lorj 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/example/students_1/students.rb +5 -6
  3. data/example/students_2/students.rb +4 -5
  4. data/example/students_3/students.rb +4 -5
  5. data/example/students_4/students.rb +4 -5
  6. data/example/students_5/students.rb +5 -5
  7. data/lib/core/core.rb +6 -1
  8. data/lib/core/core_controller.rb +1 -9
  9. data/lib/core/core_internal.rb +2 -1
  10. data/lib/core/core_model.rb +2 -10
  11. data/lib/core/core_object_data.rb +18 -0
  12. data/lib/core/core_object_params.rb +43 -4
  13. data/lib/core/core_process.rb +1 -9
  14. data/lib/core/core_process_setup.rb +32 -6
  15. data/lib/core/core_setup_ask.rb +41 -33
  16. data/lib/core/core_setup_encrypt.rb +29 -6
  17. data/lib/core/core_setup_init.rb +2 -2
  18. data/lib/core/definition.rb +33 -10
  19. data/lib/core/definition_internal.rb +10 -14
  20. data/lib/core/lorj_basedefinition.rb +16 -24
  21. data/lib/core/lorj_baseprocess.rb +113 -44
  22. data/lib/core/lorj_data.rb +2 -9
  23. data/lib/core/lorj_keypath.rb +5 -2
  24. data/lib/core_process/cloud/process/common.rb +4 -7
  25. data/lib/core_process/cloud/process/connection.rb +44 -45
  26. data/lib/core_process/cloud/process/external_network.rb +24 -28
  27. data/lib/core_process/cloud/process/flavor.rb +31 -34
  28. data/lib/core_process/cloud/process/images.rb +12 -15
  29. data/lib/core_process/cloud/process/internet_network.rb +13 -14
  30. data/lib/core_process/cloud/process/internet_server.rb +9 -10
  31. data/lib/core_process/cloud/process/keypairs.rb +34 -27
  32. data/lib/core_process/cloud/process/network.rb +21 -23
  33. data/lib/core_process/cloud/process/public_ip.rb +17 -18
  34. data/lib/core_process/cloud/process/router.rb +86 -92
  35. data/lib/core_process/cloud/process/rules.rb +30 -31
  36. data/lib/core_process/cloud/process/security_groups.rb +21 -22
  37. data/lib/core_process/cloud/process/server.rb +30 -31
  38. data/lib/core_process/cloud/process/server_log.rb +13 -14
  39. data/lib/core_process/cloud/process/subnetwork.rb +25 -40
  40. data/lib/logging.rb +4 -17
  41. data/lib/lorj/version.rb +1 -1
  42. data/lib/lorj.rb +2 -1
  43. data/lib/lorj_account.rb +137 -90
  44. data/lib/lorj_config.rb +13 -19
  45. data/lib/lorj_defaults.rb +46 -292
  46. data/lib/lorj_meta.rb +729 -0
  47. data/lib/prc.rb +119 -30
  48. data/lib/prc_base_config.rb +53 -47
  49. data/lib/prc_core_config.rb +837 -565
  50. data/lib/prc_section_config.rb +44 -16
  51. data/lib/providers/hpcloud/hpcloud.rb +1 -1
  52. data/lib/providers/openstack/openstack.rb +278 -21
  53. data/lib/providers/openstack/openstack_create.rb +205 -0
  54. data/lib/providers/openstack/openstack_delete.rb +28 -0
  55. data/lib/providers/openstack/openstack_get.rb +39 -0
  56. data/lib/providers/openstack/openstack_process.rb +26 -0
  57. data/lib/providers/openstack/openstack_query.rb +96 -0
  58. data/lib/providers/openstack/openstack_update.rb +35 -0
  59. data/lib/rh.rb +91 -6
  60. data/lorj-spec/defaults.yaml +18 -12
  61. data/lorj.gemspec +1 -0
  62. data/spec/01_hash_rh_spec.rb +41 -2
  63. data/spec/02_prc_base_config_spec.rb +1 -1
  64. data/spec/03_prc_section_config_spec.rb +1 -1
  65. data/spec/04_prc_core_config_spec.rb +148 -4
  66. data/spec/09_prc_spec.rb +104 -0
  67. data/spec/{00_lorj_log_spec.rb → 10_lorj_log_spec.rb} +23 -2
  68. data/spec/11_lorj_config_spec.rb +9 -27
  69. data/spec/12_lorj_account_spec.rb +36 -20
  70. data/spec/20_lorj_meta_spec.rb +271 -0
  71. data/spec/21_lorj_defaults_spec.rb +85 -0
  72. metadata +31 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed752c1a4519969b83c7f240f0ecbd36e1b5c691
