lorj 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +39 -579
  4. data/Rakefile +7 -0
  5. data/example/students_1/student_v1.md +115 -0
  6. data/example/students_1/students.rb +8 -2
  7. data/example/students_2/process/students.rb +5 -5
  8. data/example/students_2/student_v2.md +90 -0
  9. data/example/students_2/students.rb +6 -6
  10. data/example/students_3/controller/yaml_students.rb +23 -73
  11. data/example/students_3/controller/yaml_students_code.rb +106 -0
  12. data/example/students_3/controller/yaml_students_def.rb +69 -0
  13. data/example/students_3/process/students.rb +23 -157
  14. data/example/students_3/student_v3.md +283 -0
  15. data/example/students_3/students.rb +26 -83
  16. data/example/students_4/controller/yaml_students.rb +51 -0
  17. data/example/students_4/controller/yaml_students_code.rb +109 -0
  18. data/example/students_4/controller/yaml_students_def.rb +72 -0
  19. data/example/students_4/process/students/code/students.rb +103 -0
  20. data/example/students_4/process/students/definition/students.rb +60 -0
  21. data/example/students_4/process/students.rb +29 -0
  22. data/example/students_4/student_v4.md +191 -0
  23. data/example/students_4/students.rb +65 -0
  24. data/example/students_5/controller/yaml_students.rb +106 -0
  25. data/example/{students_3 → students_5}/controller/yaml_students_controller.rb +5 -3
  26. data/example/students_5/process/students.rb +182 -0
  27. data/example/students_5/student_v5.md +382 -0
  28. data/example/students_5/students.rb +119 -0
  29. data/example/yaml_students/students.rb +1 -1
  30. data/example/yaml_students/yaml_students.rb +102 -23
  31. data/lib/concept.md +3 -3
  32. data/lib/core/core.rb +15 -15
  33. data/lib/core/core_controller.rb +49 -24
  34. data/lib/core/core_internal.rb +2 -2
  35. data/lib/core/core_model.rb +13 -7
  36. data/lib/core/core_object_data.rb +18 -18
  37. data/lib/core/core_object_params.rb +75 -34
  38. data/lib/core/core_process.rb +104 -59
  39. data/lib/core/core_process_setup.rb +11 -11
  40. data/lib/core/core_setup_ask.rb +24 -14
  41. data/lib/core/core_setup_encrypt.rb +17 -15
  42. data/lib/core/core_setup_init.rb +19 -15
  43. data/lib/core/core_setup_list.rb +12 -12
  44. data/lib/core/definition.rb +20 -20
  45. data/lib/core/definition_internal.rb +20 -10
  46. data/lib/core/lorj_basecontroller.rb +8 -8
  47. data/lib/core/lorj_basedefinition.rb +47 -126
  48. data/lib/core/lorj_baseprocess.rb +81 -57
  49. data/lib/core/lorj_data.rb +28 -27
  50. data/lib/core/lorj_keypath.rb +1 -1
  51. data/lib/core_process/cloud/process/flavor.rb +3 -2
  52. data/lib/core_process/cloud/process/keypairs.rb +5 -4
  53. data/lib/core_process/cloud/process/network.rb +4 -3
  54. data/lib/core_process/cloud/process/public_ip.rb +3 -2
  55. data/lib/core_process/cloud/process/rules.rb +7 -6
  56. data/lib/core_process/cloud/process/security_groups.rb +1 -1
  57. data/lib/core_process/cloud/process/server.rb +1 -1
  58. data/lib/core_process/cloud/process/server_log.rb +1 -1
  59. data/lib/core_process/cloud/process/subnetwork.rb +4 -1
  60. data/lib/core_process/cloud_process.rb +1 -1
  61. data/lib/logging.rb +41 -48
  62. data/lib/lorj/version.rb +1 -1
  63. data/lib/lorj.rb +7 -0
  64. data/lib/lorj_account.rb +3 -3
  65. data/lib/lorj_config.rb +1 -1
  66. data/lib/lorj_defaults.rb +222 -26
  67. data/lib/overview.md +120 -0
  68. data/lib/prc.rb +97 -24
  69. data/lib/prc_core_config.rb +134 -52
  70. data/lib/providers/hpcloud/compute.rb +3 -3
  71. data/lib/providers/hpcloud/hpcloud.rb +14 -14
  72. data/lib/providers/hpcloud/network.rb +4 -4
  73. data/lib/providers/hpcloud/security_groups.rb +1 -1
  74. data/lib/providers/mock/mock.rb +3 -3
  75. data/lib/providers/openstack/openstack.rb +12 -12
  76. data/lib/providers/templates/compute.rb +6 -6
  77. data/lib/rh.rb +7 -5
  78. data/spec/04_prc_core_config_spec.rb +52 -0
  79. data/spec/11_lorj_config_spec.rb +1 -1
  80. metadata +21 -3
