lorj 0.2.0 → 1.0.0
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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +46 -0
- data/Gemfile +15 -15
- data/README.md +22 -17
- data/Rakefile +12 -2
- data/bin/cloud_test.rb +13 -65
- data/example/students_1/process/students.rb +39 -0
- data/example/students_1/students.rb +22 -5
- data/example/students_2/process/students.rb +48 -0
- data/example/students_2/students.rb +39 -16
- data/example/students_3/controller/yaml_students.rb +50 -43
- data/example/students_3/controller/yaml_students_controller.rb +100 -87
- data/example/students_3/process/students.rb +161 -97
- data/example/students_3/students.rb +85 -56
- data/example/yaml_students/students.rb +40 -40
- data/example/yaml_students/yaml_students.rb +103 -90
- data/lib/core/core.rb +356 -696
- data/lib/core/core_controller.rb +227 -0
- data/lib/core/core_internal.rb +339 -0
- data/lib/core/core_model.rb +328 -0
- data/lib/core/core_object_data.rb +330 -0
- data/lib/core/core_object_params.rb +230 -0
- data/lib/core/core_process.rb +391 -0
- data/lib/core/core_process_setup.rb +353 -0
- data/lib/core/core_setup_ask.rb +241 -0
- data/lib/core/core_setup_encrypt.rb +146 -0
- data/lib/core/core_setup_init.rb +229 -0
- data/lib/core/core_setup_list.rb +160 -0
- data/lib/core/definition.rb +647 -469
- data/lib/core/definition_internal.rb +264 -308
- data/lib/core/lorj_basecontroller.rb +95 -0
- data/lib/core/lorj_basedefinition.rb +307 -0
- data/lib/core/lorj_baseprocess.rb +265 -0
- data/lib/core/lorj_data.rb +583 -0
- data/lib/core/lorj_keypath.rb +119 -0
- data/lib/core_process/cloud/process/common.rb +63 -0
- data/lib/core_process/cloud/process/connection.rb +93 -0
- data/lib/core_process/cloud/process/external_network.rb +94 -0
- data/lib/core_process/cloud/process/flavor.rb +99 -0
- data/lib/core_process/cloud/process/images.rb +87 -0
- data/lib/core_process/cloud/process/internet_network.rb +34 -0
- data/lib/core_process/cloud/process/internet_server.rb +30 -0
- data/lib/core_process/cloud/process/keypairs.rb +276 -0
- data/lib/core_process/cloud/process/network.rb +108 -0
- data/lib/core_process/cloud/process/public_ip.rb +100 -0
- data/lib/core_process/cloud/process/router.rb +260 -0
- data/lib/core_process/cloud/process/rules.rb +120 -0
- data/lib/core_process/cloud/process/security_groups.rb +121 -0
- data/lib/core_process/cloud/process/server.rb +127 -0
- data/lib/core_process/cloud/process/server_log.rb +35 -0
- data/lib/core_process/cloud/process/subnetwork.rb +108 -0
- data/lib/core_process/cloud_process.rb +30 -0
- data/lib/logging.rb +298 -0
- data/lib/lorj/version.rb +18 -1
- data/lib/lorj.rb +58 -18
- data/lib/lorj_account.rb +556 -0
- data/lib/lorj_config.rb +468 -0
- data/lib/lorj_defaults.rb +278 -0
- data/lib/prc.rb +136 -104
- data/lib/prc_base_config.rb +285 -0
- data/lib/prc_core_config.rb +878 -0
- data/lib/prc_section_config.rb +57 -0
- data/lib/providers/hpcloud/compute.rb +81 -93
- data/lib/providers/hpcloud/hpcloud.rb +462 -0
- data/lib/providers/hpcloud/network.rb +96 -98
- data/lib/providers/hpcloud/security_groups.rb +41 -40
- data/lib/providers/mock/mock.rb +144 -0
- data/lib/providers/openstack/openstack.rb +45 -0
- data/lib/providers/templates/compute.rb +21 -23
- data/lib/providers/templates/mycloud.rb +72 -0
- data/lib/providers/templates/network.rb +11 -12
- data/lib/rh.rb +339 -0
- data/lorj-spec/defaults.yaml +4 -0
- data/lorj.gemspec +6 -0
- data/spec/00_lorj_log_spec.rb +53 -0
- data/spec/01_hash_rh_spec.rb +243 -0
- data/spec/02_prc_base_config_spec.rb +216 -0
- data/spec/04_prc_core_config_spec.rb +83 -0
- data/spec/11_lorj_config_spec.rb +263 -0
- data/spec/12_lorj_account_spec.rb +181 -0
- metadata +76 -28
- data/Gemfile.lock +0 -37
- data/example/students_1/process/Students.rb +0 -20
- data/example/students_2/process/Students.rb +0 -27
- data/example/students_4/controller/yaml_students.rb +0 -82
- data/example/students_4/controller/yaml_students_controller.rb +0 -141
- data/example/students_4/process/students.rb +0 -112
- data/example/students_4/students.rb +0 -103
- data/lib/core/lorj-basecontroller.rb +0 -90
- data/lib/core/lorj-basedefinition.rb +0 -1139
- data/lib/core/lorj-baseprocess.rb +0 -236
- data/lib/core/lorj-data.rb +0 -567
- data/lib/core/lorj-keypath.rb +0 -115
- data/lib/core_process/CloudProcess.rb +0 -337
- data/lib/core_process/global_process.rb +0 -502
- data/lib/core_process/network_process.rb +0 -605
- data/lib/prc-account.rb +0 -339
- data/lib/prc-config.rb +0 -1030
- data/lib/prc-logging.rb +0 -261
- data/lib/providers/hpcloud/Hpcloud.rb +0 -426
- data/lib/providers/mock/Mock.rb +0 -141
- data/lib/providers/openstack/Openstack.rb +0 -47
- data/lib/providers/templates/core.rb +0 -61
- data/spec/forj-account_spec.rb +0 -75
- data/spec/forj-config_spec.rb +0 -196
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
|
|
4
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
# require 'byebug'
|
|
19
|
+
|
|
20
|
+
$LOAD_PATH << File.join('..', 'lib')
|
|
21
|
+
|
|
22
|
+
require 'rh.rb'
|
|
23
|
+
require 'prc.rb'
|
|
24
|
+
require 'prc_base_config.rb' # Load PRC_core framework
|
|
25
|
+
|
|
26
|
+
describe 'class: PRC::BaseConfig,' do
|
|
27
|
+
context 'when creating a new instance' do
|
|
28
|
+
it 'should be loaded' do
|
|
29
|
+
config = PRC::BaseConfig.new
|
|
30
|
+
expect(config).to be
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should be initialized with Hash data.' do
|
|
34
|
+
config = PRC::BaseConfig.new(:test => :toto)
|
|
35
|
+
expect(config.data).to eq(:test => :toto)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context 'config[*keys] = value' do
|
|
40
|
+
before(:all) do
|
|
41
|
+
@config = PRC::BaseConfig.new
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'should be able to create a key/value in the config object.' do
|
|
45
|
+
@config[:test1] = 'value'
|
|
46
|
+
expect(@config.data).to eq(:test1 => 'value')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should be able to create a key tree/value in the config object.' do
|
|
50
|
+
@config[:test1, :test2] = 'value'
|
|
51
|
+
expect(@config.data).to eq(:test1 => { :test2 => 'value' })
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context 'config.del(*keys)' do
|
|
56
|
+
before(:all) do
|
|
57
|
+
@config = PRC::BaseConfig.new(:test1 => 'value',
|
|
58
|
+
:test2 => { :test2 => 'value' })
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'should be able to delete a key/value in the config object.' do
|
|
62
|
+
expect(@config.del(:test1)).to eq('value')
|
|
63
|
+
expect(@config.data).to eq(:test2 => { :test2 => 'value' })
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'should be able to delete a key/value in the config object.' do
|
|
67
|
+
expect(@config.del(:test2)).to eq(:test2 => 'value')
|
|
68
|
+
expect(@config.data).to eq({})
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context 'config[*keys]' do
|
|
73
|
+
before(:all) do
|
|
74
|
+
@config = PRC::BaseConfig.new(:test1 => { :test2 => 'value' })
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'with no parameter should return nil' do
|
|
78
|
+
expect(@config[]).to equal(nil)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "with keys = [:test1], should return {:test2 =>'value'}." do
|
|
82
|
+
expect(@config[:test1]).to eq(:test2 => 'value')
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "with keys = [:test1, :test2], should return {:test2 =>'value'}." do
|
|
86
|
+
expect(@config[:test1, :test2]).to eq('value')
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
context 'config.exist?(*keys)' do
|
|
91
|
+
before(:all) do
|
|
92
|
+
@config = PRC::BaseConfig.new(:test1 => { :test2 => 'value' })
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'with no parameter should return nil' do
|
|
96
|
+
expect(@config.exist?).to equal(nil)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'with keys = [test1], should return true.' do
|
|
100
|
+
expect(@config.exist?(:test1)).to equal(true)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'with keys = [:test1, :test2], should return true.' do
|
|
104
|
+
expect(@config.exist?(:test1, :test2)).to equal(true)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'with keys = [:test], should return false.' do
|
|
108
|
+
expect(@config.exist?(:test)).to equal(false)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'with keys = [:test1, :test], should return false.' do
|
|
112
|
+
expect(@config.exist?(:test1, :test)).to equal(false)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it 'with keys = [:test1, :test2, :test3], should return false.' do
|
|
116
|
+
expect(@config.exist?(:test1, :test2, :test3)).to equal(false)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
context "config.erase on :test1 => { :test2 => 'value' }" do
|
|
121
|
+
it 'with no parameter should return {} and cleanup internal data.' do
|
|
122
|
+
config = PRC::BaseConfig.new(:test1 => { :test2 => 'value' })
|
|
123
|
+
expect(config.erase).to eq({})
|
|
124
|
+
expect(config.data).to eq({})
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
context 'config.save and config.load' do
|
|
129
|
+
before(:all) do
|
|
130
|
+
@config = PRC::BaseConfig.new(:test1 => { :test2 => 'value' })
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it 'save with no parameter should fail' do
|
|
134
|
+
expect { @config.save }.to raise_error RuntimeError
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'save with filename set, save should true' do
|
|
138
|
+
file = '~/.lorj_rspec.yaml'
|
|
139
|
+
@config.filename = file
|
|
140
|
+
filename = File.expand_path(file)
|
|
141
|
+
|
|
142
|
+
expect(@config.filename).to eq(filename)
|
|
143
|
+
expect(@config.save).to equal(true)
|
|
144
|
+
|
|
145
|
+
File.delete(filename)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'save with filename given, returns true, and file saved.' do
|
|
149
|
+
file = '~/.lorj_rspec2.yaml'
|
|
150
|
+
old_file = @config.filename
|
|
151
|
+
filename = File.expand_path(file)
|
|
152
|
+
|
|
153
|
+
expect(@config.save(file)).to equal(true)
|
|
154
|
+
expect(@config.filename).not_to eq(old_file)
|
|
155
|
+
expect(@config.filename).to eq(filename)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it 'load returns true and file is loaded.' do
|
|
159
|
+
@config.erase
|
|
160
|
+
|
|
161
|
+
expect(@config.load).to equal(true)
|
|
162
|
+
expect(@config.data).to eq(:test1 => { :test2 => 'value' })
|
|
163
|
+
|
|
164
|
+
File.delete(@config.filename)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it 'load raises if file given is not found.' do
|
|
168
|
+
@config.erase
|
|
169
|
+
|
|
170
|
+
expect { @config.load('~/.lorj_rspec.yaml') }.to raise_error
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
context 'config.data_options(options)' do
|
|
175
|
+
it 'with no parameter should return {} ie no options.' do
|
|
176
|
+
config = PRC::BaseConfig.new
|
|
177
|
+
expect(config.data_options).to eq({})
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it 'with :readonly => true should return {} ie no options.' do
|
|
181
|
+
config = PRC::BaseConfig.new
|
|
182
|
+
expect(config.data_options(:readonly => true)).to eq(:readonly => true)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it 'with any unknown options like :section => "test" should return '\
|
|
186
|
+
'{:section => "test"}.' do
|
|
187
|
+
config = PRC::BaseConfig.new
|
|
188
|
+
expect(config.data_options(:section => 'test')).to eq(:section => 'test')
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it 'with any existing options set we replace it all.' do
|
|
192
|
+
config = PRC::BaseConfig.new
|
|
193
|
+
config.data_options(:section => 'test')
|
|
194
|
+
expect(config.data_options(:toto => 'tata')).to eq(:toto => 'tata')
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it 'with :data_readonly => true, we cannot set a data.' do
|
|
198
|
+
config = PRC::BaseConfig.new(:test => 'toto')
|
|
199
|
+
config.data_options(:data_readonly => true)
|
|
200
|
+
config[:test] = 'titi'
|
|
201
|
+
expect(config.data).to eq(:test => 'toto')
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it 'with :file_readonly => true, we cannot save data to a file.' do
|
|
205
|
+
config = PRC::BaseConfig.new(:test => 'toto')
|
|
206
|
+
file = '~/.rspec_test.yaml'
|
|
207
|
+
file_path = File.expand_path(file)
|
|
208
|
+
config.data_options(:file_readonly => true)
|
|
209
|
+
system('rm -f ~/.rspec_test.yaml')
|
|
210
|
+
expect(config.save(file)).to equal(false)
|
|
211
|
+
expect(config.filename).to equal(nil)
|
|
212
|
+
expect { config.load(file) }.to raise_error
|
|
213
|
+
expect(config.filename).to eq(file_path)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
|
|
4
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
# require 'byebug'
|
|
19
|
+
|
|
20
|
+
$LOAD_PATH << File.join('..', 'lib')
|
|
21
|
+
|
|
22
|
+
require 'rh.rb'
|
|
23
|
+
require 'prc.rb'
|
|
24
|
+
require 'prc_base_config.rb'
|
|
25
|
+
require 'prc_core_config.rb'
|
|
26
|
+
|
|
27
|
+
describe 'class: PRC::CoreConfig,' do
|
|
28
|
+
context 'when creating a new instance' do
|
|
29
|
+
before(:all) do
|
|
30
|
+
@config = PRC::CoreConfig.new
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should be loaded' do
|
|
34
|
+
expect(@config).to be
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'runtime set works' do
|
|
38
|
+
expect(@config[:test] = :toto).to eq(:toto)
|
|
39
|
+
expect(@config.exist?(:test)).to eq(true)
|
|
40
|
+
expect(@config[:test]).to eq(:toto)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context 'from a child class, with local layer set to :test => :found_local'\
|
|
45
|
+
' and runtime layer' do
|
|
46
|
+
before(:all) do
|
|
47
|
+
# Child class definition for rSpec.
|
|
48
|
+
class Test1 < PRC::CoreConfig
|
|
49
|
+
def initialize
|
|
50
|
+
local = PRC::BaseConfig.new(:test => :found_local)
|
|
51
|
+
layers = []
|
|
52
|
+
layers << PRC::CoreConfig.define_layer(:name => 'local',
|
|
53
|
+
:config => local)
|
|
54
|
+
layers << PRC::CoreConfig.define_layer # runtime
|
|
55
|
+
|
|
56
|
+
initialize_layers(layers)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
@config = Test1.new
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'should be loaded' do
|
|
63
|
+
expect(@config).to be
|
|
64
|
+
expect(@config.layers).to eq(%w(runtime local))
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'config.where?(:test) should be ["local"]' do
|
|
68
|
+
expect(@config.where?(:test)).to eq(['local'])
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'config.[:test] = :where set in "runtime".' do
|
|
72
|
+
expect(@config[:test] = :where).to eq(:where)
|
|
73
|
+
expect(@config.where?(:test)).to eq(%w(runtime local))
|
|
74
|
+
expect(@config[:test]).to equal(:where)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'config.del(:test) remove the data from runtime, '\
|
|
78
|
+
'and restore from local.' do
|
|
79
|
+
expect(@config.del(:test)).to eq(:where)
|
|
80
|
+
expect(@config[:test]).to equal(:found_local)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
|
|
4
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
app_path = File.dirname(__FILE__)
|
|
19
|
+
|
|
20
|
+
$LOAD_PATH << File.join('..', 'lib')
|
|
21
|
+
|
|
22
|
+
require 'lorj' # Load lorj framework
|
|
23
|
+
|
|
24
|
+
describe 'class: Lorj::Config,' do
|
|
25
|
+
context 'new instance, with no default local config files, ' do
|
|
26
|
+
before(:all) do
|
|
27
|
+
PrcLib.log_file = 'lorj-rspec.log'
|
|
28
|
+
PrcLib.level = Logger::FATAL
|
|
29
|
+
PrcLib.app_name = 'lorj-spec'
|
|
30
|
+
PrcLib.app_defaults = File.expand_path(File.join(app_path, '..',
|
|
31
|
+
'lorj-spec'))
|
|
32
|
+
@local = File.join(PrcLib.data_path, 'config.yaml')
|
|
33
|
+
File.delete(@local) if File.exist?(@local)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should be loaded' do
|
|
37
|
+
expect(File.exist?(@local)).to equal(false)
|
|
38
|
+
config = Lorj::Config.new
|
|
39
|
+
expect(config).to be
|
|
40
|
+
end
|
|
41
|
+
it 'local config file gets created.' do
|
|
42
|
+
expect(File.exist?(@local)).to equal(true)
|
|
43
|
+
end
|
|
44
|
+
it 'local config is empty.' do
|
|
45
|
+
expect(YAML.load_file(@local)).to eq(:default => nil)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context 'CoreConfig original functions,' do
|
|
50
|
+
before(:all) do
|
|
51
|
+
@config = Lorj::Config.new
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'config.file return nil. (runtime)' do
|
|
55
|
+
expect(@config.file).to equal(nil)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "config.file(nil, :name => 'local') return local config file." do
|
|
59
|
+
file = File.join(PrcLib.data_path, 'config.yaml')
|
|
60
|
+
expect(@config.file(nil, :name => 'local')).to eq(file)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "config.file(nil, :name => 'default') return default "\
|
|
64
|
+
'application file.' do
|
|
65
|
+
file = File.join(PrcLib.app_defaults, 'defaults.yaml')
|
|
66
|
+
expect(@config.file(nil, :name => 'default')).to eq(file)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'config.layers returns all config names.' do
|
|
70
|
+
expect(@config.layers).to eq(%w(runtime local default))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'config.where?(:test1) return false' do
|
|
74
|
+
expect(@config.where?(:test1)).to equal(false)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'config.exist?(:test1) returns false' do
|
|
78
|
+
expect(@config.exist?(:test1)).to equal(false)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "config.where?(:maestro_url) return ['defaults'] "\
|
|
82
|
+
'(see lorj-spec/defaults.yaml)' do
|
|
83
|
+
expect(@config.where?(:maestro_url)).to eq(['default'])
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'config.exist?(:maestro_url) returns true' do
|
|
87
|
+
expect(@config.exist?(:maestro_url)).to equal(true)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
context 'redefined CoreConfig functions' do
|
|
92
|
+
before(:all) do
|
|
93
|
+
@config = Lorj::Config.new
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "config[:maestro_url] returns 'http://example.org'" do
|
|
97
|
+
expect(@config[:maestro_url]).to eq('http://example.org')
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "config.get(:maestro_url) returns 'http://example.org'" do
|
|
101
|
+
expect(@config.get(:maestro_url)).to eq('http://example.org')
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'config[:test1, :none] returns :none' do
|
|
105
|
+
expect(@config[:test1, :none]).to equal(:none)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "config[:maestro_url, :none] returns 'http://example.org'" do
|
|
109
|
+
expect(@config[:maestro_url, :none]).to eq('http://example.org')
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'config[:maestro_url] = :none returns :none' do
|
|
113
|
+
expect(@config[:maestro_url] = :none).to eq(:none)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'config[:maestro_url, :none] returns :none' do
|
|
117
|
+
expect(@config[:maestro_url]).to eq(:none)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'config.where?(:maestro_url) returns [runtime, default]' do
|
|
121
|
+
expect(@config.where?(:maestro_url)).to eq(%w(runtime default))
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'config.del(:maestro_url) returns :none' do
|
|
125
|
+
expect(@config.del(:maestro_url)).to eq(:none)
|
|
126
|
+
end
|
|
127
|
+
it 'config.where?(:maestro_url) now returns [default]' do
|
|
128
|
+
expect(@config.where?(:maestro_url)).to eq(%w(default))
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it 'config.set(:maestro_url, :none) is equivalent as '\
|
|
132
|
+
'config[:maestro_url] = :none' do
|
|
133
|
+
expect(@config.set(:maestro_url, :none)).to eq(:none)
|
|
134
|
+
expect(@config.where?(:maestro_url)).to eq(%w(runtime default))
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
context 'Lorj::Config specific functions' do
|
|
139
|
+
before(:all) do
|
|
140
|
+
@config = Lorj::Config.new
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it 'config.config_filename is identical than '\
|
|
144
|
+
"config.file(nil, :name => 'local')" do
|
|
145
|
+
file = @config.file(nil, :name => 'local')
|
|
146
|
+
expect(@config.config_filename).to eq(file)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "config.config_filename('default') is identical than "\
|
|
150
|
+
"config.file(nil, :name => 'default')" do
|
|
151
|
+
file = @config.file(nil, :name => 'default')
|
|
152
|
+
expect(@config.config_filename('default')).to eq(file)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "config.file('test2.yaml', 'runtime') returns false - not authorized." do
|
|
156
|
+
expect(@config.file('test2.yaml', :name => 'runtime')).to equal(false)
|
|
157
|
+
expect(@config.config_filename('runtime')).to equal(nil)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "config.file('test2.yaml', 'local') returns false - not authorized." do
|
|
161
|
+
expect(@config.file('test2.yaml', :name => 'local')).to equal(false)
|
|
162
|
+
file = File.join(PrcLib.data_path, 'config.yaml')
|
|
163
|
+
expect(@config.config_filename).to eq(file)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it "config.file('test2.yaml', 'default') returns false - not authorized." do
|
|
167
|
+
expect(@config.file('test2.yaml', :name => 'default')).to equal(false)
|
|
168
|
+
file = File.join(PrcLib.app_defaults, 'defaults.yaml')
|
|
169
|
+
expect(@config.config_filename('default')).to eq(file)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it 'config.local_exist?(:test1) returns false' do
|
|
173
|
+
expect(@config.local_exist?(:test1)).to equal(false)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "config.local_set(:test1, 'value') returns 'value' and saved in"\
|
|
177
|
+
" 'local' config" do
|
|
178
|
+
expect(@config.local_set(:test1, 'value')).to eq('value')
|
|
179
|
+
expect(@config.where?(:test1)).to eq(%w(local))
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it 'config.local_exist?(:test1) returns true' do
|
|
183
|
+
expect(@config.local_exist?(:test1)).to equal(true)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it "config.local_get(:test1) returns 'value'" do
|
|
187
|
+
expect(@config.local_get(:test1)).to eq('value')
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it 'config.save_local_config returns true and is really saved.' do
|
|
191
|
+
config = Lorj::Config.new
|
|
192
|
+
expect(config.where?(:test1)).to equal(false)
|
|
193
|
+
expect(@config.save_local_config).to equal(true)
|
|
194
|
+
config2 = Lorj::Config.new
|
|
195
|
+
expect(config2.where?(:test1)).to eq(%w(local))
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it "config.local_del(:test1) returns 'value'" do
|
|
199
|
+
expect(@config.local_del(:test1)).to eq('value')
|
|
200
|
+
expect(@config.where?(:test1)).to equal(false)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
it 'default_dump return all in a Hash' do
|
|
204
|
+
default_file = @config.config_filename('default')
|
|
205
|
+
default = YAML.load_file(default_file)
|
|
206
|
+
|
|
207
|
+
res = { 'local' => { :default => {} },
|
|
208
|
+
'default' => default
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
expect(@config.config_dump).to eq(res)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it 'config.get_section(:maestro_url) returns :maestro' do
|
|
215
|
+
expect(@config.get_section(:maestro_url)).to equal(:maestro)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it 'config.get_section(:test1, :default) returns :default' do
|
|
219
|
+
expect(@config.get_section(:test1)).to equal(nil)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it 'config.runtime_exist?(:test1) returns false - no :test1 available in '\
|
|
223
|
+
'runtime.' do
|
|
224
|
+
expect(@config.runtime_exist?(:test1)).to equal(false)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
context 'setting :test1 => :value,' do
|
|
228
|
+
before(:all) do
|
|
229
|
+
@config[:test1] = :value
|
|
230
|
+
end
|
|
231
|
+
it 'config.runtime_get(:test1) returns :value' do
|
|
232
|
+
expect(@config.runtime_get(:test1)).to equal(:value)
|
|
233
|
+
end
|
|
234
|
+
it 'config.runtime_exist?(:test1) returns true' do
|
|
235
|
+
expect(@config.runtime_exist?(:test1)).to equal(true)
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
context 'app default functions' do
|
|
239
|
+
before(:all) do
|
|
240
|
+
default_file = @config.config_filename('default')
|
|
241
|
+
@default = YAML.load_file(default_file)
|
|
242
|
+
end
|
|
243
|
+
it 'config.app_default(:default) returns :default of defaults.yaml' do
|
|
244
|
+
expect(@config.app_default(:default)).to eq(@default[:default])
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
it 'config.app_default(:sections) returns :section of defaults.yaml' do
|
|
248
|
+
expect(@config.app_default(:sections)).to eq(@default[:sections])
|
|
249
|
+
end
|
|
250
|
+
it 'config.meta_each provides the wanted list of section/key/values' do
|
|
251
|
+
# The defaults.yaml MUST have data exclusive set to true
|
|
252
|
+
expect(@default.rh_get(:sections, :credentials, :data,
|
|
253
|
+
:account_exclusive)).to equal(true)
|
|
254
|
+
@config.meta_each do | section, key, value |
|
|
255
|
+
expect(@default.rh_exist?(:sections, section, key)).to equal(true)
|
|
256
|
+
expect(@default.rh_get(:sections, section, key)).to equal(value)
|
|
257
|
+
expect([section, key,
|
|
258
|
+
value]).not_to eq([:sections, :credentials, :data])
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
end
|