4
- data.tar.gz: 1e7dd04ad2bedb015039056a6c6cc3e373c37c22
3
+ metadata.gz: 63d7eabf0a0bfe1c20a49ea78ad77a37b6b5e521
4
+ data.tar.gz: 5170b2123e123a05028cd52cad7af4d1288acc09
5
5
  SHA512:
6
- metadata.gz: c6cd78cba3f041dd7982afc192776075a9e3548195f0d8984dd194645b248986e21ccabbbee5015eb166812a89251ae553514e3247bd9780c1acd9f41c25042b
7
- data.tar.gz: 6f42a29853960ae4778c3751226b56775ede547911a3bd691b14cf6297df4049c358ea66c1c3528c040c20e4c76a877540bc99f9d4294ce20d766c6bd76f5dae
6
+ metadata.gz: 88a9a2866f706cf5183caf65cce95bbeffec6073fc47b2457c233a28bc73d4fe175aade0ae4410e42eb050ac52f5ea1da782c2e1a1404f0a673c575acb2e959e
7
+ data.tar.gz: 96ec48620a59cc39ea1307fcea13e04eeb2a703d1466338cf18b74ecfac225caabe85e0ef2c1a61b4359fa1f0621bf46b2589c260ec3d2f54da277391806ea7c
@@ -15,14 +15,13 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- if ENV['BYEBUG']
19
- require 'byebug'
20
- lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
21
- $LOAD_PATH << lib_path
22
- end
23
-
24
18
  app_path = File.dirname(__FILE__)
25
19
 
20
+ lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
21
+ $LOAD_PATH << lib_path
22
+
23
+ require 'byebug' if ENV['BYEBUG']
24
+
26
25
  require 'lorj'
27
26
 
28
27
  # If you want to see what is happening in the framework, uncomment debug
@@ -17,11 +17,10 @@
17
17
 
18
18
  app_path = File.dirname(__FILE__)
19
19
 
20
- if ENV['BYEBUG']
21
- require 'byebug'
22
- lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
23
- $LOAD_PATH << lib_path
24
- end
20
+ lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
21
+ $LOAD_PATH << lib_path
22
+
23
+ require 'byebug' if ENV['BYEBUG']
25
24
 
26
25
  require 'lorj'
27
26
 
@@ -17,11 +17,10 @@
17
17
 
18
18
  app_path = File.dirname(__FILE__)
19
19
 
20
- if ENV['BYEBUG']
21
- require 'byebug'
22
- lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
23
- $LOAD_PATH << lib_path
24
- end
20
+ lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
21
+ $LOAD_PATH << lib_path
22
+
23
+ require 'byebug' if ENV['BYEBUG']
25
24
 
26
25
  require 'lorj'
27
26
 
@@ -17,11 +17,10 @@
17
17
 
18
18
  app_path = File.dirname(__FILE__)
19
19
 
20
- if ENV['BYEBUG']
21
- require 'byebug'
22
- lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
23
- $LOAD_PATH << lib_path
24
- end
20
+ lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
21
+ $LOAD_PATH << lib_path
22
+
23
+ require 'byebug' if ENV['BYEBUG']
25
24
 
26
25
  require 'lorj'
27
26
 
@@ -17,11 +17,11 @@
17
17
 