@@ -44,8 +44,9 @@ class CloudProcess
44
44
  :more => "Found several %s. Searching for '%s'.",
45
45
  :items => :public_ip
46
46
  }
47
- list = controller_query(sCloudObj, sQuery)
48
- query_single(sCloudObj, list, sQuery, server_name, info)
47
+ # list = controller_query(sCloudObj, sQuery)
48
+ # query_single(sCloudObj, list, sQuery, server_name, info)
49
+ query_single(sCloudObj, sQuery, server_name, info)
49
50
  rescue => e
50
51
  retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
51
52
  end
@@ -30,18 +30,19 @@ class CloudProcess
30
30
 
31
31
  # Process Query handler
32
32
  def forj_query_rule(sCloudObj, sQuery, hParams)
33
- rule = '%s %s:%s - %s to %s', hParams[:dir], hParams[:rule_proto],
34
- hParams[:port_min], hParams[:port_max],
35
- hParams[:addr_map]
33
+ rule = format('%s %s:%s - %s to %s', hParams[:dir], hParams[:rule_proto],
34
+ hParams[:port_min], hParams[:port_max],
35
+ hParams[:addr_map])
36
36
  PrcLib.state("Searching for rule '%s'", rule)
37
37
  ssl_error_obj = SSLErrorMgt.new
38
38
  begin
39
39
  info = {
40
- :items => [:dir, :rule_proto, :port_min, :port_max, :addr_map],
40
+ :items => [:dir, :proto, :port_min, :port_max, :addr_map],
41
41
  :items_form => '%s %s:%s - %s to %s'
42
42
  }
43
- list = controller_query(sCloudObj, sQuery)
44
- query_single(sCloudObj, list, sQuery, rule, info)
43
+ # list = controller_query(sCloudObj, sQuery)
44
+ # query_single(sCloudObj, list, sQuery, rule, info)
45
+ query_single(sCloudObj, sQuery, rule, info)
45
46
  rescue => e
46
47
  retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
47
48
  end
@@ -49,7 +49,7 @@ class CloudProcess
49
49
  config[:addr_map] = '0.0.0.0/0'
50
50
 
51
51
  # object.Create(:rule)
52
- Create(:rule)
52
+ process_create(:rule)
53
53
  end
54
54
  end
55
55
  security_group
@@ -63,7 +63,7 @@ class CloudProcess
63
63
  end
64
64
 
65
65
  # Define framework object on BaseDefinition
66
- class Lorj
66
+ module Lorj
67
67
  # ************************************ SERVER Object
68
68
  # Identify the server to use/build on the network/...
69
69
  class BaseDefinition
@@ -17,7 +17,7 @@
17
17
  # It requires Core objects to be defined + default ForjProcess functions.
18
18
 
19
19
  # Define framework object on BaseDefinition
20
- class Lorj
20
+ module Lorj
21
21
  # ************************************ SERVER Console Object
22
22
  # Object representing the console log attached to a server
23
23
  class BaseDefinition
@@ -20,7 +20,10 @@
20
20
  class CloudProcess
21
21
  def forj_get_or_create_subnetwork(sCloudObj, hParams)
22
22
  subnet = query_subnet_one(sCloudObj, hParams)
23
- return nil if subnet.nil?
23
+ unless subnet.empty?
24
+ register(subnet)
25
+ return subnet
26
+ end
24
27
 
25
28
  # Create the subnet
26
29
  subnet = create_subnet(sCloudObj, hParams)
@@ -25,6 +25,6 @@ lorj_objects = %w(common connection network subnetwork router
25
25
  keypairs images flavor internet_network server public_ip
26
26
  server_log internet_server)
27
27
 
