/
merge_exec.rb
51 lines (38 loc) · 1.24 KB
/
merge_exec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module IronWorkerNG
module Feature
module Node
module MergeExec
class Feature < IronWorkerNG::Feature::Base
attr_reader :path
def initialize(code, path)
super(code)
@path = path
end
def hash_string
Digest::MD5.hexdigest(@path + File.mtime(rebase(@path)).to_i.to_s)
end
def bundle(zip)
IronCore::Logger.debug 'IronWorkerNG', "Bundling node exec with path='#{@path}'"
zip_add(zip, File.basename(@path), rebase(@path))
end
end
module InstanceMethods
def merge_exec(path=nil)
@exec ||= nil
return @exec unless path
unless @exec.nil?
IronCore::Logger.warn 'IronWorkerNG', "Ignoring attempt to merge node exec with path='#{path}'"
return
end
@exec = IronWorkerNG::Feature::Node::MergeExec::Feature.new(self, path)
IronCore::Logger.info 'IronWorkerNG', "Merging node exec with path='#{path}'"
@features << @exec
end
alias :exec :merge_exec
alias :merge_worker :merge_exec
alias :worker :merge_worker
end
end
end
end
end