18
18
  app_path = File.dirname(__FILE__)
19
19
 
20
- if ENV['BYEBUG']
21
- require 'byebug'
22
- lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
23
- $LOAD_PATH << lib_path
24
- end
20
+ lib_path = File.expand_path(File.join(app_path, '..', '..', 'lib'))
21
+ $LOAD_PATH << lib_path
22
+
23
+ require 'byebug' if ENV['BYEBUG']
24
+
25
25
  require 'lorj'
26
26
  require 'ansi'
27
27
 
data/lib/core/core.rb CHANGED
@@ -319,6 +319,8 @@ module Lorj
319
319
 
320
320
  init_core_config(the_config)
321
321
 
322
+ PrcLib.model.config = @config
323
+
322
324
  model = initialize_model
323
325
 
324
326
  # Load Application processes
@@ -344,7 +346,10 @@ module Lorj
344
346
 
345
347
  process_list = [:cloud_process]
346
348
 
347
- controller_mod = config_account.get(:provider_name)
349
+ controller_mod = config_account.get(:provider)
350
+
351
+ controller_mod = config_account.get(:provider_name) if controller_mod.nil?
352
+
348
353
  PrcLib.runtime_fail 'Provider_name not set. Unable to create'\
349
354
  ' instance CloudCore.' if controller_mod.nil?
350
355
 
@@ -12,15 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # Module Lorj which contains several classes.
16
- #
17
- # Those classes describes :
18
- # - processes (BaseProcess) : How to create/delete/edit/query object.
19
- # - controler (BaseControler) : If a provider is defined, define how will do
20
- # object creation/etc...
21
- # - definition(BaseDefinition): Functions to declare objects, query/data mapping
22
- # and setup
23
- # this task to make it to work.
15
+ # - controler functions: controller functions called by Lorj::BaseProcess.
24
16
  module Lorj
25
17
  # Adding controller core functions.
26
18
  class BaseDefinition
@@ -16,7 +16,8 @@
16
16
 
17
17
  # rubocop: disable Metrics/AbcSize
18
18
 
19
- # Module Lorj which contains several classes.
19
+ # - Lorj::Core : Lorj exposed interface.
20
+ # - Initialization functions
20
21
  module Lorj
21
22
  # Define private initialize functions for processes
22
23
  class Core
@@ -18,20 +18,12 @@
18
18
 
19
19
  # TODO: Move most declaration functions to Model class for simplification.
20
20
 
21
- # Module Lorj which contains several classes.
22
- #
23
- # Those classes describes :
24
- # - processes (BaseProcess) : How to create/delete/edit/query object.
25
- # - controler (BaseControler) : If a provider is defined, define how will do
26
- # object creation/etc...
27
- # - definition(BaseDefinition): Functions to declare objects, query/data mapping
28
- # and setup
29
- # this task to make it to work.
21
+ # - Lorj::Model : Model class reference.
30
22
  module Lorj
31
23
  # Model Object
32
24
  class Model
33
25
  attr_accessor :meta_obj, :meta_data, :meta_predefined_values
34
- attr_accessor :query_auto_map
26
+ attr_accessor :query_auto_map, :config
35
27
 
36
28
  # Model initialisation
37
29
  def initialize
@@ -78,6 +78,24 @@ module Lorj
78
78
  @params = {}
79
79
  @params[:hdata] = {} unless internal
80
80
  @internal = internal
81
+ @refresh = nil
82
+ end
83
+
84
+ # Refresh setting
85
+ #
86
+ # This function is used to provide capability to an Object to be refreshed
87
+ # from Lorj Cache.
88
+ #
89
+ def refresh_set(base_def_instance, object_type, sEventType, as_controller)
90
+ @refresh = { :bd_obj => base_def_instance, :object_type => object_type,
91
+ :event_type => sEventType, :controller => as_controller
92
+ }
93
+ end
94
+
95
+ def refresh
96
+ return self if @refresh.nil?
97
+ # Do the refresh itself.
98
+ @refresh[:bd_obj].update_params(self, @refresh)
81
99
  end