28
- lorj_objects.each do | name |
28
+ lorj_objects.each do |name|
29
29
  require File.join(cloud_path, 'cloud', 'process', name + '.rb')
30
30
  end
data/lib/logging.rb CHANGED
@@ -23,51 +23,6 @@ require 'ansi'
23
23
  require 'ansi/logger'
24
24
 
25
25
  #
26
- # PrcLib module
27
- #
28
- # PrcLib Implements a Logging class based on logger.
29
- #
30
- # For details about this class capabilities, see PrcLib::Logging
31
- #
32
- # # To use the Prc::Logging system, do the following:
33
- # require 'PrcLib'
34
- #
35
- # # To configure logging system:
36
- # PrcLib.app_name = 'config/app' # Define application data path as
37
- # # ~/.<app_name>.
38
- # # Ex: 'config/app' will use ~/.config/app
39
- # PrcLib.log_file = 'app.log' # Relative path to the log file name
40
- # # stored in the Application data path.
41
- # # Here, ~/.config/app/app.log
42
- # PrcLib.level = Logger::FATAL # Define printout debug level. Can be any
43
- # # Logger predefined value.
44
- #
45
- # # To log some information:
46
- # PrcLib.debug('My debug message')
47
- # PrcLib.info('My info message')
48
- # PrcLib.warning('my warning')
49
- # PrcLib.error('my error')
50
- # PrcLib.fatal(2, "Fatal error, with return code = 2)
51
- # PrcLib.message('Only printout message')
52
- #
53
- # # You can printout some instant message to the terminal, not logged.
54
- # # This is useful before any action that will take time to be executed.
55
- # # It is inform the end user that something is still running, which means
56
- # # the application is not frozen
57
- # PrcLib.state("Running a long task")
58
- # # The next message will replace the previous state message.
59
- # sleep(10)
60
- # PrcLib.info("The long task has been executed successfully.")
61
- #
62
- # # You can change the logger level with PrcLib.level
63
- # PrcLib.level = Logger::DEBUG
64
- #
65
- # # You can just print high level message (print without \n) if PrcLib.level
66
- # is not DEBUG or INFO.
67
- # PrcLib.high_level_msg("Print a message, not logged, if level is not DEBUG
68
- # or INFO")
69
- #
70
- # Enjoy!
71
26
  module PrcLib
72
27
  # Class used to create 2 logger object, in order to keep track of error in a
73
28
  # log file and change log output to OUTPUT on needs (option flags).
@@ -86,7 +41,45 @@ module PrcLib
86
41
  # set.
87
42
  # In several cases, messages are printed out, but not stored in the log file.
88
43
  #
89
- # See Logging functions for details.
44
+ # To use the Prc::Logging system, do the following:
45
+ # require 'PrcLib'
46
+ #
47
+ # # To configure logging system:
48
+ # PrcLib.app_name = 'config/app' # Define application data path as
49
+ # # ~/.<app_name>.
50
+ # # Ex: 'config/app' will use ~/.config/app
51
+ # PrcLib.log_file = 'app.log' # Relative path to the log file name
52
+ # # stored in the Application data path.
53
+ # # Here, ~/.config/app/app.log
54
+ # PrcLib.level = Logger::FATAL # Define printout debug level. Can be any
55
+ # # Logger predefined value.
56
+ #
57
+ # # To log some information:
58
+ # PrcLib.debug('My %s debug message', 'test')
59
+ # PrcLib.info('My info message')
60
+ # PrcLib.warning('my warning')
61
+ # PrcLib.error('my error')
62
+ # PrcLib.fatal(2, "Fatal error, with return code = 2)
63
+ # PrcLib.message('Only printout message')
64
+ #
65
+ # # You can printout some instant message to the terminal, not logged.
66
+ # # This is useful before any action that will take time to be executed.
67
+ # # It is inform the end user that something is still running, which means
68
+ # # the application is not frozen
69
+ # PrcLib.state("Running a long task")
70
+ # # The next message will replace the previous state message.
71
+ # sleep(10)
72
+ # PrcLib.info("The long task has been executed successfully.")
73
+ #
74
+ # # You can change the logger level with PrcLib.level
75
+ # PrcLib.level = Logger::DEBUG
76
+ #
77
+ # # You can just print high level message (print without \n)
78
+ # # if PrcLib.level is not DEBUG or INFO.
79
+ # PrcLib.high_level_msg("Print a message, not logged, if level is not DEBUG
80
+ # # or INFO")
81
+ #
82
+ # For details, see Logging functions
90
83
  #
