Sha256: 013ee62e10c639e87e05e655a41df41f45d4d16eba49e92dbf33e9b0cf697a20

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

module IronWorkerNG
  module Feature
    module Common
      module MergeFile
        class Feature < IronWorkerNG::Feature::Base
          attr_reader :path
          attr_reader :dest

          def initialize(code, path, dest)
            super(code)

            @path = path
            @dest = dest + (dest.empty? || dest.end_with?('/') ? '' : '/')
          end

          def hash_string
            Digest::MD5.hexdigest(@path + @dest + File.mtime(rebase(@path)).to_i.to_s)
          end

          def bundle(container)
            IronCore::Logger.debug 'IronWorkerNG', "Bundling file with path='#{@path}' and dest='#{@dest}'"

            container_add(container, @dest + File.basename(@path), rebase(@path))
          end

          def command(remote = false)
            if remote
              if IronWorkerNG::Fetcher.remote?(rebase(@path))
                "file '#{rebase(@path)}', '#{@dest}'"
              else
                "file '#{@dest}#{File.basename(@path)}', '#{@dest}'"
              end
            else
              "file '#{@path}', '#{@dest}'"
            end
          end
        end

        module InstanceMethods
          def merge_file(path, dest = '')
            IronCore::Logger.info 'IronWorkerNG', "Merging file with path='#{path}' and dest='#{dest}'"

            @features << IronWorkerNG::Feature::Common::MergeFile::Feature.new(self, path, dest)
          end

          alias :file :merge_file
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iron_worker_ng-0.10.4 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.10.3 lib/iron_worker_ng/feature/common/merge_file.rb