iron_worker_ng 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/iron_worker +6 -2
- data/lib/iron_worker_ng.rb +1 -5
- data/lib/iron_worker_ng/client.rb +1 -1
- data/lib/iron_worker_ng/code/base.rb +39 -48
- data/lib/iron_worker_ng/code/binary.rb +3 -27
- data/lib/iron_worker_ng/code/creator.rb +60 -0
- data/lib/iron_worker_ng/code/initializer.rb +42 -0
- data/lib/iron_worker_ng/code/java.rb +4 -28
- data/lib/iron_worker_ng/code/node.rb +3 -27
- data/lib/iron_worker_ng/code/ruby.rb +10 -10
- data/lib/iron_worker_ng/feature/binary/merge_exec.rb +2 -0
- data/lib/iron_worker_ng/feature/java/merge_exec.rb +2 -0
- data/lib/iron_worker_ng/feature/node/merge_exec.rb +2 -0
- data/lib/iron_worker_ng/feature/ruby/merge_exec.rb +2 -0
- metadata +21 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/bin/iron_worker
CHANGED
@@ -74,9 +74,13 @@ if command == 'codes.create'
|
|
74
74
|
exit 1
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
code = nil
|
78
78
|
|
79
|
-
|
79
|
+
if runtime.nil?
|
80
|
+
code = IronWorkerNG::Code::Creator.create(:name => name)
|
81
|
+
else
|
82
|
+
code = runtimes.find { |r| r[:name] == runtime }[:klass].new(:name => name)
|
83
|
+
end
|
80
84
|
|
81
85
|
execute_features.each do |f|
|
82
86
|
code.send(f[:name], *f[:args])
|
data/lib/iron_worker_ng.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
1
|
require_relative 'iron_worker_ng/version'
|
2
2
|
require_relative 'iron_worker_ng/client'
|
3
|
-
require_relative 'iron_worker_ng/code/
|
4
|
-
require_relative 'iron_worker_ng/code/ruby'
|
5
|
-
require_relative 'iron_worker_ng/code/java'
|
6
|
-
require_relative 'iron_worker_ng/code/node'
|
7
|
-
require_relative 'iron_worker_ng/code/binary'
|
3
|
+
require_relative 'iron_worker_ng/code/creator'
|
@@ -57,7 +57,7 @@ module IronWorkerNG
|
|
57
57
|
|
58
58
|
def codes_create(code)
|
59
59
|
zip_file = code.create_zip
|
60
|
-
res = @api.codes_create(code.name, zip_file,
|
60
|
+
res = @api.codes_create(code.name, zip_file, 'sh', '__runner__.sh')
|
61
61
|
File.unlink(zip_file)
|
62
62
|
|
63
63
|
OpenStruct.new(res)
|
@@ -30,52 +30,19 @@ module IronWorkerNG
|
|
30
30
|
@@registered_features << feature
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.guess_name_for_path(path)
|
34
|
+
File.basename(path).gsub(/\..*$/, '').capitalize.gsub(/_./) { |x| x[1].upcase }
|
35
|
+
end
|
36
|
+
|
37
|
+
include IronWorkerNG::Code::Initializer::InstanceMethods
|
38
|
+
|
33
39
|
include IronWorkerNG::Feature::Common::MergeFile::InstanceMethods
|
34
40
|
include IronWorkerNG::Feature::Common::MergeDir::InstanceMethods
|
35
41
|
|
36
42
|
def initialize(*args, &block)
|
37
|
-
@name = nil
|
38
43
|
@features = []
|
39
44
|
|
40
|
-
|
41
|
-
merge_exec(args[0])
|
42
|
-
elsif args.length == 1 && args[0].class == Hash
|
43
|
-
@name = args[0][:name] || args[0]['name']
|
44
|
-
|
45
|
-
exec = args[0][:exec] || args[0]['exec'] ||
|
46
|
-
args[0][:worker] || args[0]['worker']
|
47
|
-
merge_exec(exec) unless exec.nil?
|
48
|
-
end
|
49
|
-
|
50
|
-
if args.length == 1 and (opts = args[0]).is_a? Hash and wfile = opts[:workerfile] || opts['workerfile']
|
51
|
-
eval(File.read(File.expand_path wfile))
|
52
|
-
end
|
53
|
-
|
54
|
-
unless @exec.nil?
|
55
|
-
@name ||= guess_name(@exec.path)
|
56
|
-
end
|
57
|
-
|
58
|
-
wfiles = ['Workerfile']
|
59
|
-
|
60
|
-
unless @name.nil?
|
61
|
-
wfiles << @name + '.worker'
|
62
|
-
wfiles << @name + '.workerfile'
|
63
|
-
end
|
64
|
-
|
65
|
-
wfiles.each do |wfile|
|
66
|
-
if File.exists? wfile
|
67
|
-
eval(File.read wfile)
|
68
|
-
IronCore::Logger.info 'IronWorkerNG', "Processing workerfile #{wfile}"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
unless block.nil?
|
73
|
-
instance_eval(&block)
|
74
|
-
end
|
75
|
-
|
76
|
-
unless @exec.nil?
|
77
|
-
@name ||= guess_name(@exec.path)
|
78
|
-
end
|
45
|
+
initialize_code(*args, &block)
|
79
46
|
end
|
80
47
|
|
81
48
|
def name(*args)
|
@@ -88,8 +55,16 @@ module IronWorkerNG
|
|
88
55
|
@name = name
|
89
56
|
end
|
90
57
|
|
91
|
-
def
|
92
|
-
|
58
|
+
def runtime(*args)
|
59
|
+
end
|
60
|
+
|
61
|
+
def runtime=(runtime)
|
62
|
+
end
|
63
|
+
|
64
|
+
def guess_name
|
65
|
+
if @name.nil? && (not @exec.nil?)
|
66
|
+
@name = IronWorkerNG::Code::Base.guess_name_for_path(@exec.path)
|
67
|
+
end
|
93
68
|
end
|
94
69
|
|
95
70
|
def fixate
|
@@ -128,17 +103,33 @@ module IronWorkerNG
|
|
128
103
|
|
129
104
|
Zip::ZipFile.open(zip_name, Zip::ZipFile::CREATE) do |zip|
|
130
105
|
bundle(zip)
|
131
|
-
|
106
|
+
|
107
|
+
zip.get_output_stream('__runner__.sh') do |runner|
|
108
|
+
runner.write <<RUNNER
|
109
|
+
#!/bin/sh
|
110
|
+
# iron_worker_ng-#{IronWorkerNG.full_version}
|
111
|
+
|
112
|
+
root() {
|
113
|
+
while [ $# -gt 0 ]; do
|
114
|
+
if [ "$1" = "-d" ]; then
|
115
|
+
printf "%s\n" "$2"
|
116
|
+
break
|
117
|
+
fi
|
118
|
+
done
|
119
|
+
}
|
120
|
+
|
121
|
+
cd "$(root "$@")"
|
122
|
+
|
123
|
+
#{run_code}
|
124
|
+
RUNNER
|
125
|
+
end
|
132
126
|
end
|
133
127
|
|
134
128
|
zip_name
|
135
129
|
end
|
136
130
|
|
137
|
-
def
|
138
|
-
|
139
|
-
|
140
|
-
def runner
|
141
|
-
nil
|
131
|
+
def run_code
|
132
|
+
''
|
142
133
|
end
|
143
134
|
end
|
144
135
|
end
|
@@ -5,36 +5,12 @@ module IronWorkerNG
|
|
5
5
|
class Binary < IronWorkerNG::Code::Base
|
6
6
|
include IronWorkerNG::Feature::Binary::MergeExec::InstanceMethods
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
runner.write <<RUNNER
|
11
|
-
#!/bin/sh
|
12
|
-
# iron_worker_ng-#{IronWorkerNG.full_version}
|
13
|
-
|
14
|
-
root() {
|
15
|
-
while [ $# -gt 0 ]; do
|
16
|
-
if [ "$1" = "-d" ]; then
|
17
|
-
printf "%s\n" "$2"
|
18
|
-
break
|
19
|
-
fi
|
20
|
-
done
|
21
|
-
}
|
22
|
-
|
23
|
-
cd "$(root "$@")"
|
24
|
-
|
8
|
+
def run_code
|
9
|
+
<<RUN_CODE
|
25
10
|
chmod +x #{File.basename(@exec.path)}
|
26
11
|
|
27
12
|
LD_LIBRARY_PATH=. ./#{File.basename(@exec.path)} "$@"
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def runtime(runtime = nil)
|
33
|
-
'sh'
|
34
|
-
end
|
35
|
-
|
36
|
-
def runner
|
37
|
-
'__runner__.sh'
|
13
|
+
RUN_CODE
|
38
14
|
end
|
39
15
|
end
|
40
16
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative 'initializer'
|
2
|
+
require_relative 'base'
|
3
|
+
require_relative 'ruby'
|
4
|
+
require_relative 'java'
|
5
|
+
require_relative 'node'
|
6
|
+
require_relative 'binary'
|
7
|
+
|
8
|
+
module IronWorkerNG
|
9
|
+
module Code
|
10
|
+
class Creator
|
11
|
+
include IronWorkerNG::Code::Initializer::InstanceMethods
|
12
|
+
|
13
|
+
def self.create(*args, &block)
|
14
|
+
runtime = IronWorkerNG::Code::Creator.new(*args, &block).runtime || 'ruby'
|
15
|
+
|
16
|
+
IronWorkerNG::Code::Base.registered_types.find { |r| r[:name] == runtime }[:klass].new(*args, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(*args, &block)
|
20
|
+
initialize_code(*args, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def name(*args)
|
24
|
+
@name = args[0] if args.length == 1
|
25
|
+
|
26
|
+
@name
|
27
|
+
end
|
28
|
+
|
29
|
+
def name=(name)
|
30
|
+
@name = name
|
31
|
+
end
|
32
|
+
|
33
|
+
def runtime(*args)
|
34
|
+
@runtime = args[0] if args.length == 1
|
35
|
+
|
36
|
+
@runtime
|
37
|
+
end
|
38
|
+
|
39
|
+
def runtime=(runtime)
|
40
|
+
@runtime = runtime
|
41
|
+
end
|
42
|
+
|
43
|
+
def merge_exec(path, *args)
|
44
|
+
@exec = path
|
45
|
+
|
46
|
+
if @name.nil? && (not @exec.nil?)
|
47
|
+
@name = IronWorkerNG::Code::Base.guess_name_for_path(@exec)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
alias :exec :merge_exec
|
52
|
+
|
53
|
+
alias :merge_worker :merge_exec
|
54
|
+
alias :worker :merge_worker
|
55
|
+
|
56
|
+
def method_missing(name, *args)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module IronWorkerNG
|
2
|
+
module Code
|
3
|
+
module Initializer
|
4
|
+
module InstanceMethods
|
5
|
+
def initialize_code(*args, &block)
|
6
|
+
@name = nil
|
7
|
+
@exec = nil
|
8
|
+
|
9
|
+
if args.length == 1 && args[0].class == String
|
10
|
+
merge_exec(args[0])
|
11
|
+
elsif args.length == 1 && args[0].class == Hash
|
12
|
+
@name = args[0][:name] || args[0]['name']
|
13
|
+
|
14
|
+
exec = args[0][:exec] || args[0]['exec'] || args[0][:worker] || args[0]['worker']
|
15
|
+
merge_exec(exec) unless exec.nil?
|
16
|
+
end
|
17
|
+
|
18
|
+
if args.length == 1 and (opts = args[0]).is_a? Hash and wfile = opts[:workerfile] || opts['workerfile']
|
19
|
+
eval(File.read(File.expand_path wfile))
|
20
|
+
end
|
21
|
+
|
22
|
+
wfiles = ['Workerfile']
|
23
|
+
|
24
|
+
unless @name.nil?
|
25
|
+
wfiles << @name + '.worker'
|
26
|
+
wfiles << @name + '.workerfile'
|
27
|
+
end
|
28
|
+
|
29
|
+
wfiles.each do |wfile|
|
30
|
+
if File.exists?(wfile)
|
31
|
+
eval(File.read(wfile))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
unless block.nil?
|
36
|
+
instance_eval(&block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -7,7 +7,7 @@ module IronWorkerNG
|
|
7
7
|
include IronWorkerNG::Feature::Java::MergeJar::InstanceMethods
|
8
8
|
include IronWorkerNG::Feature::Java::MergeExec::InstanceMethods
|
9
9
|
|
10
|
-
def
|
10
|
+
def run_code
|
11
11
|
classpath_array = []
|
12
12
|
|
13
13
|
@features.each do |f|
|
@@ -19,34 +19,10 @@ module IronWorkerNG
|
|
19
19
|
classpath = classpath_array.join(':')
|
20
20
|
|
21
21
|
IronCore::Logger.info 'IronWorkerNG', "Collected '#{classpath}' classpath"
|
22
|
-
|
23
|
-
|
24
|
-
runner.write <<RUNNER
|
25
|
-
#!/bin/sh
|
26
|
-
# iron_worker_ng-#{IronWorkerNG.full_version}
|
27
|
-
|
28
|
-
root() {
|
29
|
-
while [ $# -gt 0 ]; do
|
30
|
-
if [ "$1" = "-d" ]; then
|
31
|
-
printf "%s\n" "$2"
|
32
|
-
break
|
33
|
-
fi
|
34
|
-
done
|
35
|
-
}
|
36
|
-
|
37
|
-
cd "$(root "$@")"
|
38
|
-
|
22
|
+
|
23
|
+
<<RUN_CODE
|
39
24
|
java -cp #{classpath} #{@exec.klass.nil? ? "-jar #{File.basename(@exec.path)}" : @exec.klass} "$@"
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def runtime(runtime = nil)
|
45
|
-
'sh'
|
46
|
-
end
|
47
|
-
|
48
|
-
def runner
|
49
|
-
'__runner__.sh'
|
25
|
+
RUN_CODE
|
50
26
|
end
|
51
27
|
end
|
52
28
|
end
|
@@ -5,34 +5,10 @@ module IronWorkerNG
|
|
5
5
|
class Node < IronWorkerNG::Code::Base
|
6
6
|
include IronWorkerNG::Feature::Node::MergeExec::InstanceMethods
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
runner.write <<RUNNER
|
11
|
-
#!/bin/sh
|
12
|
-
# iron_worker_ng-#{IronWorkerNG.full_version}
|
13
|
-
|
14
|
-
root() {
|
15
|
-
while [ $# -gt 0 ]; do
|
16
|
-
if [ "$1" = "-d" ]; then
|
17
|
-
printf "%s\n" "$2"
|
18
|
-
break
|
19
|
-
fi
|
20
|
-
done
|
21
|
-
}
|
22
|
-
|
23
|
-
cd "$(root "$@")"
|
24
|
-
|
8
|
+
def run_code
|
9
|
+
<<RUN_CODE
|
25
10
|
node #{File.basename(@exec.path)} "$@"
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def runtime(runtime = nil)
|
31
|
-
'sh'
|
32
|
-
end
|
33
|
-
|
34
|
-
def runner
|
35
|
-
'__runner__.sh'
|
11
|
+
RUN_CODE
|
36
12
|
end
|
37
13
|
end
|
38
14
|
end
|
@@ -9,7 +9,9 @@ module IronWorkerNG
|
|
9
9
|
include IronWorkerNG::Feature::Ruby::MergeGemfile::InstanceMethods
|
10
10
|
include IronWorkerNG::Feature::Ruby::MergeExec::InstanceMethods
|
11
11
|
|
12
|
-
def
|
12
|
+
def bundle(zip)
|
13
|
+
super(zip)
|
14
|
+
|
13
15
|
gempath_code_array = []
|
14
16
|
|
15
17
|
@features.each do |f|
|
@@ -20,8 +22,8 @@ module IronWorkerNG
|
|
20
22
|
|
21
23
|
gempath_code = gempath_code_array.join("\n")
|
22
24
|
|
23
|
-
zip.get_output_stream(
|
24
|
-
runner.write <<
|
25
|
+
zip.get_output_stream('__runner__.rb') do |runner|
|
26
|
+
runner.write <<RUBY_RUNNER
|
25
27
|
# iron_worker_ng-#{IronWorkerNG.full_version}
|
26
28
|
|
27
29
|
module IronWorkerNG
|
@@ -91,16 +93,14 @@ unless #{@exec.klass == nil}
|
|
91
93
|
|
92
94
|
exec_inst.run
|
93
95
|
end
|
94
|
-
|
96
|
+
RUBY_RUNNER
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
98
|
-
def
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
def runner
|
103
|
-
'__runner__.rb'
|
100
|
+
def run_code
|
101
|
+
<<RUN_CODE
|
102
|
+
ruby __runner__.rb "$@"
|
103
|
+
RUN_CODE
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_worker_ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: iron_core
|
@@ -60,6 +60,22 @@ dependencies:
|
|
60
60
|
- - ! '>'
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 1.0.0
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
63
79
|
- !ruby/object:Gem::Dependency
|
64
80
|
name: jeweler2
|
65
81
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,6 +112,8 @@ files:
|
|
96
112
|
- lib/iron_worker_ng/client.rb
|
97
113
|
- lib/iron_worker_ng/code/base.rb
|
98
114
|
- lib/iron_worker_ng/code/binary.rb
|
115
|
+
- lib/iron_worker_ng/code/creator.rb
|
116
|
+
- lib/iron_worker_ng/code/initializer.rb
|
99
117
|
- lib/iron_worker_ng/code/java.rb
|
100
118
|
- lib/iron_worker_ng/code/node.rb
|
101
119
|
- lib/iron_worker_ng/code/ruby.rb
|
@@ -124,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
142
|
version: '0'
|
125
143
|
segments:
|
126
144
|
- 0
|
127
|
-
hash:
|
145
|
+
hash: 833770483
|
128
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
147
|
none: false
|
130
148
|
requirements:
|