91
84
  class Logging
92
85
  attr_reader :level
@@ -155,7 +148,7 @@ module PrcLib
155
148
  # Log to STDOUT and Log file and ERROR class message
156
149
  def error(message)
157
150
  @out_logger.error(message + ANSI.clear_eol)
158
- @file_logger.error(message)
151
+ @file_logger.error(message + "\n" + caller.join("\n"))
159
152
  end
160
153
 
161
154
  # Log to STDOUT and Log file and FATAL class message
@@ -250,7 +243,7 @@ module PrcLib
250
243
 
251
244
  # Internal heap management to help controller developper to identify issue.
252
245
  def dcl_fail(msg, *p)
253
- msg = "Declaration error:\n%s"
246
+ msg = "Declaration error:\n" + msg
254
247
  msg += format("\nSee at %s",
255
248
  PrcLib.model.heap[0]) if PrcLib.model.heap.is_a?(Array)
256
249
  runtime_fail(msg, *p)
data/lib/lorj/version.rb CHANGED
@@ -16,5 +16,5 @@
16
16
 
17
17
  # Lorj version
18
18
  module Lorj
19
- VERSION = '1.0.1'
19
+ VERSION = '1.0.2'
20
20
  end
data/lib/lorj.rb CHANGED
@@ -35,9 +35,16 @@ require 'lorj_account.rb' # Lorj::Account class - account config
35
35
 
36
36
  require 'core/core_internal' # Lorj Core class private init. functions
37
37
  require 'core/core' # Lorj Core class
38
+ require 'core/core_object_params' # Lorj Internal core class
38
39
  require 'core/core_model' # Lorj Model class
39
40
  require 'core/core_process' # Lorj core process functions
41
+ require 'core/core_process_setup' # Lorj core process setup
42
+ require 'core/core_setup_ask' # Lorj core setup ask functions
43
+ require 'core/core_setup_encrypt' # Lorj core setup encrypt functions
44
+ require 'core/core_setup_init' # Lorj core setup init functions
45
+ require 'core/core_setup_list' # Lorj core setup list functions
40
46
  require 'core/core_controller' # Lorj core controller functions
47
+
41
48
  require 'core/core_object_data' # Lorj ObjectData class
42
49
  require 'core/lorj_data' # Lorj Lorj::Data object
43
50
  require 'core/lorj_basedefinition' # Lorj Lorj::BaseDefinition object
data/lib/lorj_account.rb CHANGED
@@ -502,9 +502,9 @@ module Lorj
502
502
  index = layer_index(options[:name]) if options.key?(:name)
503
503
 
504
504
  indexes = exclusive_indexes(account_exclusive)
505
- options[:indexes] = indexes
506
-
507
505
  indexes = [index] if !index.nil? && indexes.include?(index)
506
+
507
+ options[:indexes] = indexes
508
508
  indexes
509
509
  end
510
510
 
@@ -553,7 +553,7 @@ module Lorj
553
553
 
554
554
  def index_to_update(layer_name, key, section)
555
555
  indexes = [0] # choose runtime by default.
556
- indexes = _layer_indexes([layer_name]) unless layer_name.nil?
556
+ indexes = layer_indexes([layer_name]) unless layer_name.nil?
557
557
 
558
558
  if layer_name.nil?
559
559
  # Return runtime layer, if layer requested is not updatable.
data/lib/lorj_config.rb CHANGED
@@ -88,7 +88,7 @@ module Lorj
88
88
  if names.length == 1
89
89
  res = config_layers[0][:config].data
90
90
  else
91
- config_layers.each do | layer |
91
+ config_layers.each do |layer|
92
92
  res[layer[:name]] = layer[:config].data
93
93
  end
94
94
  end
data/lib/lorj_defaults.rb CHANGED
@@ -23,29 +23,107 @@ require 'yaml'
23
23
  module Lorj
24
24
  # This class is the Application configuration class used by Lorj::Config
25
25
  #
