iron_worker_ng 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.9
@@ -24,6 +24,151 @@ module IronWorkerNG
24
24
  runner.write <<RUNNER
25
25
  # iron_worker_ng-#{IronWorkerNG.version}
26
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
155
+
156
+ def hash_with_indifference?(other)
157
+ other.is_a?(::Hash) &&
158
+ other.respond_to?(:indifferent_access?) &&
159
+ other.indifferent_access?
160
+ end
161
+ end
162
+ end
163
+ end
164
+
165
+ # https://github.com/intridea/hashie/ 6d21c6868512603e77a340827ec91ecd3bcef078 END
166
+
167
+ class IronWorkerNGHash < Hash
168
+ include Hashie::Extensions::MergeInitializer
169
+ include Hashie::Extensions::IndifferentAccess
170
+ end
171
+
27
172
  root = nil
28
173
  payload_file = nil
29
174
  task_id = nil
@@ -45,16 +190,13 @@ require 'json'
45
190
 
46
191
  @payload = File.read(payload_file)
47
192
 
48
- @params = {}
193
+ params = {}
49
194
  begin
50
- @params = JSON.parse(@payload)
195
+ params = JSON.parse(@payload)
51
196
  rescue
52
197
  end
53
198
 
54
- keys = @params.keys
55
- keys.each do |key|
56
- @params[key.to_sym] = @params[key]
57
- end
199
+ @params = IronWorkerNGHash.new(params)
58
200
 
59
201
  def payload
60
202
  @payload
@@ -42,9 +42,9 @@ module IronWorkerNG
42
42
  if @spec.extensions.length == 0 || IronWorkerNG::Feature::Ruby::MergeGem.merge_binary?
43
43
  IronWorkerNG::Logger.debug "Bundling ruby gem with name='#{@spec.name}' and version='#{@spec.version}'"
44
44
 
45
- zip.add('gems/' + @spec.full_name, gem_path)
45
+ zip.add('__gems__/' + @spec.full_name, gem_path)
46
46
  Dir.glob(gem_path + '/**/**') do |path|
47
- zip.add('gems/' + @spec.full_name + path[gem_path.length .. -1], path)
47
+ zip.add('__gems__/' + @spec.full_name + path[gem_path.length .. -1], path)
48
48
  end
49
49
  else
50
50
  IronWorkerNG::Logger.warn "Skipping ruby gem with name='#{@spec.name}' and version='#{@spec.version}' as it contains native extensions"
@@ -53,7 +53,7 @@ module IronWorkerNG
53
53
 
54
54
  def code_for_gempath
55
55
  if @spec.extensions.length == 0 || IronWorkerNG::Feature::Ruby::MergeGem.merge_binary?
56
- '$:.unshift("#{root}/gems/' + @spec.full_name + '/lib")'
56
+ '$:.unshift("#{root}/__gems__/' + @spec.full_name + '/lib")'
57
57
  else
58
58
  '# native gem ' + @spec.full_name
59
59
  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.3.8
4
+ version: 0.3.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -156,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  segments:
158
158
  - 0
159
- hash: -81500049
159
+ hash: -543812495
160
160
  required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements: