Sha256: 3f580e78e1738cc251bb559b53d43debf2928bb50a312dcd98eba520566d74c9

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 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
          attr_reader :exec

          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

1 entries across 1 versions & 1 rubygems

Version Path
iron_worker_ng-0.3.1 lib/iron_worker_ng/feature/binary/merge_exec.rb