26
- # It load a defaults.yaml file (path defined by PrcLib::app_defaults)
26
+ # It loads a defaults.yaml file (path defined by PrcLib::app_defaults)
27
+ #
28
+ # The defaults.yaml data is accessible through Lorj.defaults.data
29
+ # Use this capability with caution, as it contents is R/W.
30
+ #
31
+ # For getting Application defaults, use Lorj::Config[]
32
+ # or Lorj::Account[], Lorj::Account.get(key, nil, :names => ['default'])
33
+ # For setup meta data, use Lorj.defaults.get_meta,
34
+ # Lorj.defaults.get_meta_auto or Lorj.defaults.get_meta_section
27
35
  #
28
36
  # defaults.yaml is divided in 3 sections:
29
37
  #
30
- # * :default: Contains a list of key = value
38
+ # * :default: Contains a list of key = value representing the application
39
+ # default configuration.
40
+ #
41
+ # Data stored in this section are accessible through Lorj::Config[]
42
+ # or Lorj::Account[], Lorj::Account.get(key, nil, :names => ['default'])
43
+ #
44
+ # Ex:
45
+ # # Use Lorj.defaults.data exceptionnaly
46
+ # Lorj.defaults.data.merge(:default => { data: 'test'}})
47
+ #
48
+ # config = Lorj::Account.new
49
+ # puts config.get(:data, nil, :names => ['default'])
50
+ # # => test
51
+ # puts Lorj.defaults[:data]
52
+ # # => test
53
+ #
31
54
  # * :setup: Contains :ask_step array
32
- # - :ask_step: Array of group of keys/values to setup. Each group will be
33
- # internally identified by a index starting at 0. parameters
34
- # are as follow:
55
+ # - :ask_step:
56
+ #
57
+ # Array of group of keys/values to setup. Each group will be
58
+ # internally identified by a index starting at 0. parameters are as
59
+ # follow:
35
60
  # - :desc: string to print out before group setup
61
+ #
62
+ # ERB template enable: To get config data in ERB context, use
63
+ # config[...]
64
+ #
36
65
  # - :explanation: longer string to display after :desc:
37
- # - :add: array of keys to add manually in the group.
66
+ #
67
+ # It is printed out in brown color.
68
+ #
69
+ # It supports ERB template. To get config data, type
70
+ # <%= config[...] %>
71
+ #
72
+ # In your defaults.yaml file, write multiline with |- after the key.
73
+ #
74
+ # Ex: if config['text'] returns 'text', defaults.yaml can have the
75
+ # following explanation.
76
+ #
77
+ # [...]
78
+ # :explanation: |-
79
+ # My complete explanation is in
80
+ # multiline <%= config['text'] %>
81
+ # [...]
82
+ #
83
+ #
84
+ # - :add: array of keys to add manually in the group. The Array can be
85
+ # written with [] or list of dash elements
86
+ #
87
+ # Example of a defaults.yaml content:
88
+ #
89
+ # [...]
90
+ # :ports: [22, 25]
91
+ #
92
+ # :ports:
93
+ # - 22
94
+ # - 25
95
+ # [...]
38
96
  #
39
97
  # By default, thanks to data model dependency, the group is
40
- # automatically populated.
98
+ # automatically populated. So, you need update this part only for
99
+ # data that are not found from the dependency.
100
+ # * :section: Contains a list of sections with several keys and attributes
101
+ # and eventually :default:
41
102
  #
42
- # * :section: Contains a list of sections contains several key and attributes
43
- # and eventually :default:
44
103
  # This list of sections and keys will be used to build the account files
45
- # with the lorj Lorj::Core::Setup function.
104
+ # with the lorj Lorj::Core.setup function.
105
+ # Those data is accessible through the Lorj.defaults.get_meta,
106
+ # Lorj.defaults.get_meta_auto or Lorj.defaults.get_meta_section
107
+ #
108
+ # Ex:
109
+ # # Use Lorj.defaults.data exceptionnaly
110
+ # Lorj.defaults.data.merge({sections: {:mysection: {key: {
111
+ # data1: 'test1',
112
+ # data2: 'test2'
113
+ # }}}})
114
+ #
115
+ # puts Lorj.defaults.get_meta(:mysection, :key)
116
+ # # => { data1: 'test1', data2: 'test2' }
117
+ # puts Lorj.defaults.get_meta(:mysection)
118
+ # # => {:key => { data1: 'test1', data2: 'test2' }}
119
+ # puts Lorj.defaults.get_meta_section(:key)
120
+ # # => :mysection
121
+ # puts Lorj.defaults.get_meta_auto(:key)
122
+ # # => { data1: 'test1', data2: 'test2' }
46
123
  #
47
124
  # - :default: This section define updatable data available from config.yaml.
48
- # But will never be added in an account file.
125
+ # But will never be added in an account file.
126
+ #
49
127
  # It contains a list of key and options.
50
128
  #
51
129
  # - :<aKey>: Possible options
@@ -53,20 +131,31 @@ module Lorj
53
131
  #
54
132
  # - :<aSectionName>: Name of the section which should contains a list
55
133
  # - :<aKeyName>: Name of the key to setup.
56
- # - :desc: Description of that key, printed out at setup
57
- # time.
134
+ # - :desc:
135
+ #
136
+ # Description of that key, printed out at setup time.
137
+ #
58
138
  # - :readonly: true if this key is not modifiable by a simple
59
- # Lorj::Account::set function. false otherwise.
139
+ #
140
+ # Lorj::Account::set function. false otherwise.
141
+ #
60
142
  # - :account_exclusive: true if the key cannot be set as default from
61
- # config.yaml or defaults.yaml.
143
+ # config.yaml or defaults.yaml.
144
+ #
62
145
  # - :account: true to ask setup to ask this key to the user.
146
+ #
63
147
  # - :validate: Ruby Regex to validate the end user input.
64
- # Ex: !ruby/regexp /^\w?\w*$/
148
+ #
149
+ # Ex: !ruby/regexp /^\w?\w*$/
150
+ #
65
151
  # - :default_value: default value proposed to the user.
152
+ #
66
153
  # - :ask_step: Define the group number to attach the key to be
67
- # asked. ex: 2
154
+ # asked. ex: 2
155
+ #
68
156
  # - :list_values: Provide capabililities to get a list and choose
69
- # from.
157
+ # from.
158
+ #
70
159
  # - :query_type: Can be:
71
160
  #
72
161
  # ':query_call' to execute a query on flavor, query_params is empty
@@ -99,10 +188,112 @@ module Lorj
99
188
  # Used with :query_type=:process_call. hParams data passed to the
100
189
  # process function.
101
190
  #
