lorj 1.0.1 → 1.0.2

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.
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
@@ -42,7 +42,7 @@ class MockController
42
42
 
43
43
  array = @@data[sObjectType]
44
44
 
45
- array.each do | value |
45
+ array.each do |value|
46
46
  fail if value.key?(result[:name])
47
47
  end
48
48
  array << result
@@ -78,9 +78,9 @@ class MockController
78
78
 
79
79
  result = []
80
80
 
81
- @@data[sObjectType].each do | value |
81
+ @@data[sObjectType].each do |value|
82
82
  elem = value
83
- sQuery.each do | query_key, query_value |
83
+ sQuery.each do |query_key, query_value|
84
84
  elem = nil if !value.key?(query_key) || value[query_key] != query_value
85
85
  end
86
86
  result << elem if elem
@@ -23,23 +23,23 @@ class Openstack < BaseDefinition
23
23
 
24
24
  def compute
25
25
  Fog::Compute.new(
26
- :provider => :openstack,
27
- :openstack_api_key => superclass.oForjAccount.get(:account_id),
28
- :openstack_username => superclass.oForjAccount.get(:account_key),
29
- :openstack_auth_url => superclass.oForjAccount.get(:auth_uri),
30
- :openstack_tenant => superclass.oForjAccount.get(:tenant_id),
31
- :openstack_region => superclass.oForjAccount.get(:compute)
26
+ :provider => :openstack,
27
+ :openstack_api_key => superclass.oForjAccount.get(:account_id),
28
+ :openstack_username => superclass.oForjAccount.get(:account_key),
29
+ :openstack_auth_url => superclass.oForjAccount.get(:auth_uri),
30
+ :openstack_tenant => superclass.oForjAccount.get(:tenant_id),
31
+ :openstack_region => superclass.oForjAccount.get(:compute)
32
32
  )
33
33
  end
34
34
 
35
35
  def network
36
36
  Fog::Network.new(
37
- :provider => :openstack,
38
- :openstack_api_key => superclass.oForjAccount.get(:account_id),
39
- :openstack_username => superclass.oForjAccount.get(:account_key),
40
- :openstack_auth_url => superclass.oForjAccount.get(:auth_uri),
41
- :openstack_tenant => superclass.oForjAccount.get(:tenant_id),
42
- :openstack_region => superclass.oForjAccount.get(:network)
37
+ :provider => :openstack,
38
+ :openstack_api_key => superclass.oForjAccount.get(:account_id),
39
+ :openstack_username => superclass.oForjAccount.get(:account_key),
40
+ :openstack_auth_url => superclass.oForjAccount.get(:auth_uri),
41
+ :openstack_tenant => superclass.oForjAccount.get(:tenant_id),
42
+ :openstack_region => superclass.oForjAccount.get(:network)
43
43
  )
44
44
  end
45
45
  end
@@ -29,12 +29,12 @@ class Mycloud
29
29
  # obj_needs(:data, :<CloudDataKey},{:mapping => :<MyCloudKeyMapped>})
30
30
  # can be updated by removing the mapping => <Value>
31
31
  Fog::Compute.new(
32
- :provider => :mycloud,
33
- :user => @oForjAccount.get(:account_id),
34
- :pwd => @oForjAccount.get(:account_key),
35
- :auth_uri => @oForjAccount.get(:auth_uri),
36
- :project => @oForjAccount.get(:tenant),
37
- :compute_service => @oForjAccount.get(:compute)
32
+ :provider => :mycloud,
33
+ :user => @oForjAccount.get(:account_id),
34
+ :pwd => @oForjAccount.get(:account_key),
35
+ :auth_uri => @oForjAccount.get(:auth_uri),
36
+ :project => @oForjAccount.get(:tenant),
37
+ :compute_service => @oForjAccount.get(:compute)
38
38
  )
39
39
  end
40
40
  end
data/lib/rh.rb CHANGED
@@ -66,9 +66,10 @@ class Hash
66
66
  # yVal.rh_lexist? => 0
67
67
 
68
68
  def rh_lexist?(*p)
69
+ p = p.flatten
70
+
69
71
  return 0 if p.length == 0
70
72
 
71
- p = p.flatten
72
73
  if p.length == 1
73
74
  return 1 if self.key?(p[0])
74
75
  return 0
@@ -212,9 +213,9 @@ class Hash
212
213
  # # yVal = {:test2 => {:test5 => :test, 'text' => 'blabla'},
213
214
  # :test5 => :test }
214
215
  def rh_set(value, *p)
216
+ p = p.flatten
215
217
  return nil if p.length == 0
216
218
 
217
- p = p.flatten
218
219
  if p.length == 1
219
220
  self[p[0]] = value
220
221
  return value
@@ -260,9 +261,10 @@ class Hash
260
261
  # # yVal = {:test2 => {} }
261
262
  #
262
263
  def rh_del(*p)
264
+ p = p.flatten
265
+
263
266
  return nil if p.length == 0
264
267
 
265
- p = p.flatten
266
268
  return delete(p[0]) if p.length == 1
267
269
 
268
270
  return nil if self[p[0]].nil?
@@ -294,7 +296,7 @@ class Hash
294
296
 
295
297
  def rh_key_to_symbol(levels = 1)
296
298
  result = {}
297
- each do | key, value |
299
+ each do |key, value|
298
300
  new_key = key
299
301
  new_key = key.to_sym if key.is_a?(String)
300
302
  if value.is_a?(Hash) && levels > 1
@@ -325,7 +327,7 @@ class Hash
325
327
  # rh_key_to_symbol?(3) return true