82
100
 
83
101
  # Get function
@@ -15,9 +15,29 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
+ # Lorj implements Lorj::BaseDefinition core internal functions
18
19
  module Lorj
19
20
  # Class Definition internal function.
20
21
  class BaseDefinition
22
+ # function to update an existing ObjectData used as parameters to
23
+ # process or controller
24
+ #
25
+ # *parameters*:
26
+ # - data_to_refresh: ObjectData to refresh
27
+ # - refresh_par : Hash providing the parameter context used to refresh it
28
+ #
29
+ # *return*:
30
+ # - data refreshed.
31
+ #
32
+ def update_params(data_to_refresh, refresh_par) # :nodoc:
33
+ object_type = refresh_par[:object_type]
34
+ event_type = refresh_par[:event_type]
35
+ as_controller = refresh_par[:controller]
36
+
37
+ _get_object_params(object_type, event_type, __callee__, as_controller,
38
+ data_to_refresh)
39
+ end
40
+
21
41
  private
22
42
 
23
43
  # internal runtime function for process call
@@ -67,6 +87,8 @@ module Lorj
67
87
  # - +new_params+ : Parameters ObjectData
68
88
  # - +param_obj+ : parameter object
69
89
  # - +param_options+ : parameter options
90
+ # - :type : hdata requires parameters to be :data.
91
+ # - :decrypt: true if the data needs to be decrypted automatically.
70
92
  # - +value+ : value to add in hdata Hash.
71
93
  #
72
94
  # *return*:
@@ -89,6 +111,10 @@ module Lorj
89
111
  value = value_mapping[value]
90
112
  end
91
113
 
114
+ if param_options[:decrypt].is_a?(TrueClass)
115
+ value = _get_encrypted_value(value, _get_encrypt_key)
116
+ end
117
+
92
118
  return unless param_options[:mapping]
93
119
 
94
120
  # NOTE: if mapping is set, the definition subtree
@@ -111,7 +137,7 @@ module Lorj
111
137
  #
112
138
  #
113
139
  # *return*:
114
- # - value : return the parameter value.
140
+ # - value : return the parameter value or nil if is :CloudObject type.
115
141
  #
116
142
  # *raise*:
117
143
  #
@@ -126,7 +152,7 @@ module Lorj
126
152
  @object_data.type?(param_name) != :DataObject
127
153
  PrcLib.runtime_fail "Object '%s/%s' is not defined. '%s' "\
128
154
  'requirement failed.',
129
- self.class, param_name, fname
155
+ self.class, param_name, __callee__
130
156
  end
131
157
  if @object_data.exist?(param_name)
132
158
  new_params.add(@object_data[param_name, :ObjectData])
@@ -179,6 +205,10 @@ module Lorj
179
205
  _get_object_params(object_type, sEventType, fname, true)
180
206
  end
181
207
 
208
+ # TODO: Fix the Complexity
209
+ # rubocop: disable Metrics/CyclomaticComplexity
210
+ # rubocop: disable Metrics/PerceivedComplexity
211
+
182
212
  # internal runtime function for process call
183
213
  # Build a process/controller parameters object (ObjectData)
184
214
  #
@@ -197,7 +227,8 @@ module Lorj
197
227
  # *raise*:
198
228
  # - runtime error if required data is not set. (empty or nil)
199
229
  #
200
- def _get_object_params(object_type, sEventType, fname, as_controller)
230
+ def _get_object_params(object_type, sEventType, fname, as_controller,
231
+ new_params = nil)
201
232
  # Building handler parameters
202
233
  # hdata is built for controller. ie, ObjectData is NOT internal.
203
234
 
@@ -206,7 +237,9 @@ module Lorj
206
237
  PrcLib.runtime_fail "%s:'%s' Object data needs not set. Forgot "\
207
238
  'obj_needs?', fname, object_type if obj_params.nil?
208
239
 
