henry-container 0.1.80 → 0.1.81

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0b12ea5407e6f90af3f2632fbb297fcd243919b
4
- data.tar.gz: 8fe422d12fe0ada432efb0d556a27664e8fa42b1
3
+ metadata.gz: 1f0a4f0c542c76c485ed04e999512efcf472ea73
4
+ data.tar.gz: 24b631becfa803eef78d2e5a346635e64547272c
5
5
  SHA512:
6
- metadata.gz: 350db158319dd098cbfb2c09b66c95d0f3b23406e31d6265a26eb5865ace7137bc9217f042b166eac5f9557456e6ec95f57f26b6ca85a1e74afdd495254ef0aa
7
- data.tar.gz: 5c66d665fc51bd628e9489b933b29466f64eb2c7eb31b2880a8305bcc2ef8afd69aacc62bbc9ea881e7b5b4b3dca274fbc7d6a43e147aa62b016813426ef907b
6
+ metadata.gz: d6e2909492c309de7142c0a7503a50a36b4acef2a29ed2856ee125089d433181463f89615acb630647001f6e955eea19661151e65817dcfe1ec68dc6eea664cc
7
+ data.tar.gz: 1aa40c72460521b2c60b1a50fb4ace0352e9b8fb5f111b27787cb0bbe0c05369e09056777a60dbb740e7b6e43b5e9cacd600eef67ab8146807a661e2f794f960
@@ -24,6 +24,7 @@ BANNER
24
24
  opt :hints, "Custom name for the task hints (tasks to be executed) file.", :default => 'hints.henry'
25
25
  opt :"hints-dir", "Custom dir path where the task hints (tasks to be executed) will be read from.", :default => '.'
26
26
  opt :"output-dir", "Custom dir path where the task output files will be stored.", :default => '.'
27
+ opt :"reload-params", "Creates a dynamic in file based on the defined in-rules and the in-files"
27
28
  end
28
29
 
29
30
  Henry::Container.new(opts).execute
@@ -3,7 +3,7 @@ module Henry
3
3
  class Container
4
4
 
5
5
  # Current Gem version
6
- VERSION = ENV['gem_version'] || '0.1.80'
6
+ VERSION = ENV['gem_version'] || '0.1.81'
7
7
 
8
8
  end
9
9
 
@@ -203,6 +203,14 @@ TASK
203
203
  "#{@opts[:"in-dir"]}/#{@opts[:hints]}"
204
204
  end
205
205
 
206
+ # Return true whenever the execution requires the regeneration of the
207
+ # in files.
208
+ #
209
+ # @return [TrueClas|FalseClass] whether the exuction requires to regenerate the in files.
210
+ def reload_params?
211
+ @opts[:"reload-params"]
212
+ end
213
+
206
214
  # Executes required validations before execution.
207
215
  def before_execution
208
216
  unless File.exists?('henry-context.yml')
@@ -221,6 +229,8 @@ TASK
221
229
  #
222
230
  # @return [<{String => String}>] collection of execution params.
223
231
  def load_params
232
+ self.reload_params!
233
+
224
234
  return [{}] unless File.exists?(self.input_file_path)
225
235
 
226
236
  params = JSON.parse(File.read(self.input_file_path))
@@ -230,6 +240,55 @@ TASK
230
240
  params
231
241
  end
232
242
 
243
+ # Creates a dynamic in.henry based on the in-rules and
244
+ # in-files.
245
+ def reload_params!
246
+ return false unless self.reload_params?
247
+
248
+ in_files_params = self.in_files_params
249
+
250
+ in_rules = self.in_rules
251
+
252
+ params = in_rules.collect do |rule|
253
+ rule.inject({}) do |param, in_file|
254
+ in_files_params[in_file].each do |key, value|
255
+ param[key] ||= {}
256
+
257
+ param[key].merge!(value)
258
+ end
259
+
260
+ param
261
+ end
262
+ end
263
+
264
+ File.open(self.input_file_path, 'w') do |input_file|
265
+ JSON.dump(params, input_file)
266
+ end
267
+ end
268
+
269
+ # Loads and returns all the in-files as a hash
270
+ #
271
+ # @return [Hash] the in-files with its values.
272
+ def in_files_params
273
+ return @in_files_params if @in_files_params
274
+
275
+ @in_file_params = {}
276
+
277
+ Dir.new('./in-files').each do |file_name|
278
+ next if file_name.match(/^\.+$/)
279
+ @in_file_params[file_name] = JSON.parse(File.read("./in-files/#{file_name}"))
280
+ end
281
+
282
+ return @in_file_params
283
+ end
284
+
285
+ # Loads and returns the in-rules as hash.
286
+ #
287
+ # @return [Hash] the in-file values.
288
+ def in_rules
289
+ @in_rules ||= JSON.parse(File.read('in-rules.henry'))
290
+ end
291
+
233
292
  # Returns the default params.
234
293
  # @note Custom task_params will overwrite the defaults.
235
294
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: henry-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.80
4
+ version: 0.1.81
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Decurnex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-06 00:00:00.000000000 Z
11
+ date: 2014-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake