astrails/safe

View on GitHub
lib/astrails/safe/archive.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Astrails
  module Safe
    class Archive < Source

      def command
        "tar -cf - #{config[:options]} #{tar_exclude_files} #{tar_files}"
      end

      def extension; '.tar'; end

      protected

      def tar_exclude_files
        [*config[:exclude]].compact.map{|x| "--exclude=#{x}"}.join(" ")
      end

      def tar_files
        raise RuntimeError, "missing files for tar" unless config[:files]
        [*config[:files]].map{|s| s.strip}.join(" ")
      end

    end
  end
end