Sha256: 674eb749ff3f951fa7f082efb793f0e53fcfa81de883f2c75f287d29aa8505af

Contents?: true

Size: 1.4 KB

Versions: 8

Compression:

Stored size: 1.4 KB

Contents

module IronWorkerNG
  module Feature
    module Binary
      module MergeExec
        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 exec with path='#{@path}'"

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

        module InstanceMethods
          def merge_exec(path)
            @exec ||= nil 

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

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

            @exec = IronWorkerNG::Feature::Binary::MergeExec::Feature.new(path)

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

            @features << @exec
          end

          alias :exec :merge_exec

          alias :merge_worker :merge_exec
          alias :worker :merge_worker

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
iron_worker_ng-0.3.9 lib/iron_worker_ng/feature/binary/merge_exec.rb
iron_worker_ng-0.3.8 lib/iron_worker_ng/feature/binary/merge_exec.rb
iron_worker_ng-0.3.7 lib/iron_worker_ng/feature/binary/merge_exec.rb
iron_worker_ng-0.3.6 lib/iron_worker_ng/feature/binary/merge_exec.rb
iron_worker_ng-0.3.5 lib/iron_worker_ng/feature/binary/merge_exec.rb
iron_worker_ng-0.3.4 lib/iron_worker_ng/feature/binary/merge_exec.rb
iron_worker_ng-0.3.3 lib/iron_worker_ng/feature/binary/merge_exec.rb
iron_worker_ng-0.3.2 lib/iron_worker_ng/feature/binary/merge_exec.rb