iron_worker_ng 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -1
- data/VERSION +1 -1
- data/bin/iron_worker +32 -7
- data/lib/3rdparty/hashie/indifferent_access.rb +111 -0
- data/lib/3rdparty/hashie/merge_initializer.rb +25 -0
- data/lib/iron_worker_ng/api_client.rb +1 -1
- data/lib/iron_worker_ng/client.rb +10 -2
- data/lib/iron_worker_ng/code/base.rb +26 -12
- data/lib/iron_worker_ng/code/binary.rb +2 -2
- data/lib/iron_worker_ng/code/java.rb +2 -2
- data/lib/iron_worker_ng/code/node.rb +2 -2
- data/lib/iron_worker_ng/code/ruby.rb +8 -149
- data/lib/iron_worker_ng/feature/binary/merge_exec.rb +5 -2
- data/lib/iron_worker_ng/feature/java/merge_exec.rb +5 -6
- data/lib/iron_worker_ng/feature/java/merge_jar.rb +5 -0
- data/lib/iron_worker_ng/feature/node/merge_exec.rb +5 -2
- data/lib/iron_worker_ng/feature/ruby/merge_exec.rb +5 -6
- data/lib/iron_worker_ng/version.rb +4 -0
- metadata +11 -25
data/README.md
CHANGED
@@ -32,7 +32,6 @@ Each IronWorkerNG Ruby worker is just Ruby code. It can be as simple or as compl
|
|
32
32
|
```ruby
|
33
33
|
puts "I'm worker"
|
34
34
|
puts "My task_id is #{@iron_worker_task_id}"
|
35
|
-
puts "I'm executing inside #{@iron_io_project_id} and was queued using #{@iron_io_token} token"
|
36
35
|
puts "I got '#{params}' parameters"
|
37
36
|
```
|
38
37
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/bin/iron_worker
CHANGED
@@ -4,19 +4,36 @@ require 'optparse'
|
|
4
4
|
require 'time'
|
5
5
|
require 'iron_worker_ng'
|
6
6
|
|
7
|
-
if $*.size ==
|
7
|
+
if $*.size == 1 && ($*[0] == '-v' || $*[0] == '--version')
|
8
|
+
puts IronWorkerNG.full_version
|
9
|
+
exit 0
|
10
|
+
end
|
11
|
+
|
12
|
+
if $*.size == 0 || (not ['codes.create', 'upload', 'tasks.create', 'queue', 'schedules.create', 'schedule', 'tasks.log', 'log'].include?($*[0]))
|
8
13
|
puts 'usage: iron_worker COMMAND [OPTIONS]'
|
9
|
-
puts ' COMMAND: codes.create, tasks.create, schedules.create, tasks.log'
|
14
|
+
puts ' COMMAND: codes.create (upload), tasks.create (queue), schedules.create (schedule), tasks.log (log)'
|
10
15
|
puts ' run iron_worker COMMAND --help to get more information about each command'
|
11
16
|
exit 1
|
12
17
|
end
|
13
18
|
|
14
|
-
command =
|
15
|
-
|
19
|
+
command = $*.shift
|
20
|
+
|
21
|
+
command = 'codes.create' if command == 'upload'
|
22
|
+
command = 'tasks.create' if command == 'queue'
|
23
|
+
command = 'schedules.create' if command == 'schedule'
|
24
|
+
command = 'tasks.log' if command == 'log'
|
25
|
+
|
26
|
+
if level = ENV['LOG_LEVEL']
|
27
|
+
IronCore::Logger.logger.level = eval "::Logger::#{level}"
|
28
|
+
end
|
16
29
|
|
17
30
|
client = IronWorkerNG::Client.new
|
18
31
|
|
19
32
|
if command == 'codes.create'
|
33
|
+
if $*.size > 0 && $*[0][0] != '-'
|
34
|
+
$*.unshift('-n')
|
35
|
+
end
|
36
|
+
|
20
37
|
runtimes = IronWorkerNG::Code::Base.registered_types
|
21
38
|
runtimes_help = runtimes[0][:name] + ' (default)' + (runtimes.size == 1 ? '' : ', ') + runtimes.map { |r| r[:name] }[1 .. -1].join(', ')
|
22
39
|
|
@@ -57,7 +74,7 @@ if command == 'codes.create'
|
|
57
74
|
exit 1
|
58
75
|
end
|
59
76
|
|
60
|
-
runtime =
|
77
|
+
runtime = 'ruby' if runtime.nil?
|
61
78
|
|
62
79
|
code = runtimes.find { |r| r[:name] == runtime }[:klass].new(:name => name)
|
63
80
|
|
@@ -67,6 +84,10 @@ if command == 'codes.create'
|
|
67
84
|
|
68
85
|
client.codes.create(code)
|
69
86
|
elsif command == 'tasks.create' || command == 'schedules.create'
|
87
|
+
if $*.size > 0 && $*[0][0] != '-'
|
88
|
+
$*.unshift('-n')
|
89
|
+
end
|
90
|
+
|
70
91
|
name = nil
|
71
92
|
payload = nil
|
72
93
|
|
@@ -162,17 +183,21 @@ elsif command == 'tasks.create' || command == 'schedules.create'
|
|
162
183
|
|
163
184
|
print id if print_id
|
164
185
|
elsif command == 'tasks.log'
|
186
|
+
if $*.size > 0 && $*[0][0] != '-'
|
187
|
+
$*.unshift('-t')
|
188
|
+
end
|
189
|
+
|
165
190
|
task_id = nil
|
166
191
|
live = false
|
167
192
|
|
168
193
|
opts = OptionParser.new do |opts|
|
169
194
|
opts.banner = "usage: iron_worker #{command} [OPTIONS]"
|
170
195
|
|
171
|
-
opts.on('-t --task-id ID', 'task id') do |v|
|
196
|
+
opts.on('-t', '--task-id ID', 'task id') do |v|
|
172
197
|
task_id = v
|
173
198
|
end
|
174
199
|
|
175
|
-
opts.on('--
|
200
|
+
opts.on('-w', '--wait', 'wait for task') do |v|
|
176
201
|
live = true
|
177
202
|
end
|
178
203
|
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# source: https://github.com/intridea/hashie/blob/6d21c6868512603e77a340827ec91ecd3bcef078/lib/hashie/extensions/indifferent_access.rb
|
2
|
+
module Hashie
|
3
|
+
module Extensions
|
4
|
+
# IndifferentAccess gives you the ability to not care
|
5
|
+
# whether your hash has string or symbol keys. Made famous
|
6
|
+
# in Rails for accessing query and POST parameters, this
|
7
|
+
# is a handy tool for making sure your hash has maximum
|
8
|
+
# utility.
|
9
|
+
#
|
10
|
+
# One unique feature of this mixin is that it will recursively
|
11
|
+
# inject itself into sub-hash instances without modifying
|
12
|
+
# the actual class of the sub-hash.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# class MyHash < Hash
|
16
|
+
# include Hashie::Extensions::MergeInitializer
|
17
|
+
# include Hashie::Extensions::IndifferentAccess
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# h = MyHash.new(:foo => 'bar', 'baz' => 'blip')
|
21
|
+
# h['foo'] # => 'bar'
|
22
|
+
# h[:foo] # => 'bar'
|
23
|
+
# h[:baz] # => 'blip'
|
24
|
+
# h['baz'] # => 'blip'
|
25
|
+
#
|
26
|
+
module IndifferentAccess
|
27
|
+
def self.included(base)
|
28
|
+
base.class_eval do
|
29
|
+
alias_method :regular_writer, :[]=
|
30
|
+
alias_method :[]=, :indifferent_writer
|
31
|
+
%w(default update fetch delete key? values_at).each do |m|
|
32
|
+
alias_method "regular_#{m}", m
|
33
|
+
alias_method m, "indifferent_#{m}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# This will inject indifferent access into an instance of
|
39
|
+
# a hash without modifying the actual class. This is what
|
40
|
+
# allows IndifferentAccess to spread to sub-hashes.
|
41
|
+
def self.inject!(hash)
|
42
|
+
(class << hash; self; end).send :include, Hashie::Extensions::IndifferentAccess
|
43
|
+
hash.convert!
|
44
|
+
end
|
45
|
+
|
46
|
+
# Injects indifferent access into a duplicate of the hash
|
47
|
+
# provided. See #inject!
|
48
|
+
def self.inject(hash)
|
49
|
+
inject!(hash.dup)
|
50
|
+
end
|
51
|
+
|
52
|
+
def convert_key(key)
|
53
|
+
key.to_s
|
54
|
+
end
|
55
|
+
|
56
|
+
# Iterates through the keys and values, reconverting them to
|
57
|
+
# their proper indifferent state. Used when IndifferentAccess
|
58
|
+
# is injecting itself into member hashes.
|
59
|
+
def convert!
|
60
|
+
keys.each do |k|
|
61
|
+
regular_writer convert_key(k), convert_value(self.regular_delete(k))
|
62
|
+
end
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
def convert_value(value)
|
67
|
+
if hash_lacking_indifference?(value)
|
68
|
+
Hashie::Extensions::IndifferentAccess.inject(value.dup)
|
69
|
+
elsif value.is_a?(::Array)
|
70
|
+
value.dup.replace(value.map { |e| convert_value(e) })
|
71
|
+
else
|
72
|
+
value
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def indifferent_default(key = nil)
|
77
|
+
return self[convert_key(key)] if key?(key)
|
78
|
+
regular_default(key)
|
79
|
+
end
|
80
|
+
|
81
|
+
def indifferent_update(other_hash)
|
82
|
+
return regular_update(other_hash) if hash_with_indifference?(other_hash)
|
83
|
+
other_hash.each_pair do |k,v|
|
84
|
+
self[k] = v
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def indifferent_writer(key, value); regular_writer convert_key(key), convert_value(value) end
|
89
|
+
def indifferent_fetch(key, *args); regular_fetch convert_key(key), *args end
|
90
|
+
def indifferent_delete(key); regular_delete convert_key(key) end
|
91
|
+
def indifferent_key?(key); regular_key? convert_key(key) end
|
92
|
+
def indifferent_values_at(*indices); indices.map{|i| self[i] } end
|
93
|
+
|
94
|
+
def indifferent_access?; true end
|
95
|
+
|
96
|
+
protected
|
97
|
+
|
98
|
+
def hash_lacking_indifference?(other)
|
99
|
+
other.is_a?(::Hash) &&
|
100
|
+
!(other.respond_to?(:indifferent_access?) &&
|
101
|
+
other.indifferent_access?)
|
102
|
+
end
|
103
|
+
|
104
|
+
def hash_with_indifference?(other)
|
105
|
+
other.is_a?(::Hash) &&
|
106
|
+
other.respond_to?(:indifferent_access?) &&
|
107
|
+
other.indifferent_access?
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# source: https://github.com/intridea/hashie/blob/6d21c6868512603e77a340827ec91ecd3bcef078/lib/hashie/extensions/merge_initializer.rb
|
2
|
+
module Hashie
|
3
|
+
module Extensions
|
4
|
+
# The MergeInitializer is a super-simple mixin that allows
|
5
|
+
# you to initialize a subclass of Hash with another Hash
|
6
|
+
# to give you faster startup time for Hash subclasses. Note
|
7
|
+
# that you can still provide a default value as a second
|
8
|
+
# argument to the initializer.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# class MyHash < Hash
|
12
|
+
# include Hashie::Extensions::MergeInitializer
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# h = MyHash.new(:abc => 'def')
|
16
|
+
# h[:abc] # => 'def'
|
17
|
+
#
|
18
|
+
module MergeInitializer
|
19
|
+
def initialize(hash = {}, default = nil, &block)
|
20
|
+
default ? super(default) : super(&block)
|
21
|
+
update(hash)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -13,7 +13,7 @@ module IronWorkerNG
|
|
13
13
|
:host => IronWorkerNG::APIClient::AWS_US_EAST_HOST,
|
14
14
|
:port => 443,
|
15
15
|
:api_version => 2,
|
16
|
-
:user_agent =>
|
16
|
+
:user_agent => IronWorkerNG.full_version)
|
17
17
|
|
18
18
|
if (not @token) || (not @project_id)
|
19
19
|
IronCore::Logger.error 'IronWorkerNG', 'Both token and project_id must be specified'
|
@@ -31,6 +31,14 @@ module IronWorkerNG
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def token
|
35
|
+
@api.token
|
36
|
+
end
|
37
|
+
|
38
|
+
def project_id
|
39
|
+
@api.project_id
|
40
|
+
end
|
41
|
+
|
34
42
|
def method_missing(name, *args, &block)
|
35
43
|
if args.length == 0
|
36
44
|
IronWorkerNG::ClientProxyCaller.new(self, name)
|
@@ -49,10 +57,10 @@ module IronWorkerNG
|
|
49
57
|
|
50
58
|
def codes_create(code)
|
51
59
|
zip_file = code.create_zip
|
52
|
-
@api.codes_create(code.name, zip_file, code.runtime, code.runner)
|
60
|
+
res = @api.codes_create(code.name, zip_file, code.runtime, code.runner)
|
53
61
|
File.unlink(zip_file)
|
54
62
|
|
55
|
-
|
63
|
+
OpenStruct.new(res)
|
56
64
|
end
|
57
65
|
|
58
66
|
def codes_delete(code_id)
|
@@ -8,8 +8,8 @@ require_relative '../feature/common/merge_dir'
|
|
8
8
|
module IronWorkerNG
|
9
9
|
module Code
|
10
10
|
class Base
|
11
|
-
attr_accessor :name
|
12
11
|
attr_reader :features
|
12
|
+
attr_accessor :name
|
13
13
|
|
14
14
|
@@registered_types = []
|
15
15
|
|
@@ -49,19 +49,35 @@ module IronWorkerNG
|
|
49
49
|
|
50
50
|
if args.length == 1 && args[0].class == Hash && ((not args[0][:workerfile].nil?) || (not args[0]['workerfile'].nil?))
|
51
51
|
eval(File.read(File.expand_path(args[0][:workerfile] || args[0]['workerfile'])))
|
52
|
-
|
53
|
-
if (not @name.nil?) && File.exists?(@name + '.worker')
|
54
|
-
eval(File.read(@name + '.worker'))
|
55
|
-
end
|
52
|
+
end
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
unless @exec.nil?
|
55
|
+
@name ||= guess_name(@exec.path)
|
56
|
+
end
|
57
|
+
|
58
|
+
if (not @name.nil?) && File.exists?(@name + '.worker')
|
59
|
+
eval(File.read(@name + '.worker'))
|
60
|
+
end
|
61
|
+
|
62
|
+
if (not @name.nil?) && File.exists?(@name + '.workerfile')
|
63
|
+
eval(File.read(@name + '.workerfile'))
|
64
|
+
end
|
65
|
+
|
66
|
+
if File.exists?('Workerfile')
|
67
|
+
eval(File.read('Workerfile'))
|
60
68
|
end
|
61
69
|
|
62
70
|
unless block.nil?
|
63
71
|
instance_eval(&block)
|
64
72
|
end
|
73
|
+
|
74
|
+
unless @exec.nil?
|
75
|
+
@name ||= guess_name(@exec.path)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def guess_name(path)
|
80
|
+
File.basename(path).gsub(/\..*$/, '').capitalize.gsub(/_./) { |x| x[1].upcase }
|
65
81
|
end
|
66
82
|
|
67
83
|
def fixate
|
@@ -92,6 +108,8 @@ module IronWorkerNG
|
|
92
108
|
|
93
109
|
fixate
|
94
110
|
|
111
|
+
@name ||= guess_name(@exec.path)
|
112
|
+
|
95
113
|
zip_name = Dir.tmpdir + '/' + Dir::Tmpname.make_tmpname("iron-worker-ng-", "code.zip")
|
96
114
|
|
97
115
|
IronCore::Logger.debug 'IronWorkerNG', "Creating code zip '#{zip_name}'"
|
@@ -107,10 +125,6 @@ module IronWorkerNG
|
|
107
125
|
def create_runner(zip)
|
108
126
|
end
|
109
127
|
|
110
|
-
def runtime
|
111
|
-
nil
|
112
|
-
end
|
113
|
-
|
114
128
|
def runner
|
115
129
|
nil
|
116
130
|
end
|
@@ -9,7 +9,7 @@ module IronWorkerNG
|
|
9
9
|
zip.get_output_stream(runner) do |runner|
|
10
10
|
runner.write <<RUNNER
|
11
11
|
#!/bin/sh
|
12
|
-
# iron_worker_ng-#{IronWorkerNG.
|
12
|
+
# iron_worker_ng-#{IronWorkerNG.full_version}
|
13
13
|
|
14
14
|
root() {
|
15
15
|
while [ $# -gt 0 ]; do
|
@@ -29,7 +29,7 @@ RUNNER
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def runtime
|
32
|
+
def runtime(runtime = nil)
|
33
33
|
'sh'
|
34
34
|
end
|
35
35
|
|
@@ -23,7 +23,7 @@ module IronWorkerNG
|
|
23
23
|
zip.get_output_stream(runner) do |runner|
|
24
24
|
runner.write <<RUNNER
|
25
25
|
#!/bin/sh
|
26
|
-
# iron_worker_ng-#{IronWorkerNG.
|
26
|
+
# iron_worker_ng-#{IronWorkerNG.full_version}
|
27
27
|
|
28
28
|
root() {
|
29
29
|
while [ $# -gt 0 ]; do
|
@@ -41,7 +41,7 @@ RUNNER
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def runtime
|
44
|
+
def runtime(runtime = nil)
|
45
45
|
'sh'
|
46
46
|
end
|
47
47
|
|
@@ -9,7 +9,7 @@ module IronWorkerNG
|
|
9
9
|
zip.get_output_stream(runner) do |runner|
|
10
10
|
runner.write <<RUNNER
|
11
11
|
#!/bin/sh
|
12
|
-
# iron_worker_ng-#{IronWorkerNG.
|
12
|
+
# iron_worker_ng-#{IronWorkerNG.full_version}
|
13
13
|
|
14
14
|
root() {
|
15
15
|
while [ $# -gt 0 ]; do
|
@@ -27,7 +27,7 @@ RUNNER
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def runtime
|
30
|
+
def runtime(runtime = nil)
|
31
31
|
'sh'
|
32
32
|
end
|
33
33
|
|
@@ -22,151 +22,16 @@ module IronWorkerNG
|
|
22
22
|
|
23
23
|
zip.get_output_stream(runner) do |runner|
|
24
24
|
runner.write <<RUNNER
|
25
|
-
# iron_worker_ng-#{IronWorkerNG.
|
26
|
-
|
27
|
-
# https://github.com/intridea/hashie/ 6d21c6868512603e77a340827ec91ecd3bcef078 START
|
28
|
-
|
29
|
-
module Hashie
|
30
|
-
module Extensions
|
31
|
-
# The MergeInitializer is a super-simple mixin that allows
|
32
|
-
# you to initialize a subclass of Hash with another Hash
|
33
|
-
# to give you faster startup time for Hash subclasses. Note
|
34
|
-
# that you can still provide a default value as a second
|
35
|
-
# argument to the initializer.
|
36
|
-
#
|
37
|
-
# @example
|
38
|
-
# class MyHash < Hash
|
39
|
-
# include Hashie::Extensions::MergeInitializer
|
40
|
-
# end
|
41
|
-
#
|
42
|
-
# h = MyHash.new(:abc => 'def')
|
43
|
-
# h[:abc] # => 'def'
|
44
|
-
#
|
45
|
-
module MergeInitializer
|
46
|
-
def initialize(hash = {}, default = nil, &block)
|
47
|
-
default ? super(default) : super(&block)
|
48
|
-
update(hash)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
module Hashie
|
55
|
-
module Extensions
|
56
|
-
# IndifferentAccess gives you the ability to not care
|
57
|
-
# whether your hash has string or symbol keys. Made famous
|
58
|
-
# in Rails for accessing query and POST parameters, this
|
59
|
-
# is a handy tool for making sure your hash has maximum
|
60
|
-
# utility.
|
61
|
-
#
|
62
|
-
# One unique feature of this mixin is that it will recursively
|
63
|
-
# inject itself into sub-hash instances without modifying
|
64
|
-
# the actual class of the sub-hash.
|
65
|
-
#
|
66
|
-
# @example
|
67
|
-
# class MyHash < Hash
|
68
|
-
# include Hashie::Extensions::MergeInitializer
|
69
|
-
# include Hashie::Extensions::IndifferentAccess
|
70
|
-
# end
|
71
|
-
#
|
72
|
-
# h = MyHash.new(:foo => 'bar', 'baz' => 'blip')
|
73
|
-
# h['foo'] # => 'bar'
|
74
|
-
# h[:foo] # => 'bar'
|
75
|
-
# h[:baz] # => 'blip'
|
76
|
-
# h['baz'] # => 'blip'
|
77
|
-
#
|
78
|
-
module IndifferentAccess
|
79
|
-
def self.included(base)
|
80
|
-
base.class_eval do
|
81
|
-
alias_method :regular_writer, :[]=
|
82
|
-
alias_method :[]=, :indifferent_writer
|
83
|
-
%w(default update fetch delete key? values_at).each do |m|
|
84
|
-
alias_method "regular_\#{m}", m
|
85
|
-
alias_method m, "indifferent_\#{m}"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# This will inject indifferent access into an instance of
|
91
|
-
# a hash without modifying the actual class. This is what
|
92
|
-
# allows IndifferentAccess to spread to sub-hashes.
|
93
|
-
def self.inject!(hash)
|
94
|
-
(class << hash; self; end).send :include, Hashie::Extensions::IndifferentAccess
|
95
|
-
hash.convert!
|
96
|
-
end
|
97
|
-
|
98
|
-
# Injects indifferent access into a duplicate of the hash
|
99
|
-
# provided. See #inject!
|
100
|
-
def self.inject(hash)
|
101
|
-
inject!(hash.dup)
|
102
|
-
end
|
103
|
-
|
104
|
-
def convert_key(key)
|
105
|
-
key.to_s
|
106
|
-
end
|
107
|
-
|
108
|
-
# Iterates through the keys and values, reconverting them to
|
109
|
-
# their proper indifferent state. Used when IndifferentAccess
|
110
|
-
# is injecting itself into member hashes.
|
111
|
-
def convert!
|
112
|
-
keys.each do |k|
|
113
|
-
regular_writer convert_key(k), convert_value(self.regular_delete(k))
|
114
|
-
end
|
115
|
-
self
|
116
|
-
end
|
117
|
-
|
118
|
-
def convert_value(value)
|
119
|
-
if hash_lacking_indifference?(value)
|
120
|
-
Hashie::Extensions::IndifferentAccess.inject(value.dup)
|
121
|
-
elsif value.is_a?(::Array)
|
122
|
-
value.dup.replace(value.map { |e| convert_value(e) })
|
123
|
-
else
|
124
|
-
value
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def indifferent_default(key = nil)
|
129
|
-
return self[convert_key(key)] if key?(key)
|
130
|
-
regular_default(key)
|
131
|
-
end
|
132
|
-
|
133
|
-
def indifferent_update(other_hash)
|
134
|
-
return regular_update(other_hash) if hash_with_indifference?(other_hash)
|
135
|
-
other_hash.each_pair do |k,v|
|
136
|
-
self[k] = v
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def indifferent_writer(key, value); regular_writer convert_key(key), convert_value(value) end
|
141
|
-
def indifferent_fetch(key, *args); regular_fetch convert_key(key), *args end
|
142
|
-
def indifferent_delete(key); regular_delete convert_key(key) end
|
143
|
-
def indifferent_key?(key); regular_key? convert_key(key) end
|
144
|
-
def indifferent_values_at(*indices); indices.map{|i| self[i] } end
|
145
|
-
|
146
|
-
def indifferent_access?; true end
|
147
|
-
|
148
|
-
protected
|
149
|
-
|
150
|
-
def hash_lacking_indifference?(other)
|
151
|
-
other.is_a?(::Hash) &&
|
152
|
-
!(other.respond_to?(:indifferent_access?) &&
|
153
|
-
other.indifferent_access?)
|
154
|
-
end
|
25
|
+
# iron_worker_ng-#{IronWorkerNG.full_version}
|
155
26
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
other.indifferent_access?
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
27
|
+
module IronWorkerNG
|
28
|
+
#{File.read(File.dirname(__FILE__) + '/../../3rdparty/hashie/merge_initializer.rb')}
|
29
|
+
#{File.read(File.dirname(__FILE__) + '/../../3rdparty/hashie/indifferent_access.rb')}
|
163
30
|
end
|
164
31
|
|
165
|
-
# https://github.com/intridea/hashie/ 6d21c6868512603e77a340827ec91ecd3bcef078 END
|
166
|
-
|
167
32
|
class IronWorkerNGHash < Hash
|
168
|
-
include Hashie::Extensions::MergeInitializer
|
169
|
-
include Hashie::Extensions::IndifferentAccess
|
33
|
+
include IronWorkerNG::Hashie::Extensions::MergeInitializer
|
34
|
+
include IronWorkerNG::Hashie::Extensions::IndifferentAccess
|
170
35
|
end
|
171
36
|
|
172
37
|
root = nil
|
@@ -212,14 +77,8 @@ end
|
|
212
77
|
|
213
78
|
require '#{File.basename(@exec.path)}'
|
214
79
|
|
215
|
-
|
216
|
-
|
217
|
-
begin
|
80
|
+
unless #{@exec.klass == nil}
|
218
81
|
exec_class = Kernel.const_get('#{@exec.klass}')
|
219
|
-
rescue
|
220
|
-
end
|
221
|
-
|
222
|
-
unless exec_class.nil?
|
223
82
|
exec_inst = exec_class.new
|
224
83
|
|
225
84
|
params.keys.each do |param|
|
@@ -236,7 +95,7 @@ RUNNER
|
|
236
95
|
end
|
237
96
|
end
|
238
97
|
|
239
|
-
def runtime
|
98
|
+
def runtime(runtime = nil)
|
240
99
|
'ruby'
|
241
100
|
end
|
242
101
|
|
@@ -6,6 +6,11 @@ module IronWorkerNG
|
|
6
6
|
attr_reader :path
|
7
7
|
|
8
8
|
def initialize(path)
|
9
|
+
unless File.exist?(path)
|
10
|
+
IronCore::Logger.error 'IronWorkerNG', "Can't find binary exec with path='#{path}'"
|
11
|
+
raise IronCore::IronError.new("Can't find binary exec with path='#{path}'")
|
12
|
+
end
|
13
|
+
|
9
14
|
@path = File.expand_path(path)
|
10
15
|
end
|
11
16
|
|
@@ -29,8 +34,6 @@ module IronWorkerNG
|
|
29
34
|
return
|
30
35
|
end
|
31
36
|
|
32
|
-
@name ||= File.basename(path).gsub(/\..*$/, '').capitalize.gsub(/_./) { |x| x[1].upcase }
|
33
|
-
|
34
37
|
@exec = IronWorkerNG::Feature::Binary::MergeExec::Feature.new(path)
|
35
38
|
|
36
39
|
IronCore::Logger.info 'IronWorkerNG', "Merging binary exec with path='#{path}'"
|
@@ -7,6 +7,11 @@ module IronWorkerNG
|
|
7
7
|
attr_reader :klass
|
8
8
|
|
9
9
|
def initialize(path, klass)
|
10
|
+
unless File.exist?(path)
|
11
|
+
IronCore::Logger.error 'IronWorkerNG', "Can't find java exec with path='#{path}'"
|
12
|
+
raise IronCore::IronError.new("Can't find java exec with path='#{path}'")
|
13
|
+
end
|
14
|
+
|
10
15
|
@path = File.expand_path(path)
|
11
16
|
@klass = klass
|
12
17
|
end
|
@@ -35,12 +40,6 @@ module IronWorkerNG
|
|
35
40
|
return
|
36
41
|
end
|
37
42
|
|
38
|
-
if klass.nil?
|
39
|
-
@name ||= File.basename(path).gsub(/\.jar$/, '').capitalize.gsub(/_./) { |x| x[1].upcase }
|
40
|
-
else
|
41
|
-
@name ||= klass.split('.')[-1]
|
42
|
-
end
|
43
|
-
|
44
43
|
@exec = IronWorkerNG::Feature::Java::MergeExec::Feature.new(path, klass)
|
45
44
|
|
46
45
|
IronCore::Logger.info 'IronWorkerNG', "Merging java exec with path='#{path}' and class='#{klass}'"
|
@@ -6,6 +6,11 @@ module IronWorkerNG
|
|
6
6
|
attr_reader :path
|
7
7
|
|
8
8
|
def initialize(path)
|
9
|
+
unless File.exist?(path)
|
10
|
+
IronCore::Logger.error 'IronWorkerNG', "Can't find java jar with path='#{path}'"
|
11
|
+
raise IronCore::IronError.new("Can't find java jar with path='#{path}'")
|
12
|
+
end
|
13
|
+
|
9
14
|
@path = File.expand_path(path)
|
10
15
|
end
|
11
16
|
|
@@ -6,6 +6,11 @@ module IronWorkerNG
|
|
6
6
|
attr_reader :path
|
7
7
|
|
8
8
|
def initialize(path)
|
9
|
+
unless File.exist?(path)
|
10
|
+
IronCore::Logger.error 'IronWorkerNG', "Can't find node exec with path='#{path}'"
|
11
|
+
raise IronCore::IronError.new("Can't find node exec with path='#{path}'")
|
12
|
+
end
|
13
|
+
|
9
14
|
@path = File.expand_path(path)
|
10
15
|
end
|
11
16
|
|
@@ -29,8 +34,6 @@ module IronWorkerNG
|
|
29
34
|
return
|
30
35
|
end
|
31
36
|
|
32
|
-
@name ||= File.basename(path).gsub(/\.js$/, '').capitalize.gsub(/_./) { |x| x[1].upcase }
|
33
|
-
|
34
37
|
@exec = IronWorkerNG::Feature::Node::MergeExec::Feature.new(path)
|
35
38
|
|
36
39
|
IronCore::Logger.info 'IronWorkerNG', "Merging node exec with path='#{path}'"
|
@@ -7,6 +7,11 @@ module IronWorkerNG
|
|
7
7
|
attr_reader :klass
|
8
8
|
|
9
9
|
def initialize(path, klass)
|
10
|
+
unless File.exist?(path)
|
11
|
+
IronCore::Logger.error 'IronWorkerNG', "Can't find ruby exec with path='#{path}'"
|
12
|
+
raise IronCore::IronError.new("Can't find ruby exec with path='#{path}'")
|
13
|
+
end
|
14
|
+
|
10
15
|
@path = File.expand_path(path)
|
11
16
|
@klass = klass
|
12
17
|
end
|
@@ -26,17 +31,11 @@ module IronWorkerNG
|
|
26
31
|
def merge_exec(path, klass = nil)
|
27
32
|
@exec ||= nil
|
28
33
|
|
29
|
-
if klass == nil
|
30
|
-
klass = File.basename(path).gsub(/\.rb$/, '').capitalize.gsub(/_./) { |x| x[1].upcase }
|
31
|
-
end
|
32
|
-
|
33
34
|
unless @exec.nil?
|
34
35
|
IronCore::Logger.warn 'IronWorkerNG', "Ignoring attempt to merge ruby exec with path='#{path}' and class='#{klass}'"
|
35
36
|
return
|
36
37
|
end
|
37
38
|
|
38
|
-
@name ||= klass
|
39
|
-
|
40
39
|
@exec = IronWorkerNG::Feature::Ruby::MergeExec::Feature.new(path, klass)
|
41
40
|
|
42
41
|
IronCore::Logger.info 'IronWorkerNG', "Merging ruby exec with path='#{path}' and class='#{klass}'"
|
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.
|
4
|
+
version: 0.4.2
|
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-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: iron_core
|
@@ -44,22 +44,6 @@ dependencies:
|
|
44
44
|
- - ! '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: json
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :runtime
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
|
-
requirements:
|
60
|
-
- - ! '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
47
|
- !ruby/object:Gem::Dependency
|
64
48
|
name: bundler
|
65
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,21 +61,21 @@ dependencies:
|
|
77
61
|
- !ruby/object:Gem::Version
|
78
62
|
version: 1.0.0
|
79
63
|
- !ruby/object:Gem::Dependency
|
80
|
-
name:
|
64
|
+
name: jeweler2
|
81
65
|
requirement: !ruby/object:Gem::Requirement
|
82
66
|
none: false
|
83
67
|
requirements:
|
84
|
-
- -
|
68
|
+
- - ! '>='
|
85
69
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
70
|
+
version: '0'
|
87
71
|
type: :development
|
88
72
|
prerelease: false
|
89
73
|
version_requirements: !ruby/object:Gem::Requirement
|
90
74
|
none: false
|
91
75
|
requirements:
|
92
|
-
- -
|
76
|
+
- - ! '>='
|
93
77
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
78
|
+
version: '0'
|
95
79
|
description: New generation ruby client for IronWorker
|
96
80
|
email: info@iron.io
|
97
81
|
executables:
|
@@ -105,6 +89,8 @@ files:
|
|
105
89
|
- README.md
|
106
90
|
- VERSION
|
107
91
|
- bin/iron_worker
|
92
|
+
- lib/3rdparty/hashie/indifferent_access.rb
|
93
|
+
- lib/3rdparty/hashie/merge_initializer.rb
|
108
94
|
- lib/iron_worker_ng.rb
|
109
95
|
- lib/iron_worker_ng/api_client.rb
|
110
96
|
- lib/iron_worker_ng/client.rb
|
@@ -138,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
124
|
version: '0'
|
139
125
|
segments:
|
140
126
|
- 0
|
141
|
-
hash: -
|
127
|
+
hash: -641630419
|
142
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
129
|
none: false
|
144
130
|
requirements:
|
@@ -147,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
133
|
version: '0'
|
148
134
|
requirements: []
|
149
135
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.8.
|
136
|
+
rubygems_version: 1.8.24
|
151
137
|
signing_key:
|
152
138
|
specification_version: 3
|
153
139
|
summary: New generation ruby client for IronWorker
|