209
- new_params = _obj_param_init(object_type, sEventType, as_controller)
240
+ if new_params.nil?
241
+ new_params = _obj_param_init(object_type, sEventType, as_controller)
242
+ end
210
243
 
211
244
  obj_params.each do |param_path, param_options|
212
245
  if param_options.key?(:for)
@@ -221,9 +254,15 @@ module Lorj
221
254
  _build_hdata(object_type, new_params, param_obj, param_options, value)
222
255
  end
223
256
  end
257
+ unless fname == :update_params
258
+ new_params.refresh_set(self, object_type, sEventType, as_controller)
259
+ end
224
260
  new_params
225
261
  end
226
262
 
263
+ # rubocop: enable Metrics/CyclomaticComplexity
264
+ # rubocop: enable Metrics/PerceivedComplexity
265
+
227
266
  # Internal runtime function for process call
228
267
  #
229
268
  # initialize Object parameters object (ObjectData)
@@ -12,15 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # Module Lorj which contains several classes.
16
- #
17
- # Those classes describes :
18
- # - processes (BaseProcess) : How to create/delete/edit/query object.
19
- # - controler (BaseControler) : If a provider is defined, define how will do
20
- # object creation/etc...
21
- # - definition(BaseDefinition): Functions to declare objects, query/data mapping
22
- # and setup
23
- # this task to make it to work.
15
+ # - process functions: Process functions called by Core or BaseProcess.
24
16
  module Lorj
25
17
  # Adding process core functions.
26
18
  class BaseDefinition
@@ -124,7 +124,7 @@ module Lorj
124
124
 
125
125
  setup_steps = _setup_load
126
126
 
127
- @config.ac_load(sAccountName) if sAccountName
127
+ return nil unless _process_setup_init(sAccountName)
128
128
 
129
129
  Lorj.debug(2, "Setup is identifying account data to ask for '%s'",
130
130
  sObjectType)
@@ -137,10 +137,36 @@ module Lorj
137
137
  Lorj.debug(2, "Setup will ask for :\n %s", setup_steps.to_yaml)
138
138
 
139
139
  _setup_ask(setup_steps)
140
- PrcLib.info("Configuring account : '#{config[:account_name]}',"\
140
+
141
+ PrcLib.info("Configuring account : '#{sAccountName}',"\
141
142
  " provider '#{config[:provider_name]}'")
142
143
  end
143
144
 
145
+ private
146
+
147
+ # Internal function to initialize the account.
148
+ #
149
+ # return true if initialized, false otherwise.
150
+ def _process_setup_init(sAccountName)
151
+ return false unless sAccountName
152
+
153
+ if @config.ac_load(sAccountName)
154
+ if @config[:provider] != @config[:provider_name]
155
+ s_ask = format("Account '%s' was configured with a different "\
156
+ "provider '%s'.\nAre you sure to re-initialize this "\
157
+ "account with '%s' provider instead? "\
158
+ 'All data will be lost',
159
+ sAccountName, @config[:provider],
160
+ @config[:provider_name])
161
+ PrcLib.fatal(0, 'Exited by user request.') unless agree(s_ask)
162
+ @config.ac_new(sAccountName, config[:provider_name])
163
+ end
164
+ else
165
+ @config.ac_new(sAccountName, config[:provider_name])
166
+ end
167
+ true
168
+ end
169
+
144
170
  # Internal function to insert the data after several data to ask.
145
171
  #
146
172
  # * *Args* :
@@ -191,7 +217,7 @@ module Lorj
191
217
  # * *Raises* :
192
218
  #
193
219
  def _setup_data_after(data_to_check)
194
- meta = _get_meta_data_auto(data_to_check)
220
+ meta = _get_meta_data(data_to_check)
195
221
  return [] unless meta.rh_exist?(:after)
196
222
 
197
223
  datas_after = meta[:after]
@@ -240,7 +266,7 @@ module Lorj
240
266
  return false
241
267
  end
242
268
 
243
- meta = _get_meta_data_auto(attr_name)
269
+ meta = _get_meta_data(attr_name)
244
270
  return false unless meta.is_a?(Hash)
245
271
 
246
272
  ask_step = 0
@@ -273,7 +299,7 @@ module Lorj
273
299
  # parameters:
274
300
  # - +order_array+ : array of levels of attributes ordered.
275
301
  # - +attr_name+ : attribute name
276
- # - +depends_on+ : Dependendy Array.
302
+ # - +depends_on+ : Dependency Array.
277
303
  #
278
304
  # return:
279
305
  # - level_index to use.
@@ -284,7 +310,7 @@ module Lorj
284
310
  attr_name) unless depends_on.nil?