102
- # - :value: fields to extract for the list of objects
103
- # displayed.
104
- # - :validate: if :list_strict, the value is limited to the
105
- # possible values from the list
191
+ # - :value:
192
+ #
193
+ # fields to extract for the list of objects displayed.
194
+ #
195
+ # - :validate:
196
+ #
197
+ # if :list_strict, the value is limited to the possible values from
198
+ # the list
199
+
200
+ # meta data are defined in defaults.yaml and loaded in Lorj::Default class
201
+ # definition.
202
+ # Cloud provider can redefine ForjData defaults and add some extra
203
+ # parameters.
204
+ # To get Application defaults, read defaults.yaml, under :sections:
205
+ # Those values can be updated by the controller with define_data
206
+ # <Section>:
207
+ # <Data>: Required. Symbol/String. default: nil
208
+ # => Data name. This symbol must be unique, across
209
+ # sections.
210
+ # :desc: Required. String. default: nil
211
+ # => Description
212
+ # :explanation: |- Print a multiline explanation before ask the key
213
+ # value.
214
+ # ERB template enable. To get config data,
215
+ # type <%= config[...] %>
216
+ # :readonly: Optional. true/false. Default: false
217
+ # => oForjConfig.set() will fail if readonly is
218
+ # true. It can be set, only thanks to:
219
+ # - oForjConfig.setup()
220
+ # or using private
221
+ # - oForjConfig._set()
222
+ # :account_exclusive: Optional. true/false. Default: false
223
+ # => Only oConfig.account_get/set() can handle the
224
+ # value
225
+ # oConfig.set/get cannot.
226
+ # :account: Optional. default: False
227
+ # => setup will configure the account with this
228
+ # <Data>
229
+ # :ask_sort: Number which represents the ask order in the
230
+ # step group. (See /:setup/:ask_step for details)
231
+ # :after: <Data> Name of the previous <Data> to ask before the
232
+ # current one.
233
+ # :depends_on:
234
+ # => Identify :data type required to be set before
235
+ # the current one.
236
+ # :default_value: Default value at setup time. This is not
237
+ # necessarily the Application default value
238
+ # (See /:default)
239
+ # :validate: Regular expression to validate end user input
240
+ # during setup.
241
+ # :value_mapping: list of values to map as defined by the
242
+ # controller
243
+ # :controller: mapping for get controller value from process
244
+ # values
245
+ # <value> : <map> value map equivalence. See data_value_mapping
246
+ # function
247
+ # :process: mapping for get process value from controller
248
+ # values
249
+ # <value> : <map> value map equivalence. See data_value_mapping
250
+ # function
251
+ # :default: Default value. Replace /:default/<data>
252
+ # :list_values: Defines a list of valid values for the current
253
+ # data.
254
+ # :query_type :controller_call to execute a function defined
255
+ # in the controller object.
256
+ # :process_call to execute a function defined in
257
+ # the process object.
258
+ # :values to get list of values from :values.
259
+ # :object Object to load before calling the function.
260
+ # Only :query_type = :*_call
261
+ # :query_call Symbol. function name to call.
262
+ # Only :query_type = :*_call
263
+ # function must return an Array.
264
+ # :query_params Hash. Controler function parameters.
265
+ # Only :query_type = :*_call
266
+ # :validate :list_strict. valid only if value is one of
267
+ # thoselisted.
268
+ # :values: to retrieve from.
269
+ # otherwise define simply a list of possible
270
+ # values.
271
+ # :ask_step: Step number. By default, setup will determine
272
+ # the step, thanks to meta lorj object
273
+ # dependencies tree.
274
+ # This number start at 0. Each step can be defined
275
+ # by /:setup/:ask_step/<steps> list.
276
+ # :pre_step_function: Process called before asking the data.
277
+ # if it returns true, user interaction is
278
+ # cancelled.
279
+ # :post_step_function:Process called after asking the data.
280
+ # if it returns false, the user is requested to
281
+ # re-enter a new value.
282
+ #
283
+ # :setup: This section describes group of fields to ask,
284
+ # step by step.
285
+ # :ask_step: Define an Array of setup steps to ask to the
286
+ # end user. The step order is respected, and
287
+ # start at 0
288
+ # - :desc: Define the step description. ERB template
289
+ # enable. To get config data, type config[...]
290
+ # :explanation: |- Define a multiline explanation. This is printed
291
+ # out in brown color.
292
+ # ERB template enable. To get config data, type
293
+ # <%= config[...] %>
294
+ # :add: Define a list of additionnal fields to ask.
295
+ # - <Data> Data to ask.
296
+ #
106
297
  class Defaults < PRC::SectionConfig
107
298
  # Remove inherited method []=
108
299
  def []=(*_keys, _value)
@@ -123,8 +314,8 @@ module Lorj
123
314
  def meta_each
124
315
  return nil if @data.rh_get(:sections).nil?
125
316
 
126
- @data.rh_get(:sections).each do | section, hValue |
127
- hValue.each do | key, value |
317
+ @data.rh_get(:sections).each do |section, hValue|
318
+ hValue.each do |key, value|
128
319
  yield section, key, value
129
320
  end
130
321
  end
@@ -168,6 +359,11 @@ module Lorj
168
359
  @data.rh_get(:sections, section, keys)
169
360
  end
170
361
 
362
+ # def get_meta_section(*keys)
363
+ # return nil unless keys.length > 0
364
+ # @account_section_mapping.rh_get(keys[0])
365
+ # end
366
+
171
367
  # Get model section/data options.
172
368
  #
173
369
  # * *Args* :
@@ -204,9 +400,9 @@ module Lorj
204
400
 
205
401
  # TODO: Support multiple identical key name on distinct sections
206
402
  # The primary data key should change from key to section & key.
207
- @data.rh_get(:sections).each do | section, hValue |
403
+ @data.rh_get(:sections).each do |section, hValue|
208
404
  next if section == :default
209
- hValue.each_key do | map_key |
405
+ hValue.each_key do |map_key|
210
406
  if @account_section_mapping.rh_exist?(map_key)
211
407
  PrcLib.fatal(1, 'defaults.yaml: Duplicate entry between sections. '\
212
408
  "'%s' defined in section '%s' already exists in"\