Sha256: 6ad14b6dc8fdb7f46a1da0b36a8bc9e506f5438619ab11bc2f93879d34763349

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

module IronWorkerNG
  module Feature
    module Node
      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 node 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 node worker with path='#{path}'"
              return
            end

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

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

            IronWorkerNG::Logger.info "Merging node 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/node/merge_worker.rb
iron_worker_ng-0.2.3 lib/iron_worker_ng/feature/node/merge_worker.rb
iron_worker_ng-0.2.2 lib/iron_worker_ng/feature/node/merge_worker.rb
iron_worker_ng-0.2.1 lib/iron_worker_ng/feature/node/merge_worker.rb