285
311
  0
286
312
  else
287
- _setup_find_dep_level(order_array, meta[:depends_on])
313
+ _setup_find_dep_level(order_array, depends_on)
288
314
  end
289
315
  end
290
316
 
@@ -34,12 +34,13 @@ module Lorj
34
34
  # new value
35
35
  #
36
36
  # * *Args* :
37
- # - +desc+ : Data description
38
- # - +data+ : Data to ask.
39
- # - +options+: list and validation options
37
+ # - +desc+ : Data description
38
+ # - +data+ : Data to ask.
39
+ # - +options+: list and validation options
40
+ # - +:post_step_function+ : Call a post process function.
40
41
  #
41
42
  # * *Returns*:
42
- # - value : value entered by the end user.
43
+ # - nothing
43
44
  #
44
45
  # * *Raises* :
45
46
  #
@@ -52,22 +53,34 @@ module Lorj
52
53
  desc, options)
53
54
  end
54
55
 
55
- @config.set(data, value)
56
-
56
+ # @config.set(data, value) ??? Why do we need that???
57
57
  section = _get_account_section(data)
58
- @config.set(data, value, :name =>
59
- 'account', :section => section) unless section.nil?
58
+ # We set the value only if there is a value entered by the user.
59
+ unless section.nil? || value.nil?
60
+ @config.set(data, value, :name => 'account', :section => section)
61
+ end
60
62
 
61
- break if options[:post_step_function].nil?
63
+ result = _setup_ask_post_process(options[:post_step_function])
64
+ break unless result.is_a?(FalseClass)
65
+ end
66
+ end
62
67
 
63
- proc = options[:post_step_function]
64
- result = @process.method(proc).call
68
+ # Execute the post process on data entered by the user
69
+ #
70
+ # * *returns*
71
+ # - false if the process ask the user to re-enter a value.
72
+ # - true otherwise.
73
+ def _setup_ask_post_process(proc)
74
+ return true if proc.nil?
65
75
 
66
- PrcLib.debug("Warning: '%s' did not return any boolean"\
67
- ' value. Ignored', proc) unless result.boolean?
76
+ result = @process.method(proc).call
68
77
 
69
- break unless result.is_a?(FalseClass)
78
+ unless result.boolean?
79
+ PrcLib.debug("Warning: '%s' did not return any boolean"\
80
+ ' value. Ignored', proc)
81
+ result = true
70
82
  end
83
+ result
71
84
  end
72
85
 
73
86
  # Internal setup function to ask to the end user from a list.
@@ -173,12 +186,14 @@ module Lorj
173
186
  # Internal setup function to ask to the end user.
174
187
  #
175
188
  # * *Args* :
176
- # - +desc+ : Data description
177
- # - +data+ : Data to ask.
178
- # - +options+: list and validation options
189
+ # - +desc+ : Data description
190
+ # - +data+ : Data to ask.
191
+ # - +options+: list and validation options
192
+ # - :ask_function: Replace the _ask default call by a process function
193
+ # This function should return a string or nil, if no value.
179
194
  #
180
195
  # * *Returns*:
181
- # - value : value entered by the end user.
196
+ # - value : value entered by the end user or nil if no value.
182
197
  #
183
198
  # * *Raises* :
184
199
  #
@@ -196,24 +211,11 @@ module Lorj
196
211
  proc_ask = options[:ask_function]