326
328
  # rh_key_to_symbol?(4) return true
327
329
  def rh_key_to_symbol?(levels = 1)
328
- each do | key, value |
330
+ each do |key, value|
329
331
  return true if key.is_a?(String)
330
332
 
331
333
  res = false
@@ -79,5 +79,57 @@ describe 'class: PRC::CoreConfig,' do
79
79
  expect(@config.del(:test)).to eq(:where)
80
80
  expect(@config[:test]).to equal(:found_local)
81
81
  end
82
+
83
+ it 'PRC::CoreConfig.define_layer(...) return a valid standalone layer' do
84
+ config = PRC::BaseConfig.new
85
+ layer = PRC::CoreConfig.define_layer(:name => 'instant',
86
+ :config => config)
87
+ expect(layer).to be
88
+ expect(layer[:name]).to eq('instant')
89
+ expect(layer[:config]).to eq(config)
90
+ expect(layer[:set]).to equal(true)
91
+ expect(layer[:load]).to equal(false)
92
+ expect(layer[:save]).to equal(false)
93
+ expect(layer[:file_set]).to equal(false)
94
+ end
95
+
96
+ it "config.layer_add(:name => 'instant') return true if layer is added" do
97
+ layer = PRC::CoreConfig.define_layer(:name => 'instant')
98
+ expect(@config.layer_add layer).to equal(true)
99
+ end
100
+
101
+ it 'config.layers return %w(instant runtime local)' do
102
+ expect(@config.layers).to eq(%w(instant runtime local))
103
+ end
104
+
105
+ it 'config.layer_add(layer) return nil if layer name already exist '\
106
+ 'in layers' do
107
+ config = PRC::BaseConfig.new
108
+ layer = PRC::CoreConfig.define_layer(:name => 'instant',
109
+ :config => config)
110
+ expect(@config.layers).to eq(%w(instant runtime local))
111
+ expect(@config.layer_add layer).to equal(nil)
112
+ expect(@config.layers).to eq(%w(instant runtime local))
113
+ end
114
+
115
+ it "config['test'] = 'toto' is added in the 'instant' layer" do
116
+ @config['test'] = 'toto'
117
+ expect(@config.where?('test')).to eq(%w(instant))
118
+ end
119
+
120
+ it "config.layer_remove(:name => 'instant') return true" do
121
+ expect(@config.layer_remove(:name => 'instant')).to equal(true)
122
+ end
123
+
124
+ it "config.where?('test') return false - The layer is inexistent." do
125
+ expect(@config.where?('test')).to equal(false)
126
+ end
127
+
128
+ it "config.layer_remove(:name => 'runtime') return nil"\
129
+ ' - Unable to remove a layer not added at runtime' do
130
+ expect(@config.layers).to eq(%w(runtime local))
131
+ expect(@config.layer_remove(:name => 'runtime')).to equal(nil)
132
+ expect(@config.layers).to eq(%w(runtime local))
133
+ end
82
134
  end
83
135
  end
@@ -251,7 +251,7 @@ describe 'class: Lorj::Config,' do
251
251
  # The defaults.yaml MUST have data exclusive set to true
252
252
  expect(@default.rh_get(:sections, :credentials, :data,
253
253
  :account_exclusive)).to equal(true)
254
- @config.meta_each do | section, key, value |
254
+ @config.meta_each do |section, key, value|
255
255
  expect(@default.rh_exist?(:sections, section, key)).to equal(true)
256
256
  expect(@default.rh_get(:sections, section, key)).to equal(value)
257
257
  expect([section, key,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lorj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - forj team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,13 +127,30 @@ files:
127
127
  - Rakefile
128
128
  - bin/cloud_test.rb
129
129
  - example/students_1/process/students.rb
130
+ - example/students_1/student_v1.md
130
131
  - example/students_1/students.rb
131
132
  - example/students_2/process/students.rb
133
+ - example/students_2/student_v2.md
132
134
  - example/students_2/students.rb
133
135
  - example/students_3/controller/yaml_students.rb
134
- - example/students_3/controller/yaml_students_controller.rb
136
+ - example/students_3/controller/yaml_students_code.rb
137
+ - example/students_3/controller/yaml_students_def.rb
135
138
  - example/students_3/process/students.rb
139
+ - example/students_3/student_v3.md
136
140
  - example/students_3/students.rb
141
+ - example/students_4/controller/yaml_students.rb
142
+ - example/students_4/controller/yaml_students_code.rb
143
+ - example/students_4/controller/yaml_students_def.rb
144
+ - example/students_4/process/students.rb
145
+ - example/students_4/process/students/code/students.rb
146
+ - example/students_4/process/students/definition/students.rb
147
+ - example/students_4/student_v4.md
148
+ - example/students_4/students.rb
149
+ - example/students_5/controller/yaml_students.rb
150
+ - example/students_5/controller/yaml_students_controller.rb
151
+ - example/students_5/process/students.rb
152
+ - example/students_5/student_v5.md
153
+ - example/students_5/students.rb
137
154
  - example/yaml_students/students.rb
138
155
  - example/yaml_students/yaml_students.rb
139
156
  - lib/concept.md
@@ -183,6 +200,7 @@ files:
183
200
  - lib/lorj_account.rb
184
201
  - lib/lorj_config.rb
185
202
  - lib/lorj_defaults.rb
203
+ - lib/overview.md
186
204
  - lib/prc.rb
187
205
  - lib/prc_base_config.rb
188
206
  - lib/prc_core_config.rb