lorj 1.0.8 → 1.0.9
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/lib/core/core_setup_init.rb +6 -0
- data/lib/core/lorj_basedefinition.rb +0 -14
- data/lib/core/lorj_keypath.rb +7 -0
- data/lib/core_process/cloud/process/keypairs.rb +19 -0
- data/lib/core_process/cloud_process.rb +1 -1
- data/lib/lorj/version.rb +1 -1
- data/lib/lorj_account.rb +44 -12
- data/lib/lorj_defaults.rb +63 -14
- data/lib/prc_base_config.rb +13 -4
- data/lib/prc_core_config.rb +26 -0
- data/lib/providers/hpcloud/hpcloud.rb +3 -3
- data/lorj-spec/defaults.yaml +6 -0
- data/spec/02_prc_base_config_spec.rb +11 -0
- data/spec/04_prc_core_config_spec.rb +22 -0
- data/spec/{21_lorj_defaults_spec.rb → 11_lorj_defaults_spec.rb} +32 -1
- data/spec/{11_lorj_config_spec.rb → 12_lorj_config_spec.rb} +6 -1
- data/spec/{12_lorj_account_spec.rb → 13_lorj_account_spec.rb} +0 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a783a3bdefa0193225dbdeeffa904220c3e212
|
4
|
+
data.tar.gz: b5d15179e5989d20e02dec91bcb5f6fd6cafb530
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed18aa7febd8d02e4e5d31bfa9b99407a40f5bc80a97d237bd0696281be2e330756e08d276fb4b77c7e6d90db239e569eb3fea4f661cffd0880ab04a89cb3bc1
|
7
|
+
data.tar.gz: 3c553c66bd2b48a15e0652c8b18c28ce2bafb4a7c37a47b3fef1712f71dccd761fed8ff992aedf41c8f9e89e9db3a8b230191bd38a6947cf137f9b4575f08ae0
|
data/lib/core/core_setup_init.rb
CHANGED
@@ -217,14 +217,20 @@ module Lorj
|
|
217
217
|
options = _get_meta_data(data)
|
218
218
|
options = {} if options.nil?
|
219
219
|
|
220
|
+
Lorj.data.layer_add(:name => :setup)
|
221
|
+
|
220
222
|
if options[:pre_step_function]
|
221
223
|
proc = options[:pre_step_function]
|
222
224
|
next unless @process.method(proc).call(data)
|
225
|
+
# Get any update from pre_step_function
|
226
|
+
options = _get_meta_data(data)
|
223
227
|
end
|
224
228
|
|
225
229
|
data_desc = _setup_display_data(data, options)
|
226
230
|
|
227
231
|
_setup_ask_data(data_desc, data, options)
|
232
|
+
|
233
|
+
Lorj.data.layer_remove(:name => :setup)
|
228
234
|
end
|
229
235
|
end
|
230
236
|
end
|
@@ -18,20 +18,6 @@
|
|
18
18
|
# Lorj::BaseDefinition
|
19
19
|
#
|
20
20
|
module Lorj
|
21
|
-
# This class limits ERC template to access only to config object data.
|
22
|
-
class ERBConfig
|
23
|
-
attr_reader :config
|
24
|
-
|
25
|
-
def initialize(config)
|
26
|
-
@config = config
|
27
|
-
end
|
28
|
-
|
29
|
-
# Bind this limited class with ERB templates
|
30
|
-
def get_binding # rubocop: disable AccessorMethodName
|
31
|
-
binding
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
21
|
# Following class defines class levels function to
|
36
22
|
# declare framework objects.
|
37
23
|
# As each process needs to define new object to deal with
|
data/lib/core/lorj_keypath.rb
CHANGED
@@ -38,6 +38,7 @@ module Lorj
|
|
38
38
|
# puts oKey.key[1] # => nil
|
39
39
|
# puts oKey.fpath # => ':test'
|
40
40
|
# puts oKey.tree # => [:test]
|
41
|
+
# puts oKey.key_tree # => :test
|
41
42
|
#
|
42
43
|
# oKey = KeyPath([:test,:test2,:test3])
|
43
44
|
# puts oKey.to_s # => 'test/test2/test3'
|
@@ -46,6 +47,7 @@ module Lorj
|
|
46
47
|
# puts oKey.key[1] # => :test2
|
47
48
|
# puts oKey.fpath # => ':test/:test2/:test3'
|
48
49
|
# puts oKey.tree # => [:test,:test2,:test3]
|
50
|
+
# puts oKey.key_tree # => ':test/:test2/:test3'
|
49
51
|
#
|
50
52
|
class KeyPath
|
51
53
|
def initialize(sKeyPath = nil, max_level = -1)
|
@@ -74,6 +76,11 @@ module Lorj
|
|
74
76
|
@keypath
|
75
77
|
end
|
76
78
|
|
79
|
+
def key_tree
|
80
|
+
return @keypath[0] if @keypath.length == 1
|
81
|
+
fpath
|
82
|
+
end
|
83
|
+
|
77
84
|
def fpath
|
78
85
|
return nil if @keypath.length == 0
|
79
86
|
key_access = @keypath.clone
|
@@ -129,6 +129,21 @@ class CloudProcess
|
|
129
129
|
private_key_file) if keypair[:private_key_exist?]
|
130
130
|
PrcLib.info("Found openssh public key file '%s'.",
|
131
131
|
public_key_file) if keypair[:public_key_exist?]
|
132
|
+
|
133
|
+
unless keypair[:public_key_exist?]
|
134
|
+
name = keypair[:name]
|
135
|
+
PrcLib.warning("The local public key file '%s' is missing.\n"\
|
136
|
+
"As the keypair name '%s' already exists in your cloud, "\
|
137
|
+
'you will need to get the original SSH keypair files '\
|
138
|
+
"used to create the keypair name '%s'. Otherwise, you "\
|
139
|
+
"won't be able to use it to connect to a box configured"\
|
140
|
+
" with '%s'."\
|
141
|
+
"\nPublic key found in the cloud:\n%s",
|
142
|
+
public_key_file, name, name, name,
|
143
|
+
keypair[:public_key])
|
144
|
+
return
|
145
|
+
end
|
146
|
+
|
132
147
|
if keypair[:coherent]
|
133
148
|
PrcLib.info("keypair '%s' local files are coherent with keypair in "\
|
134
149
|
'your cloud service. You will be able to use your local '\
|
@@ -142,7 +157,10 @@ class CloudProcess
|
|
142
157
|
public_key_file, keypair[:name], keypair[:public_key])
|
143
158
|
end
|
144
159
|
end
|
160
|
+
end
|
145
161
|
|
162
|
+
# Keypair management: Internal process functions
|
163
|
+
class CloudProcess
|
146
164
|
# Function to update a keypair object with ssh files found in :keypair_path
|
147
165
|
#
|
148
166
|
def keypair_files_detected(keypair, loc_kpair)
|
@@ -293,6 +311,7 @@ class CloudProcess
|
|
293
311
|
|
294
312
|
# Check the public key with the one found here, locally.
|
295
313
|
if !pub_keypair.nil? && pub_keypair != ''
|
314
|
+
return false unless loc_kpair[:public_key_exist?]
|
296
315
|
begin
|
297
316
|
loc_pubkey = File.read(File.join(loc_kpair[:keypair_path],
|
298
317
|
loc_kpair[:public_key_name]))
|
data/lib/lorj/version.rb
CHANGED
data/lib/lorj_account.rb
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
|
18
18
|
require 'rubygems'
|
19
19
|
|
20
|
+
require 'erb'
|
21
|
+
|
20
22
|
# Lorj implements Lorj::Accounts
|
21
23
|
module Lorj
|
22
24
|
# Simple List of accounts class.
|
@@ -27,6 +29,8 @@ module Lorj
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def dump
|
32
|
+
return [] unless File.directory?(@account_path)
|
33
|
+
|
30
34
|
accounts = []
|
31
35
|
Dir.foreach(@account_path) do |x|
|
32
36
|
accounts << x unless x.match(/^\..?$/)
|
@@ -55,6 +59,22 @@ module Lorj
|
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
62
|
+
module Lorj
|
63
|
+
# This class limits ERB template to access only to config object data.
|
64
|
+
class ERBConfig
|
65
|
+
attr_reader :config
|
66
|
+
|
67
|
+
def initialize(config)
|
68
|
+
@config = config
|
69
|
+
end
|
70
|
+
|
71
|
+
# Bind this limited class with ERB templates
|
72
|
+
def get_binding # rubocop: disable AccessorMethodName
|
73
|
+
binding
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
58
78
|
# Lorj implements Lorj::Account
|
59
79
|
module Lorj
|
60
80
|
# Lorj::Account manage a list of key/value grouped by section.
|
@@ -154,6 +174,8 @@ module Lorj
|
|
154
174
|
# :account_exclusive => true, get will limit to runtime then account.
|
155
175
|
# otherwise, search in all layers.
|
156
176
|
#
|
177
|
+
# The data found is parse through ERB with self as context.
|
178
|
+
#
|
157
179
|
# * *Args* :
|
158
180
|
# - +key+ : key name. It do not support it to be a key tree (Arrays of
|
159
181
|
# keys).
|
@@ -183,10 +205,13 @@ module Lorj
|
|
183
205
|
names = []
|
184
206
|
indexes.each { |index| names << @config_layers[index][:name] }
|
185
207
|
|
186
|
-
options[:data_options] = _set_data_options_per_names(names)
|
187
|
-
|
188
|
-
return p_get(options) if p_exist?(options)
|
208
|
+
options[:data_options] = _set_data_options_per_names(names, section)
|
189
209
|
|
210
|
+
if p_exist?(options)
|
211
|
+
value = p_get(options)
|
212
|
+
return value unless value.is_a?(String)
|
213
|
+
return ERB.new(value).result ERBConfig.new(self).get_binding
|
214
|
+
end
|
190
215
|
default
|
191
216
|
end
|
192
217
|
|
@@ -232,7 +257,7 @@ module Lorj
|
|
232
257
|
:keys => [key],
|
233
258
|
:section => section,
|
234
259
|
:indexes => indexes,
|
235
|
-
:data_options => _set_data_options_per_names(names)
|
260
|
+
:data_options => _set_data_options_per_names(names, section)
|
236
261
|
}
|
237
262
|
|
238
263
|
p_where?(where_options)
|
@@ -275,7 +300,7 @@ module Lorj
|
|
275
300
|
names = []
|
276
301
|
indexes.each { |index| names << @config_layers[index][:name] }
|
277
302
|
|
278
|
-
options[:data_options] = _set_data_options_per_names(names)
|
303
|
+
options[:data_options] = _set_data_options_per_names(names, section)
|
279
304
|
|
280
305
|
p_exist?(options)
|
281
306
|
end
|
@@ -563,30 +588,37 @@ module Lorj
|
|
563
588
|
indexes
|
564
589
|
end
|
565
590
|
|
566
|
-
def _set_data_options_per_names(names)
|
591
|
+
def _set_data_options_per_names(names, section)
|
567
592
|
data_options = []
|
568
593
|
|
569
|
-
names.each
|
594
|
+
names.each do |name|
|
595
|
+
data_options << _data_options_per_layer(name, section)
|
596
|
+
end
|
570
597
|
|
571
598
|
data_options
|
572
599
|
end
|
573
600
|
|
574
|
-
# TODO: Change local and default way to get default values, not in /:default
|
575
|
-
|
576
601
|
# This internal function defines default section name per config index.
|
577
|
-
def _data_options_per_layer(layer_name)
|
602
|
+
def _data_options_per_layer(layer_name, section)
|
578
603
|
# runtime and local and default uses :default section
|
579
604
|
case layer_name
|
580
|
-
when '
|
605
|
+
when 'default'
|
606
|
+
return { :section => :default, :metadata_section => section }
|
607
|
+
when 'local'
|
581
608
|
# local & default are SectionConfig and is forced to use :default as
|
582
609
|
# section name for each data.
|
583
|
-
{ :section => :default }
|
610
|
+
return { :section => :default }
|
584
611
|
end
|
585
612
|
# nil: layer_index = 0 => runtime. runtime is not a SectionConfig.
|
586
613
|
|
587
614
|
# nil: layer_index = 1 => account
|
615
|
+
# If no section is provided, 'account' layer will use the first section
|
616
|
+
# name
|
617
|
+
# otherwise, it will used the section provided.
|
618
|
+
return { :section => section } unless section.nil?
|
588
619
|
# account is a SectionConfig and use section value defined by the
|
589
620
|
# lorj data model. So the section name is not forced.
|
621
|
+
nil
|
590
622
|
end
|
591
623
|
|
592
624
|
def _do_load(config, account_file)
|
data/lib/lorj_defaults.rb
CHANGED
@@ -60,21 +60,70 @@ module Lorj
|
|
60
60
|
# and eventually :default:
|
61
61
|
# For details, see Lorj::MetaAppConfig
|
62
62
|
#
|
63
|
-
# :setup: This section describes group of fields to ask,
|
64
|
-
# step by step.
|
65
|
-
# :ask_step: Define an Array of setup steps to ask to the
|
66
|
-
# end user. The step order is respected, and
|
67
|
-
# start at 0
|
68
|
-
# - :desc: Define the step description. ERB template
|
69
|
-
# enable. To get config data, type config[...]
|
70
|
-
# :explanation: |- Define a multiline explanation. This is printed
|
71
|
-
# out in brown color.
|
72
|
-
# ERB template enable. To get config data, type
|
73
|
-
# <%= config[...] %>
|
74
|
-
# :add: Define a list of additionnal fields to ask.
|
75
|
-
# - <Data> Data to ask.
|
76
|
-
#
|
77
63
|
class Defaults < PRC::SectionConfig
|
64
|
+
# Get function
|
65
|
+
# It implements the following:
|
66
|
+
# 1. Search in data_options[:section] section or :default section if missing
|
67
|
+
# 2. otherwise, provide the metadata default value, erb like.
|
68
|
+
# It uses data_options[:metadata_section]
|
69
|
+
#
|
70
|
+
# * *Args*
|
71
|
+
# - +keys+ : Array of key path to found
|
72
|
+
#
|
73
|
+
# * *Returns*
|
74
|
+
# - value
|
75
|
+
#
|
76
|
+
def [](*keys)
|
77
|
+
return nil if keys.length == 0
|
78
|
+
|
79
|
+
if @data_options[:section].nil?
|
80
|
+
section = :default
|
81
|
+
else
|
82
|
+
section = @data_options[:section]
|
83
|
+
end
|
84
|
+
|
85
|
+
return p_get(section, *keys) if p_exist?(section, *keys)
|
86
|
+
|
87
|
+
metadata_section = @data_options[:metadata_section]
|
88
|
+
|
89
|
+
return nil if metadata_section.nil?
|
90
|
+
default = Lorj.data.section_data(metadata_section, keys[0],
|
91
|
+
:default_value)
|
92
|
+
return nil if default.nil?
|
93
|
+
default
|
94
|
+
end
|
95
|
+
|
96
|
+
# Check if data found in this default layer has a value.
|
97
|
+
#
|
98
|
+
# It implements the following:
|
99
|
+
# 1. Search in data_options[:section] section or :default section if missing
|
100
|
+
# 2. otherwise, provide the metadata default value, erb like.
|
101
|
+
# It uses data_options[:metadata_section]
|
102
|
+
#
|
103
|
+
# * *Args*
|
104
|
+
# - +keys+ : Array of key path to found
|
105
|
+
#
|
106
|
+
# * *Returns*
|
107
|
+
# - boolean : true if the key path was found
|
108
|
+
#
|
109
|
+
def exist?(*keys)
|
110
|
+
return nil if keys.length == 0
|
111
|
+
|
112
|
+
if @data_options[:section].nil?
|
113
|
+
section = :default
|
114
|
+
else
|
115
|
+
section = @data_options[:section]
|
116
|
+
end
|
117
|
+
|
118
|
+
return true if p_exist?(section, *keys)
|
119
|
+
|
120
|
+
metadata_section = @data_options[:metadata_section]
|
121
|
+
|
122
|
+
return false if metadata_section.nil?
|
123
|
+
|
124
|
+
Lorj.data.exist?(:sections, metadata_section, keys[0], :default_value)
|
125
|
+
end
|
126
|
+
|
78
127
|
# Remove inherited method []=
|
79
128
|
def []=(*_keys, _value)
|
80
129
|
end
|
data/lib/prc_base_config.rb
CHANGED
@@ -42,6 +42,9 @@ module PRC
|
|
42
42
|
# * *get*: get the config file name used by #load and #save.
|
43
43
|
attr_accessor :filename
|
44
44
|
|
45
|
+
# config layer version
|
46
|
+
attr_accessor :version
|
47
|
+
|
45
48
|
# initialize BaseConfig
|
46
49
|
#
|
47
50
|
# * *Args*
|
@@ -114,14 +117,13 @@ module PRC
|
|
114
117
|
p_exist?(*keys)
|
115
118
|
end
|
116
119
|
|
117
|
-
# Erase
|
118
|
-
#
|
119
|
-
# * *Args*
|
120
|
+
# Erase the data in the object. internal version is cleared as well.
|
120
121
|
#
|
121
122
|
# * *Returns*
|
122
|
-
# -
|
123
|
+
# - Hash : {}.
|
123
124
|
#
|
124
125
|
def erase
|
126
|
+
@version = nil
|
125
127
|
@data = {}
|
126
128
|
end
|
127
129
|
|
@@ -275,6 +277,10 @@ module PRC
|
|
275
277
|
fail 'Config filename not set.' if @filename.nil?
|
276
278
|
|
277
279
|
@data = YAML.load_file(File.expand_path(@filename))
|
280
|
+
if @data.key?(:file_version)
|
281
|
+
@version = @data[:file_version]
|
282
|
+
@data.delete(:file_version)
|
283
|
+
end
|
278
284
|
true
|
279
285
|
end
|
280
286
|
|
@@ -284,6 +290,9 @@ module PRC
|
|
284
290
|
|
285
291
|
fail 'Config filename not set.' if @filename.nil?
|
286
292
|
|
293
|
+
@data.delete(:file_version)
|
294
|
+
@data[:file_version] = @version unless @version.nil?
|
295
|
+
|
287
296
|
File.open(@filename, 'w+') { |out| YAML.dump(@data, out) }
|
288
297
|
true
|
289
298
|
end
|
data/lib/prc_core_config.rb
CHANGED
@@ -1186,6 +1186,32 @@ module PRC
|
|
1186
1186
|
be_exclusive)
|
1187
1187
|
end
|
1188
1188
|
|
1189
|
+
# Function to get the version of a config layer name.
|
1190
|
+
# * *Args*
|
1191
|
+
# - +:name+ : layer to get data.
|
1192
|
+
#
|
1193
|
+
def version(name)
|
1194
|
+
return nil unless name.is_a?(String)
|
1195
|
+
|
1196
|
+
index = layer_index(name)
|
1197
|
+
return nil if index.nil?
|
1198
|
+
|
1199
|
+
@config_layers[index][:config].version
|
1200
|
+
end
|
1201
|
+
|
1202
|
+
# Function to set the version of a config layer name.
|
1203
|
+
# * *Args*
|
1204
|
+
# - +:name+ : layer to set data version.
|
1205
|
+
#
|
1206
|
+
def version_set(name, version)
|
1207
|
+
return nil unless name.is_a?(String) && version.is_a?(String)
|
1208
|
+
|
1209
|
+
index = layer_index(name)
|
1210
|
+
return nil if index.nil?
|
1211
|
+
|
1212
|
+
@config_layers[index][:config].version = version
|
1213
|
+
end
|
1214
|
+
|
1189
1215
|
# List all config layers defined in this instance.
|
1190
1216
|
def layers
|
1191
1217
|
result = []
|
@@ -21,9 +21,9 @@ require 'fog' # We use fog to access HPCloud
|
|
21
21
|
|
22
22
|
hpcloud_path = File.expand_path(File.dirname(__FILE__))
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
load File.join(hpcloud_path, 'compute.rb')
|
25
|
+
load File.join(hpcloud_path, 'network.rb')
|
26
|
+
load File.join(hpcloud_path, 'security_groups.rb')
|
27
27
|
|
28
28
|
# Defines Meta HPCloud object
|
29
29
|
class Hpcloud
|
data/lorj-spec/defaults.yaml
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
:maestro_url: http://example.org
|
18
18
|
:keypair_name: default_key
|
19
19
|
:data: None
|
20
|
+
:default_case2: 'success'
|
20
21
|
:description:
|
21
22
|
:FORJ_HPC: Testing extra application default value.
|
22
23
|
:setup:
|
@@ -34,3 +35,8 @@
|
|
34
35
|
:account_exclusive: true
|
35
36
|
:maestro:
|
36
37
|
:maestro_url:
|
38
|
+
:lorj_default:
|
39
|
+
:default_case:
|
40
|
+
:default_value: 'success'
|
41
|
+
:default_case2:
|
42
|
+
:default_value: 'incorrect - meta-default value'
|
@@ -50,6 +50,12 @@ describe 'class: PRC::BaseConfig,' do
|
|
50
50
|
@config[:test1, :test2] = 'value'
|
51
51
|
expect(@config.data).to eq(:test1 => { :test2 => 'value' })
|
52
52
|
end
|
53
|
+
|
54
|
+
it 'version = "0.1" can be set and get' do
|
55
|
+
expect(@config.version).to equal(nil)
|
56
|
+
@config.version = '0.1'
|
57
|
+
expect(@config.version).to eq('0.1')
|
58
|
+
end
|
53
59
|
end
|
54
60
|
|
55
61
|
context 'config.del(*keys)' do
|
@@ -120,8 +126,11 @@ describe 'class: PRC::BaseConfig,' do
|
|
120
126
|
context "config.erase on :test1 => { :test2 => 'value' }" do
|
121
127
|
it 'with no parameter should return {} and cleanup internal data.' do
|
122
128
|
config = PRC::BaseConfig.new(:test1 => { :test2 => 'value' })
|
129
|
+
config.version = '0.1'
|
130
|
+
|
123
131
|
expect(config.erase).to eq({})
|
124
132
|
expect(config.data).to eq({})
|
133
|
+
expect(config.version).to eq(nil)
|
125
134
|
end
|
126
135
|
end
|
127
136
|
|
@@ -150,6 +159,7 @@ describe 'class: PRC::BaseConfig,' do
|
|
150
159
|
old_file = @config.filename
|
151
160
|
filename = File.expand_path(file)
|
152
161
|
|
162
|
+
@config.version = '1'
|
153
163
|
expect(@config.save(file)).to equal(true)
|
154
164
|
expect(@config.filename).not_to eq(old_file)
|
155
165
|
expect(@config.filename).to eq(filename)
|
@@ -160,6 +170,7 @@ describe 'class: PRC::BaseConfig,' do
|
|
160
170
|
|
161
171
|
expect(@config.load).to equal(true)
|
162
172
|
expect(@config.data).to eq(:test1 => { :test2 => 'value' })
|
173
|
+
expect(@config.version).to eq('1')
|
163
174
|
|
164
175
|
File.delete(@config.filename)
|
165
176
|
end
|
@@ -77,6 +77,28 @@ describe 'class: PRC::CoreConfig,' do
|
|
77
77
|
expect(@config.layers).to eq(%w(runtime local))
|
78
78
|
end
|
79
79
|
|
80
|
+
it 'config.version("local") return nil' do
|
81
|
+
expect(@config.version('local')).to equal(nil)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'config.version("runtime") return nil' do
|
85
|
+
expect(@config.version('runtime')).to equal(nil)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'config.version["inexistent"] return nil' do
|
89
|
+
expect(@config.version('inexistent')).to equal(nil)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'only config.version_set("local") = "1"' do
|
93
|
+
expect(@config.version_set('local', '1')).to eq('1')
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'only config.version("local") return "1"' do
|
97
|
+
expect(@config.version('local')).to eq('1')
|
98
|
+
expect(@config.version('runtime')).to equal(nil)
|
99
|
+
expect(@config.version('inexistent')).to equal(nil)
|
100
|
+
end
|
101
|
+
|
80
102
|
it 'config.exist?(:test) returns true' do
|
81
103
|
expect(@config.exist?(:test)).to equal(true)
|
82
104
|
end
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
18
|
# require 'rubygems'
|
19
|
-
#
|
19
|
+
# require 'byebug'
|
20
20
|
# require 'bundler/setup'
|
21
21
|
|
22
22
|
app_path = File.dirname(__FILE__)
|
@@ -80,6 +80,37 @@ describe 'class: Lorj::Default loaded lorj_spec/defaults.yaml, '\
|
|
80
80
|
it 'get_meta_section(:data) return :credentials' do
|
81
81
|
expect(@defaults.get_meta_section(:data)).to eq(:credentials)
|
82
82
|
end
|
83
|
+
|
84
|
+
it 'with :metadata_section => :lorj_default_missing, '\
|
85
|
+
'exist?[:default_case] return false' do
|
86
|
+
@defaults.data_options(:metadata_section => :lorj_default_missing)
|
87
|
+
expect(@defaults.exist?(:default_case)).to equal(false)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
context 'defaults.yaml loaded, with :metadata_section => :lorj_default,' do
|
91
|
+
before(:all) do
|
92
|
+
@defaults.data_options(:metadata_section => :lorj_default)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'exist?[:default_case] return true' do
|
96
|
+
expect(@defaults.exist?(:default_case)).to equal(true)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'exist?[:default_case2] return true' do
|
100
|
+
expect(@defaults.exist?(:default_case2)).to equal(true)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'exist?[:default_case3] return false' do
|
104
|
+
expect(@defaults.exist?(:default_case3)).to equal(false)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'get[:default_case] return "success"' do
|
108
|
+
expect(@defaults[:default_case]).to eq('success')
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'get[:default_case2] return "success"' do
|
112
|
+
expect(@defaults[:default_case2]).to eq('success')
|
113
|
+
end
|
83
114
|
end
|
84
115
|
end
|
85
116
|
end
|
@@ -206,9 +206,14 @@ describe 'class: Lorj::Config,' do
|
|
206
206
|
expect(@config.where?(:test1)).to equal(false)
|
207
207
|
end
|
208
208
|
|
209
|
-
it 'default_dump return all in a Hash' do
|
209
|
+
it 'default_dump return all in a Hash, without :setup and :sections' do
|
210
210
|
default_file = @config.config_filename('default')
|
211
|
+
# Following will split defaults.yaml to 2 differents config
|
212
|
+
# values config layers and metadata config layers.
|
213
|
+
Lorj.defaults
|
211
214
|
default = YAML.load_file(default_file)
|
215
|
+
default.delete(:setup)
|
216
|
+
default.delete(:sections)
|
212
217
|
|
213
218
|
res = { 'local' => { :default => {} },
|
214
219
|
'default' => default
|
File without changes
|
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.
|
4
|
+
version: 1.0.9
|
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-
|
11
|
+
date: 2015-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -244,10 +244,10 @@ files:
|
|
244
244
|
- spec/04_prc_core_config_spec.rb
|
245
245
|
- spec/09_prc_spec.rb
|
246
246
|
- spec/10_lorj_log_spec.rb
|
247
|
-
- spec/
|
248
|
-
- spec/
|
247
|
+
- spec/11_lorj_defaults_spec.rb
|
248
|
+
- spec/12_lorj_config_spec.rb
|
249
|
+
- spec/13_lorj_account_spec.rb
|
249
250
|
- spec/20_lorj_meta_spec.rb
|
250
|
-
- spec/21_lorj_defaults_spec.rb
|
251
251
|
homepage: https://github.com/forj-oss/lorj
|
252
252
|
licenses:
|
253
253
|
- Apache License, Version 2.0.
|
@@ -281,8 +281,8 @@ test_files:
|
|
281
281
|
- spec/04_prc_core_config_spec.rb
|
282
282
|
- spec/09_prc_spec.rb
|
283
283
|
- spec/10_lorj_log_spec.rb
|
284
|
-
- spec/
|
285
|
-
- spec/
|
284
|
+
- spec/11_lorj_defaults_spec.rb
|
285
|
+
- spec/12_lorj_config_spec.rb
|
286
|
+
- spec/13_lorj_account_spec.rb
|
286
287
|
- spec/20_lorj_meta_spec.rb
|
287
|
-
- spec/21_lorj_defaults_spec.rb
|
288
288
|
has_rdoc:
|