Sha256: 41ed6675929df3948c8fbcf0f7080b52d3f7e54944b62c5e9fb73ed628be5566

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

module IronWorkerNG
  module Feature
    module Binary
      module MergeWorker
        class Feature < IronWorkerNG::Feature::Base
          attr_reader :path

          def initialize(path)
            @path = File.expand_path(path)
          end

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

          def bundle(zip)
            IronWorkerNG::Logger.debug "Bundling binary worker with path='#{@path}'"

            zip.add(File.basename(@path), @path)
          end
        end

        module InstanceMethods
          attr_reader :worker

          def merge_worker(path)
            @worker ||= nil 

            unless @worker.nil?
              IronWorkerNG::Logger.warn "Ignoring attempt to merge binary worker with path='#{path}'"
              return
            end

            @name ||= File.basename(path).gsub(/\..*$/, '').capitalize.gsub(/_./) { |x| x[1].upcase }

            @worker = IronWorkerNG::Feature::Binary::MergeWorker::Feature.new(path)

            IronWorkerNG::Logger.info "Merging binary worker with path='#{path}'"

            @features << @worker
          end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iron_worker_ng-0.2.4 lib/iron_worker_ng/feature/binary/merge_worker.rb
iron_worker_ng-0.2.3 lib/iron_worker_ng/feature/binary/merge_worker.rb
iron_worker_ng-0.2.2 lib/iron_worker_ng/feature/binary/merge_worker.rb
iron_worker_ng-0.2.1 lib/iron_worker_ng/feature/binary/merge_worker.rb