197
212
 
198
213
  if proc_ask.nil?
199
- # proc_method = _ask(desc, default, valid_regex,
200
- # is_encrypted, is_required)
201
- value = _ask(desc, default, valid_regex,
202
- is_encrypted, is_required)
214
+ value = _ask(desc, default, valid_regex, is_encrypted, is_required)
203
215
  else
204
- # proc_method = @process.method(proc_ask)
205
216
  value = @process.method(proc_ask)
206
217
  end
207
-
208
- # loop do
209
- # value = proc_method.call(desc, default, valid_regex,
210
- # is_encrypted, is_required)
211
- # break if validate_proc.nil?
212
-
213
- # validate_method = @process.method(validate_proc)
214
- # break if validate_method.call(value)
215
- # end
216
- value
218
+ _nil_if_no_value(value)
217
219
  end
218
220
 
219
221
  # internal runtime function for process call
@@ -247,5 +249,11 @@ module Lorj
247
249
  end
248
250
  value.to_s
249
251
  end
252
+
253
+ # Internal function to return nil if value is empty.
254
+ def _nil_if_no_value(value)
255
+ return nil if value.nil? || value == ''
256
+ value
257
+ end
250
258
  end
251
259
  end
@@ -83,12 +83,7 @@ module Lorj
83
83
  return '' if enc_value.nil?
84
84
  value_hidden = ''
85
85
  begin
86
- value_hidden = '*' * Encryptor.decrypt(
87
- :value => Base64.strict_decode64(enc_value),
88
- :key => entr[:key],
89
- :iv => Base64.strict_decode64(entr[:iv]),
90
- :salt => entr[:salt]
91
- ).length
86
+ value_hidden = '*' * _get_encrypted_value(enc_value, entr).length
92
87
  rescue
93
88
  PrcLib.error('Unable to decrypt your %s. You will need to re-enter it.',
94
89
  sDesc)
@@ -99,6 +94,34 @@ module Lorj
99
94
  value_hidden
100
95
  end
101
96
 
97
+ # internal runtime function for process call #_build_hdata and
98
+ # #_get_encrypted_value_hidden
99
+ # Get encrypted value
100
+ #
101
+ # *parameters*:
102
+ # - +default+ : encrypted default value
103
+ # - +entropy+ : Entropy Hash
104
+ #
105
+ # *return*:
106
+ # - value : decrypted value.
107
+ #
108
+ # *raise*:
109
+ #
110
+ def _get_encrypted_value(enc_value, entr)
111
+ return '' if enc_value.nil?
112
+ begin
113
+ Encryptor.decrypt(
114
+ :value => Base64.strict_decode64(enc_value),
115
+ :key => entr[:key],
116
+ :iv => Base64.strict_decode64(entr[:iv]),
117
+ :salt => entr[:salt]
118
+ )
119
+ rescue
120
+ PrcLib.error('Unable to decrypt your %s. You will need to re-enter it.',
121
+ sDesc)
122
+ end
123
+ end
124
+
102
125
  # internal runtime function for process call
103
126
  # Ask encrypted function executed by _ask
104
127
  #
@@ -37,7 +37,7 @@ module Lorj
37
37
  # * *Raises* :
38
38
  #
39
39
  def _setup_load
40
- ask_steps = Lorj.defaults.data.rh_get(:setup, :ask_step)
40
+ ask_steps = Lorj.data.setup_data(:ask_step)
41
41
  setup_steps = []
42
42
  ask_steps.each do |value|
43
43
  setup_steps << {
@@ -214,7 +214,7 @@ module Lorj
214
214
  order_array.each_index do |iIndex|
215
215
  Lorj.debug(2, 'Ask order %s:', iIndex)
216
216
  order_array[iIndex].each do |data|
217
- options = _get_meta_data_auto(data)
217
+ options = _get_meta_data(data)
218
218
  options = {} if options.nil?
219
219
 
220
220
  data_desc = _setup_display_data(data, options)