nugrant 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +23 -23
- data/.travis.yml +15 -10
- data/CHANGELOG.md +347 -338
- data/CONTRIBUTORS.md +7 -5
- data/Gemfile +13 -13
- data/README.md +601 -601
- data/lib/nugrant/bag.rb +264 -264
- data/lib/nugrant/config.rb +201 -201
- data/lib/nugrant/helper/bag.rb +38 -38
- data/lib/nugrant/helper/env/exporter.rb +195 -195
- data/lib/nugrant/helper/env/namer.rb +47 -47
- data/lib/nugrant/helper/parameters.rb +12 -12
- data/lib/nugrant/helper/stack.rb +86 -86
- data/lib/nugrant/mixin/parameters.rb +178 -178
- data/lib/nugrant/parameters.rb +29 -29
- data/lib/nugrant/vagrant/errors.rb +35 -35
- data/lib/nugrant/vagrant/v2/action/auto_export.rb +45 -45
- data/lib/nugrant/vagrant/v2/action.rb +17 -17
- data/lib/nugrant/vagrant/v2/command/env.rb +118 -118
- data/lib/nugrant/vagrant/v2/command/parameters.rb +153 -153
- data/lib/nugrant/vagrant/v2/command/restricted_keys.rb +64 -64
- data/lib/nugrant/vagrant/v2/command/root.rb +95 -95
- data/lib/nugrant/vagrant/v2/config/user.rb +29 -29
- data/lib/nugrant/vagrant/v2/helper.rb +96 -96
- data/lib/nugrant/vagrant/v2/plugin.rb +34 -34
- data/lib/nugrant/version.rb +3 -3
- data/lib/nugrant.rb +31 -31
- data/locales/en.yml +24 -24
- data/locales/fr.yml +24 -24
- data/nugrant.gemspec +32 -32
- data/test/lib/nugrant/helper/env/test_exporter.rb +238 -238
- data/test/lib/nugrant/helper/test_bag.rb +16 -16
- data/test/lib/nugrant/helper/test_parameters.rb +17 -17
- data/test/lib/nugrant/helper/test_stack.rb +152 -152
- data/test/lib/nugrant/test_bag.rb +450 -450
- data/test/lib/nugrant/test_config.rb +201 -201
- data/test/lib/nugrant/test_parameters.rb +438 -438
- data/test/lib/test_helper.rb +3 -3
- data/test/resources/README.md +52 -52
- data/test/resources/json/params_current_1.json +6 -6
- data/test/resources/json/params_current_2.json +29 -29
- data/test/resources/json/params_user_nil_values.json +9 -9
- data/test/resources/vagrantfiles/v2.auto_export +13 -13
- data/test/resources/vagrantfiles/v2.bag_inside_array +15 -15
- data/test/resources/vagrantfiles/v2.defaults_mixed_string_symbols +18 -18
- data/test/resources/vagrantfiles/v2.defaults_null_values_in_vagrantuser +23 -23
- data/test/resources/vagrantfiles/v2.defaults_using_string +18 -18
- data/test/resources/vagrantfiles/v2.defaults_using_symbol +18 -18
- data/test/resources/vagrantfiles/v2.empty +2 -2
- data/test/resources/vagrantfiles/v2.fake +29 -29
- data/test/resources/vagrantfiles/v2.missing_parameter +3 -3
- data/test/resources/vagrantfiles/v2.real +22 -22
- data/test/resources/yaml/params_array.yml +5 -5
- data/test/resources/yaml/params_boolean.yml +1 -1
- data/test/resources/yaml/params_combinations.yml +72 -72
- data/test/resources/yaml/params_current_1.yml +4 -4
- data/test/resources/yaml/params_current_2.yml +23 -23
- data/test/resources/yaml/params_defaults_at_root.yml +1 -1
- data/test/resources/yaml/params_defaults_not_at_root.yml +2 -2
- data/test/resources/yaml/params_list.yml +2 -2
- data/test/resources/yaml/params_numeric_key.yml +3 -3
- data/test/resources/yaml/params_simple.yml +1 -1
- data/test/resources/yaml/params_system_1.yml +4 -4
- data/test/resources/yaml/params_system_2.yml +25 -25
- data/test/resources/yaml/params_unix_eol.yml +3 -3
- data/test/resources/yaml/params_user_1.yml +4 -4
- data/test/resources/yaml/params_user_2.yml +23 -23
- data/test/resources/yaml/params_user_nil_values.yml +5 -5
- data/test/resources/yaml/params_windows_eol.yml +3 -3
- metadata +12 -13
data/lib/nugrant/bag.rb
CHANGED
@@ -1,264 +1,264 @@
|
|
1
|
-
require 'nugrant/config'
|
2
|
-
|
3
|
-
module Nugrant
|
4
|
-
class Bag < Hash
|
5
|
-
|
6
|
-
##
|
7
|
-
# Create a new Bag object which holds key/value pairs.
|
8
|
-
# The Bag object inherits from the Hash object, the main
|
9
|
-
# differences with a normal Hash are indifferent access
|
10
|
-
# (symbol or string) and method access (via method call).
|
11
|
-
#
|
12
|
-
# Hash objects in the map are converted to Bag. This ensure
|
13
|
-
# proper nesting of functionality.
|
14
|
-
#
|
15
|
-
# =| Arguments
|
16
|
-
# * `elements`
|
17
|
-
# The initial elements the bag should be built with it.'
|
18
|
-
# Must be an object responding to `each` and accepting
|
19
|
-
# a block with two arguments: `key, value`. Defaults to
|
20
|
-
# the empty hash.
|
21
|
-
#
|
22
|
-
# * `config`
|
23
|
-
# A Nugrant::Config object or hash passed to Nugrant::Config
|
24
|
-
# constructor. Used for `key_error` handler.
|
25
|
-
#
|
26
|
-
def initialize(elements = {}, config = {})
|
27
|
-
super()
|
28
|
-
|
29
|
-
@__config = Config::convert(config)
|
30
|
-
|
31
|
-
(elements || {}).each do |key, value|
|
32
|
-
self[key] = value
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def config=(config)
|
37
|
-
@__config = Config::convert(config)
|
38
|
-
end
|
39
|
-
|
40
|
-
def method_missing(method, *args, &block)
|
41
|
-
self[method]
|
42
|
-
end
|
43
|
-
|
44
|
-
##
|
45
|
-
### Enumerable Overridden Methods (for string & symbol indifferent access)
|
46
|
-
##
|
47
|
-
|
48
|
-
def count(item)
|
49
|
-
super(__try_convert_item(item))
|
50
|
-
end
|
51
|
-
|
52
|
-
def find_index(item = nil, &block)
|
53
|
-
block_given? ? super(&block) : super(__try_convert_item(item))
|
54
|
-
end
|
55
|
-
|
56
|
-
##
|
57
|
-
### Hash Overridden Methods (for string & symbol indifferent access)
|
58
|
-
##
|
59
|
-
|
60
|
-
def [](input)
|
61
|
-
key = __convert_key(input)
|
62
|
-
return @__config.key_error.call(key) if not key?(key)
|
63
|
-
|
64
|
-
super(key)
|
65
|
-
end
|
66
|
-
|
67
|
-
def []=(input, value)
|
68
|
-
super(__convert_key(input), __convert_value(value))
|
69
|
-
end
|
70
|
-
|
71
|
-
def assoc(key)
|
72
|
-
super(__convert_key(key))
|
73
|
-
end
|
74
|
-
|
75
|
-
def delete(key)
|
76
|
-
super(__convert_key(key))
|
77
|
-
end
|
78
|
-
|
79
|
-
def fetch(key, default = nil)
|
80
|
-
super(__convert_key(key), default)
|
81
|
-
end
|
82
|
-
|
83
|
-
def has_key?(key)
|
84
|
-
super(__convert_key(key))
|
85
|
-
end
|
86
|
-
|
87
|
-
def include?(item)
|
88
|
-
super(__try_convert_item(item))
|
89
|
-
end
|
90
|
-
|
91
|
-
def key?(key)
|
92
|
-
super(__convert_key(key))
|
93
|
-
end
|
94
|
-
|
95
|
-
def member?(item)
|
96
|
-
super(__try_convert_item(item))
|
97
|
-
end
|
98
|
-
|
99
|
-
def dup()
|
100
|
-
self.class.new(self, @__config.dup())
|
101
|
-
end
|
102
|
-
|
103
|
-
def merge(other, options = {})
|
104
|
-
result = dup()
|
105
|
-
result.merge!(other)
|
106
|
-
end
|
107
|
-
|
108
|
-
def merge!(other, options = {})
|
109
|
-
other.each do |key, value|
|
110
|
-
current = __get(key)
|
111
|
-
case
|
112
|
-
when current == nil
|
113
|
-
self[key] = value
|
114
|
-
|
115
|
-
when current.kind_of?(Hash) && value.kind_of?(Hash)
|
116
|
-
current.merge!(value, options)
|
117
|
-
|
118
|
-
when current.kind_of?(Array) && value.kind_of?(Array)
|
119
|
-
strategy = options[:array_merge_strategy]
|
120
|
-
if not Nugrant::Config.supported_array_merge_strategy(strategy)
|
121
|
-
strategy = @__config.array_merge_strategy
|
122
|
-
end
|
123
|
-
|
124
|
-
self[key] = send("__#{strategy}_array_merge", current, value)
|
125
|
-
|
126
|
-
when value != nil
|
127
|
-
self[key] = value
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
self
|
132
|
-
end
|
133
|
-
|
134
|
-
def store(key, value)
|
135
|
-
self[key] = value
|
136
|
-
end
|
137
|
-
|
138
|
-
def to_hash(options = {})
|
139
|
-
return {} if empty?()
|
140
|
-
|
141
|
-
use_string_key = options[:use_string_key]
|
142
|
-
|
143
|
-
Hash[map do |key, value|
|
144
|
-
key = use_string_key ? key.to_s() : key
|
145
|
-
value = __convert_value_to_hash(value, options)
|
146
|
-
|
147
|
-
[key, value]
|
148
|
-
end]
|
149
|
-
end
|
150
|
-
|
151
|
-
def walk(path = [], &block)
|
152
|
-
each do |key, value|
|
153
|
-
nested_bag = value.kind_of?(Nugrant::Bag)
|
154
|
-
|
155
|
-
value.walk(path + [key], &block) if nested_bag
|
156
|
-
yield path + [key], key, value if not nested_bag
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
alias_method :to_ary, :to_a
|
161
|
-
|
162
|
-
##
|
163
|
-
### Private Methods
|
164
|
-
##
|
165
|
-
|
166
|
-
private
|
167
|
-
|
168
|
-
def __convert_key(key)
|
169
|
-
return key.to_s().to_sym() if !key.nil? && key.respond_to?(:to_s)
|
170
|
-
|
171
|
-
raise ArgumentError, "Key cannot be nil" if key.nil?
|
172
|
-
raise ArgumentError, "Key cannot be converted to symbol, current value [#{key}] (#{key.class.name})"
|
173
|
-
end
|
174
|
-
|
175
|
-
##
|
176
|
-
# This function change value convertible to Bag into actual Bag.
|
177
|
-
# This trick enable deeply using all Bag functionalities and also
|
178
|
-
# ensures at the same time a deeply preventive copy since a new
|
179
|
-
# instance is created for this nested structure.
|
180
|
-
#
|
181
|
-
# In addition, it also transforms array elements of type Hash into
|
182
|
-
# Bag instance also. This enable indifferent access inside arrays
|
183
|
-
# also.
|
184
|
-
#
|
185
|
-
# @param value The value to convert to bag if necessary
|
186
|
-
# @return The converted value
|
187
|
-
#
|
188
|
-
def __convert_value(value)
|
189
|
-
case
|
190
|
-
# Converts Hash to Bag instance
|
191
|
-
when value.kind_of?(Hash)
|
192
|
-
Bag.new(value, @__config)
|
193
|
-
|
194
|
-
# Converts Array elements to Bag instances if needed
|
195
|
-
when value.kind_of?(Array)
|
196
|
-
value.map(&self.method(:__convert_value))
|
197
|
-
|
198
|
-
# Keeps as-is other elements
|
199
|
-
else
|
200
|
-
value
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
##
|
205
|
-
# This function does the reversion of value conversion to Bag
|
206
|
-
# instances. It transforms Bag instances to Hash (using to_hash)
|
207
|
-
# and array Bag elements to Hash (using to_hash).
|
208
|
-
#
|
209
|
-
# The options parameters are pass to the to_hash function
|
210
|
-
# when invoked.
|
211
|
-
#
|
212
|
-
# @param value The value to convert to hash
|
213
|
-
# @param options The options passed to the to_hash function
|
214
|
-
# @return The converted value
|
215
|
-
#
|
216
|
-
def __convert_value_to_hash(value, options = {})
|
217
|
-
case
|
218
|
-
# Converts Bag instance to Hash
|
219
|
-
when value.kind_of?(Bag)
|
220
|
-
value.to_hash(options)
|
221
|
-
|
222
|
-
# Converts Array elements to Hash instances if needed
|
223
|
-
when value.kind_of?(Array)
|
224
|
-
value.map { |value| __convert_value_to_hash(value, options) }
|
225
|
-
|
226
|
-
# Keeps as-is other elements
|
227
|
-
else
|
228
|
-
value
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
def __get(key)
|
233
|
-
# Calls Hash method [__convert_key(key)], used internally to retrieve value without raising Undefined parameter
|
234
|
-
self.class.superclass.instance_method(:[]).bind(self).call(__convert_key(key))
|
235
|
-
end
|
236
|
-
|
237
|
-
##
|
238
|
-
# The concat order is the reversed compared to others
|
239
|
-
# because we assume that new values have precedence
|
240
|
-
# over current ones. Hence, the are prepended to
|
241
|
-
# current values. This is also logical for parameters
|
242
|
-
# because of the order in which bags are merged.
|
243
|
-
#
|
244
|
-
def __concat_array_merge(current_array, new_array)
|
245
|
-
new_array + current_array
|
246
|
-
end
|
247
|
-
|
248
|
-
def __extend_array_merge(current_array, new_array)
|
249
|
-
current_array | new_array
|
250
|
-
end
|
251
|
-
|
252
|
-
def __replace_array_merge(current_array, new_array)
|
253
|
-
new_array
|
254
|
-
end
|
255
|
-
|
256
|
-
def __try_convert_item(args)
|
257
|
-
return [__convert_key(args[0]), args[1]] if args.kind_of?(Array)
|
258
|
-
|
259
|
-
__convert_key(args)
|
260
|
-
rescue
|
261
|
-
args
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
1
|
+
require 'nugrant/config'
|
2
|
+
|
3
|
+
module Nugrant
|
4
|
+
class Bag < Hash
|
5
|
+
|
6
|
+
##
|
7
|
+
# Create a new Bag object which holds key/value pairs.
|
8
|
+
# The Bag object inherits from the Hash object, the main
|
9
|
+
# differences with a normal Hash are indifferent access
|
10
|
+
# (symbol or string) and method access (via method call).
|
11
|
+
#
|
12
|
+
# Hash objects in the map are converted to Bag. This ensure
|
13
|
+
# proper nesting of functionality.
|
14
|
+
#
|
15
|
+
# =| Arguments
|
16
|
+
# * `elements`
|
17
|
+
# The initial elements the bag should be built with it.'
|
18
|
+
# Must be an object responding to `each` and accepting
|
19
|
+
# a block with two arguments: `key, value`. Defaults to
|
20
|
+
# the empty hash.
|
21
|
+
#
|
22
|
+
# * `config`
|
23
|
+
# A Nugrant::Config object or hash passed to Nugrant::Config
|
24
|
+
# constructor. Used for `key_error` handler.
|
25
|
+
#
|
26
|
+
def initialize(elements = {}, config = {})
|
27
|
+
super()
|
28
|
+
|
29
|
+
@__config = Config::convert(config)
|
30
|
+
|
31
|
+
(elements || {}).each do |key, value|
|
32
|
+
self[key] = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def config=(config)
|
37
|
+
@__config = Config::convert(config)
|
38
|
+
end
|
39
|
+
|
40
|
+
def method_missing(method, *args, &block)
|
41
|
+
self[method]
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
### Enumerable Overridden Methods (for string & symbol indifferent access)
|
46
|
+
##
|
47
|
+
|
48
|
+
def count(item)
|
49
|
+
super(__try_convert_item(item))
|
50
|
+
end
|
51
|
+
|
52
|
+
def find_index(item = nil, &block)
|
53
|
+
block_given? ? super(&block) : super(__try_convert_item(item))
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
### Hash Overridden Methods (for string & symbol indifferent access)
|
58
|
+
##
|
59
|
+
|
60
|
+
def [](input)
|
61
|
+
key = __convert_key(input)
|
62
|
+
return @__config.key_error.call(key) if not key?(key)
|
63
|
+
|
64
|
+
super(key)
|
65
|
+
end
|
66
|
+
|
67
|
+
def []=(input, value)
|
68
|
+
super(__convert_key(input), __convert_value(value))
|
69
|
+
end
|
70
|
+
|
71
|
+
def assoc(key)
|
72
|
+
super(__convert_key(key))
|
73
|
+
end
|
74
|
+
|
75
|
+
def delete(key)
|
76
|
+
super(__convert_key(key))
|
77
|
+
end
|
78
|
+
|
79
|
+
def fetch(key, default = nil)
|
80
|
+
super(__convert_key(key), default)
|
81
|
+
end
|
82
|
+
|
83
|
+
def has_key?(key)
|
84
|
+
super(__convert_key(key))
|
85
|
+
end
|
86
|
+
|
87
|
+
def include?(item)
|
88
|
+
super(__try_convert_item(item))
|
89
|
+
end
|
90
|
+
|
91
|
+
def key?(key)
|
92
|
+
super(__convert_key(key))
|
93
|
+
end
|
94
|
+
|
95
|
+
def member?(item)
|
96
|
+
super(__try_convert_item(item))
|
97
|
+
end
|
98
|
+
|
99
|
+
def dup()
|
100
|
+
self.class.new(self, @__config.dup())
|
101
|
+
end
|
102
|
+
|
103
|
+
def merge(other, options = {})
|
104
|
+
result = dup()
|
105
|
+
result.merge!(other)
|
106
|
+
end
|
107
|
+
|
108
|
+
def merge!(other, options = {})
|
109
|
+
other.each do |key, value|
|
110
|
+
current = __get(key)
|
111
|
+
case
|
112
|
+
when current == nil
|
113
|
+
self[key] = value
|
114
|
+
|
115
|
+
when current.kind_of?(Hash) && value.kind_of?(Hash)
|
116
|
+
current.merge!(value, options)
|
117
|
+
|
118
|
+
when current.kind_of?(Array) && value.kind_of?(Array)
|
119
|
+
strategy = options[:array_merge_strategy]
|
120
|
+
if not Nugrant::Config.supported_array_merge_strategy(strategy)
|
121
|
+
strategy = @__config.array_merge_strategy
|
122
|
+
end
|
123
|
+
|
124
|
+
self[key] = send("__#{strategy}_array_merge", current, value)
|
125
|
+
|
126
|
+
when value != nil
|
127
|
+
self[key] = value
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
self
|
132
|
+
end
|
133
|
+
|
134
|
+
def store(key, value)
|
135
|
+
self[key] = value
|
136
|
+
end
|
137
|
+
|
138
|
+
def to_hash(options = {})
|
139
|
+
return {} if empty?()
|
140
|
+
|
141
|
+
use_string_key = options[:use_string_key]
|
142
|
+
|
143
|
+
Hash[map do |key, value|
|
144
|
+
key = use_string_key ? key.to_s() : key
|
145
|
+
value = __convert_value_to_hash(value, options)
|
146
|
+
|
147
|
+
[key, value]
|
148
|
+
end]
|
149
|
+
end
|
150
|
+
|
151
|
+
def walk(path = [], &block)
|
152
|
+
each do |key, value|
|
153
|
+
nested_bag = value.kind_of?(Nugrant::Bag)
|
154
|
+
|
155
|
+
value.walk(path + [key], &block) if nested_bag
|
156
|
+
yield path + [key], key, value if not nested_bag
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
alias_method :to_ary, :to_a
|
161
|
+
|
162
|
+
##
|
163
|
+
### Private Methods
|
164
|
+
##
|
165
|
+
|
166
|
+
private
|
167
|
+
|
168
|
+
def __convert_key(key)
|
169
|
+
return key.to_s().to_sym() if !key.nil? && key.respond_to?(:to_s)
|
170
|
+
|
171
|
+
raise ArgumentError, "Key cannot be nil" if key.nil?
|
172
|
+
raise ArgumentError, "Key cannot be converted to symbol, current value [#{key}] (#{key.class.name})"
|
173
|
+
end
|
174
|
+
|
175
|
+
##
|
176
|
+
# This function change value convertible to Bag into actual Bag.
|
177
|
+
# This trick enable deeply using all Bag functionalities and also
|
178
|
+
# ensures at the same time a deeply preventive copy since a new
|
179
|
+
# instance is created for this nested structure.
|
180
|
+
#
|
181
|
+
# In addition, it also transforms array elements of type Hash into
|
182
|
+
# Bag instance also. This enable indifferent access inside arrays
|
183
|
+
# also.
|
184
|
+
#
|
185
|
+
# @param value The value to convert to bag if necessary
|
186
|
+
# @return The converted value
|
187
|
+
#
|
188
|
+
def __convert_value(value)
|
189
|
+
case
|
190
|
+
# Converts Hash to Bag instance
|
191
|
+
when value.kind_of?(Hash)
|
192
|
+
Bag.new(value, @__config)
|
193
|
+
|
194
|
+
# Converts Array elements to Bag instances if needed
|
195
|
+
when value.kind_of?(Array)
|
196
|
+
value.map(&self.method(:__convert_value))
|
197
|
+
|
198
|
+
# Keeps as-is other elements
|
199
|
+
else
|
200
|
+
value
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
##
|
205
|
+
# This function does the reversion of value conversion to Bag
|
206
|
+
# instances. It transforms Bag instances to Hash (using to_hash)
|
207
|
+
# and array Bag elements to Hash (using to_hash).
|
208
|
+
#
|
209
|
+
# The options parameters are pass to the to_hash function
|
210
|
+
# when invoked.
|
211
|
+
#
|
212
|
+
# @param value The value to convert to hash
|
213
|
+
# @param options The options passed to the to_hash function
|
214
|
+
# @return The converted value
|
215
|
+
#
|
216
|
+
def __convert_value_to_hash(value, options = {})
|
217
|
+
case
|
218
|
+
# Converts Bag instance to Hash
|
219
|
+
when value.kind_of?(Bag)
|
220
|
+
value.to_hash(options)
|
221
|
+
|
222
|
+
# Converts Array elements to Hash instances if needed
|
223
|
+
when value.kind_of?(Array)
|
224
|
+
value.map { |value| __convert_value_to_hash(value, options) }
|
225
|
+
|
226
|
+
# Keeps as-is other elements
|
227
|
+
else
|
228
|
+
value
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def __get(key)
|
233
|
+
# Calls Hash method [__convert_key(key)], used internally to retrieve value without raising Undefined parameter
|
234
|
+
self.class.superclass.instance_method(:[]).bind(self).call(__convert_key(key))
|
235
|
+
end
|
236
|
+
|
237
|
+
##
|
238
|
+
# The concat order is the reversed compared to others
|
239
|
+
# because we assume that new values have precedence
|
240
|
+
# over current ones. Hence, the are prepended to
|
241
|
+
# current values. This is also logical for parameters
|
242
|
+
# because of the order in which bags are merged.
|
243
|
+
#
|
244
|
+
def __concat_array_merge(current_array, new_array)
|
245
|
+
new_array + current_array
|
246
|
+
end
|
247
|
+
|
248
|
+
def __extend_array_merge(current_array, new_array)
|
249
|
+
current_array | new_array
|
250
|
+
end
|
251
|
+
|
252
|
+
def __replace_array_merge(current_array, new_array)
|
253
|
+
new_array
|
254
|
+
end
|
255
|
+
|
256
|
+
def __try_convert_item(args)
|
257
|
+
return [__convert_key(args[0]), args[1]] if args.kind_of?(Array)
|
258
|
+
|
259
|
+
__convert_key(args)
|
260
|
+
rescue
|
261
|
+
args
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|