Sha256: 190204c7831bbbe2fa4e436ef2204beec85c7d54b7c423bfa151d64c00bf5182

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

require 'pathname'

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 = Pathname.new(dest).cleanpath.to_s + '/' unless @dest.empty?
          end

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

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

            zip_add(zip, @dest + File.basename(@path), rebase(@path))
          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

          def self.included(base)
            IronWorkerNG::Code::Base.register_feature(:name => 'merge_file', :for_klass => base, :args => 'PATH[,DEST]')
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
iron_worker_ng-0.7.4 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.7.3 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.7.2 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.7.1 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.7.0 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.6.8 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.6.7 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.6.6 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.6.5 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.6.4 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.6.3 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.6.2 lib/iron_worker_ng/feature/common/merge_file.rb
iron_worker_ng-0.6.1 lib/iron_worker_ng/feature/common/merge_file.rb