nugrant 2.0.0.dev1 → 2.0.0.dev2
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 +8 -8
- data/lib/nugrant/bag.rb +4 -4
- data/lib/nugrant/config.rb +1 -1
- data/lib/nugrant/helper/bag.rb +1 -1
- data/lib/nugrant/parameters.rb +6 -1
- data/lib/nugrant/version.rb +1 -1
- data/nugrant.gemspec +5 -0
- data/test/lib/nugrant/test_bag.rb +37 -37
- data/test/lib/nugrant/test_parameters.rb +66 -66
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTc4MzNjMDg2Mzk2MDU0MTFkODU5M2NmY2Y3ZmNjMWEzZjUyNDJlYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODg2OWRhZDJkN2ZmYTU3ZmYyODg5YjAxZWI5NjhmNTFjZGU3M2E4Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTc5ZDY1N2IzZGYwN2M5Y2IxOWEzYmMxODFjYjlkMmY0ODEzNWIzMTA3MGY2
|
10
|
+
YzYyZGIxOWRlYjc0N2E0MGYyNjdhZDZlNzg5YzlkMzM5NGJlYjg4OTljYTM1
|
11
|
+
NjhkZDYzODJiYjA0MGE3MWQ0MTcyOThmYTMzYzUwMTU5YjY0ODE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjQyNzc2M2Q2YjdlZTc0YzE1ZDFlNjFlMzY1M2UwOTQzZjU2ZWM5ZGQ5ZDc4
|
14
|
+
ZDVlZmQwZjEwMDk5Yzk1YjlhNjgxNjlmZWU0NDQyYmZjNjc4MjQxMDA3NmRj
|
15
|
+
MTlmYWQ4NjFiYjJjNWI5YTRmYzNmM2RiYTQ2NmFhZDg2YWUxMzY=
|
data/lib/nugrant/bag.rb
CHANGED
@@ -15,7 +15,7 @@ module Nugrant
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def method_missing(method, *args, &block)
|
18
|
-
return __fetch(method
|
18
|
+
return __fetch(method)
|
19
19
|
end
|
20
20
|
|
21
21
|
def has?(key)
|
@@ -64,7 +64,7 @@ module Nugrant
|
|
64
64
|
|
65
65
|
hash = {}
|
66
66
|
each do |key, value|
|
67
|
-
hash[key] = value.kind_of?(Bag) ? value.__to_hash() : value
|
67
|
+
hash[key.to_sym()] = value.kind_of?(Bag) ? value.__to_hash() : value
|
68
68
|
end
|
69
69
|
|
70
70
|
return hash
|
@@ -76,12 +76,12 @@ module Nugrant
|
|
76
76
|
|
77
77
|
hash.each do |key, value|
|
78
78
|
if not value.kind_of?(Hash)
|
79
|
-
@__elements[key] = value
|
79
|
+
@__elements[key.to_sym()] = value
|
80
80
|
next
|
81
81
|
end
|
82
82
|
|
83
83
|
# It is a hash, transform it into a bag
|
84
|
-
@__elements[key] = Bag.new(value)
|
84
|
+
@__elements[key.to_sym()] = Bag.new(value)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
data/lib/nugrant/config.rb
CHANGED
@@ -60,7 +60,7 @@ module Nugrant
|
|
60
60
|
# parameters should resides. The parameters loaded from this
|
61
61
|
# location have the second highest precedence.
|
62
62
|
# Defaults => "~/#{@params_filename}"
|
63
|
-
# * +:
|
63
|
+
# * +:system_path+ - The system path is the location where system wide
|
64
64
|
# parameters should resides. The parameters loaded from this
|
65
65
|
# location have the third highest precedence.
|
66
66
|
# Defaults => Default system path depending on OS + @params_filename
|
data/lib/nugrant/helper/bag.rb
CHANGED
data/lib/nugrant/parameters.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'nugrant/bag'
|
2
|
+
require 'nugrant/config'
|
2
3
|
require 'nugrant/helper/bag'
|
3
4
|
|
4
5
|
module Nugrant
|
@@ -35,7 +36,7 @@ module Nugrant
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def method_missing(method, *args, &block)
|
38
|
-
return @__all[method
|
39
|
+
return @__all[method]
|
39
40
|
end
|
40
41
|
|
41
42
|
def empty?()
|
@@ -78,5 +79,9 @@ module Nugrant
|
|
78
79
|
@__all.__merge!(@__user)
|
79
80
|
@__all.__merge!(@__current)
|
80
81
|
end
|
82
|
+
|
83
|
+
def __to_hash()
|
84
|
+
@__all.__to_hash()
|
85
|
+
end
|
81
86
|
end
|
82
87
|
end
|
data/lib/nugrant/version.rb
CHANGED
data/nugrant.gemspec
CHANGED
@@ -28,5 +28,10 @@ Gem::Specification.new do |gem|
|
|
28
28
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
29
29
|
gem.require_paths = ["lib"]
|
30
30
|
|
31
|
+
gem.requirements << "json if you plan to use json parameters format"
|
32
|
+
|
33
|
+
gem.add_dependency 'multi_json', '~> 1.7'
|
34
|
+
|
31
35
|
gem.add_development_dependency "rake"
|
36
|
+
gem.add_development_dependency "json"
|
32
37
|
end
|
@@ -30,49 +30,49 @@ module Nugrant
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_bag()
|
33
|
-
run_test_bag({
|
33
|
+
run_test_bag({:first => "value1", :second => "value2"})
|
34
34
|
|
35
35
|
run_test_bag({
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
:first => {
|
37
|
+
:level1 => "value1",
|
38
|
+
:level2 => "value2",
|
39
39
|
},
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
:second => {
|
41
|
+
:level1 => "value3",
|
42
|
+
:level2 => "value4",
|
43
43
|
},
|
44
|
-
|
44
|
+
:third => "value5"
|
45
45
|
})
|
46
46
|
|
47
47
|
run_test_bag({
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
:first => {
|
49
|
+
:level1 => {
|
50
|
+
:level11 => "value1",
|
51
|
+
:level12 => "value2",
|
52
52
|
},
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
:level2 => {
|
54
|
+
:level21 => "value3",
|
55
|
+
:level22 => "value4",
|
56
56
|
},
|
57
|
-
|
57
|
+
:level3 => "value5",
|
58
58
|
},
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
:second => {
|
60
|
+
:level1 => {
|
61
|
+
:level11 => "value6",
|
62
|
+
:level12 => "value7",
|
63
63
|
},
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
:level2 => {
|
65
|
+
:level21 => "value8",
|
66
|
+
:level22 => "value9",
|
67
67
|
},
|
68
|
-
|
68
|
+
:level3 => "value10",
|
69
69
|
},
|
70
|
-
|
70
|
+
:third => "value11"
|
71
71
|
})
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_undefined_value()
|
75
|
-
bag = create_bag({
|
75
|
+
bag = create_bag({:value => "one"})
|
76
76
|
|
77
77
|
assert_raise(KeyError) do
|
78
78
|
bag.invalid_value
|
@@ -89,29 +89,29 @@ module Nugrant
|
|
89
89
|
assert_kind_of(Hash, hash)
|
90
90
|
assert_equal({}, hash)
|
91
91
|
|
92
|
-
hash = create_bag({
|
92
|
+
hash = create_bag({:value => {:one => "value", :two => "value"}}).__to_hash()
|
93
93
|
|
94
94
|
assert_kind_of(Hash, hash)
|
95
|
-
assert_kind_of(Hash, hash[
|
96
|
-
assert_kind_of(String, hash[
|
97
|
-
assert_kind_of(String, hash[
|
98
|
-
assert_equal({
|
95
|
+
assert_kind_of(Hash, hash[:value])
|
96
|
+
assert_kind_of(String, hash[:value][:one])
|
97
|
+
assert_kind_of(String, hash[:value][:two])
|
98
|
+
assert_equal({:value => {:one => "value", :two => "value"}}, hash)
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_merge_array()
|
102
|
-
bag1 = create_bag({
|
103
|
-
bag2 = create_bag({
|
102
|
+
bag1 = create_bag({:first => [1, 2]})
|
103
|
+
bag2 = create_bag({:first => [2, 3]})
|
104
104
|
|
105
105
|
bag1.__merge!(bag2);
|
106
106
|
|
107
|
-
assert_equal({
|
107
|
+
assert_equal({:first => [1, 2, 3]}, bag1.__to_hash())
|
108
108
|
|
109
|
-
bag1 = create_bag({
|
110
|
-
bag2 = create_bag({
|
109
|
+
bag1 = create_bag({:first => [1, 2]})
|
110
|
+
bag2 = create_bag({:first => "string"})
|
111
111
|
|
112
112
|
bag1.__merge!(bag2);
|
113
113
|
|
114
|
-
assert_equal({
|
114
|
+
assert_equal({:first => "string"}, bag1.__to_hash())
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -52,13 +52,13 @@ class Nugrant::TestParameters < Test::Unit::TestCase
|
|
52
52
|
parameters = create_parameters(format, "params_current_1", "params_user_1", "params_system_1")
|
53
53
|
|
54
54
|
assert_level(parameters, {
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
55
|
+
:'1.1.1' => "current",
|
56
|
+
:'1.1.0' => "current",
|
57
|
+
:'1.0.1' => "current",
|
58
|
+
:'0.1.1' => "user",
|
59
|
+
:'1.0.0' => "current",
|
60
|
+
:'0.1.0' => "user",
|
61
|
+
:'0.0.1' => "system",
|
62
62
|
})
|
63
63
|
end
|
64
64
|
end
|
@@ -67,65 +67,65 @@ class Nugrant::TestParameters < Test::Unit::TestCase
|
|
67
67
|
formats.each do |format|
|
68
68
|
parameters = create_parameters(format, "params_current_2", "params_user_2", "params_system_2")
|
69
69
|
|
70
|
-
run_second_level(parameters,
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
70
|
+
run_second_level(parameters, :'1.1.1', {
|
71
|
+
:'1.1.1' => "current",
|
72
|
+
:'1.1.0' => "current",
|
73
|
+
:'1.0.1' => "current",
|
74
|
+
:'0.1.1' => "user",
|
75
|
+
:'1.0.0' => "current",
|
76
|
+
:'0.1.0' => "user",
|
77
|
+
:'0.0.1' => "system",
|
78
78
|
})
|
79
79
|
|
80
|
-
run_second_level(parameters,
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
80
|
+
run_second_level(parameters, :'1.1.0', {
|
81
|
+
:'1.1.1' => "current",
|
82
|
+
:'1.1.0' => "current",
|
83
|
+
:'1.0.1' => "current",
|
84
|
+
:'0.1.1' => "user",
|
85
|
+
:'1.0.0' => "current",
|
86
|
+
:'0.1.0' => "user",
|
87
87
|
})
|
88
88
|
|
89
|
-
run_second_level(parameters,
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
run_second_level(parameters, :'1.0.1', {
|
90
|
+
:'1.1.1' => "current",
|
91
|
+
:'1.1.0' => "current",
|
92
|
+
:'1.0.1' => "current",
|
93
|
+
:'0.1.1' => "system",
|
94
|
+
:'1.0.0' => "current",
|
95
|
+
:'0.0.1' => "system",
|
96
96
|
})
|
97
97
|
|
98
|
-
run_second_level(parameters,
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
98
|
+
run_second_level(parameters, :'0.1.1', {
|
99
|
+
:'1.1.1' => "user",
|
100
|
+
:'1.1.0' => "user",
|
101
|
+
:'1.0.1' => "system",
|
102
|
+
:'0.1.1' => "user",
|
103
|
+
:'0.1.0' => "user",
|
104
|
+
:'0.0.1' => "system",
|
105
105
|
})
|
106
106
|
|
107
|
-
run_second_level(parameters,
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
107
|
+
run_second_level(parameters, :'1.0.0', {
|
108
|
+
:'1.1.1' => "current",
|
109
|
+
:'1.1.0' => "current",
|
110
|
+
:'1.0.1' => "current",
|
111
|
+
:'1.0.0' => "current",
|
112
112
|
})
|
113
113
|
|
114
|
-
run_second_level(parameters,
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
run_second_level(parameters, :'0.1.0', {
|
115
|
+
:'1.1.1' => "user",
|
116
|
+
:'1.1.0' => "user",
|
117
|
+
:'0.1.1' => "user",
|
118
|
+
:'0.1.0' => "user",
|
119
119
|
})
|
120
120
|
|
121
|
-
run_second_level(parameters,
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
121
|
+
run_second_level(parameters, :'0.0.1', {
|
122
|
+
:'1.1.1' => "system",
|
123
|
+
:'1.0.1' => "system",
|
124
|
+
:'0.1.1' => "system",
|
125
|
+
:'0.0.1' => "system",
|
126
126
|
})
|
127
127
|
|
128
|
-
assert_key_error(parameters,
|
128
|
+
assert_key_error(parameters, :'0.0.0')
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -133,7 +133,7 @@ class Nugrant::TestParameters < Test::Unit::TestCase
|
|
133
133
|
assert_level(parameters.send(key), results)
|
134
134
|
assert_level(parameters[key], results)
|
135
135
|
|
136
|
-
assert_key_error(parameters,
|
136
|
+
assert_key_error(parameters, :'0.0.0')
|
137
137
|
end
|
138
138
|
|
139
139
|
def test_params_array()
|
@@ -141,7 +141,7 @@ class Nugrant::TestParameters < Test::Unit::TestCase
|
|
141
141
|
formats.each do |format|
|
142
142
|
parameters = create_parameters(format, file_path, invalid_path, invalid_path)
|
143
143
|
|
144
|
-
assert_equal(["1", "2", "3"], parameters[
|
144
|
+
assert_equal(["1", "2", "3"], parameters[:level1][:level2])
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -156,13 +156,13 @@ class Nugrant::TestParameters < Test::Unit::TestCase
|
|
156
156
|
def run_test_file_invalid(invalid_value)
|
157
157
|
formats.each do |format|
|
158
158
|
parameters = create_parameters(format, "params_simple", invalid_path, invalid_path)
|
159
|
-
assert_equal("value", parameters[
|
159
|
+
assert_equal("value", parameters[:test])
|
160
160
|
|
161
161
|
parameters = create_parameters(format, invalid_path, "params_simple", invalid_path)
|
162
|
-
assert_equal("value", parameters[
|
162
|
+
assert_equal("value", parameters[:test])
|
163
163
|
|
164
164
|
parameters = create_parameters(format, invalid_path, invalid_path, "params_simple")
|
165
|
-
assert_equal("value", parameters[
|
165
|
+
assert_equal("value", parameters[:test])
|
166
166
|
|
167
167
|
parameters = create_parameters(format, invalid_path, invalid_path, invalid_path)
|
168
168
|
assert_not_nil(parameters)
|
@@ -181,8 +181,8 @@ class Nugrant::TestParameters < Test::Unit::TestCase
|
|
181
181
|
formats.each do |format|
|
182
182
|
parameters = create_parameters(format, file_path, invalid_path, invalid_path)
|
183
183
|
|
184
|
-
assert_equal("value1", parameters[
|
185
|
-
assert_equal("value2", parameters[
|
184
|
+
assert_equal("value1", parameters[:level1])
|
185
|
+
assert_equal("value2", parameters[:level2][:first])
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
@@ -203,19 +203,19 @@ class Nugrant::TestParameters < Test::Unit::TestCase
|
|
203
203
|
def test_defaults()
|
204
204
|
formats.each do |format|
|
205
205
|
parameters = create_parameters(format, "params_simple", invalid_path, invalid_path)
|
206
|
-
parameters.defaults = {
|
206
|
+
parameters.defaults = {:test => "override1", :level => "new1"}
|
207
207
|
|
208
|
-
assert_equal("value", parameters[
|
209
|
-
assert_equal("new1", parameters[
|
208
|
+
assert_equal("value", parameters[:test])
|
209
|
+
assert_equal("new1", parameters[:level])
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
213
|
def test_empty_file()
|
214
214
|
formats.each do |format|
|
215
215
|
parameters = create_parameters(format, "params_empty", invalid_path, invalid_path)
|
216
|
-
parameters.defaults = {
|
216
|
+
parameters.defaults = {:test => "value"}
|
217
217
|
|
218
|
-
assert_equal("value", parameters[
|
218
|
+
assert_equal("value", parameters[:test])
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
@@ -223,9 +223,9 @@ class Nugrant::TestParameters < Test::Unit::TestCase
|
|
223
223
|
["boolean", "list"].each do |wrong_type|
|
224
224
|
formats.each do |format|
|
225
225
|
parameters = create_parameters(format, "params_#{wrong_type}", invalid_path, invalid_path)
|
226
|
-
parameters.defaults = {
|
226
|
+
parameters.defaults = {:test => "value"}
|
227
227
|
|
228
|
-
assert_equal("value", parameters[
|
228
|
+
assert_equal("value", parameters[:test])
|
229
229
|
end
|
230
230
|
end
|
231
231
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nugrant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.dev2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthieu Vachon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,20 @@ dependencies:
|
|
24
38
|
- - ! '>='
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
description: ! " Nugrant is a library to easily handle parameters that need to
|
28
56
|
be\n injected into an application via different sources (system, user,\n project,
|
29
57
|
defaults).\n\n Nugrant can also be directly used as a Vagrant plugin. By activating\n
|
@@ -125,7 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
153
|
- - ! '>'
|
126
154
|
- !ruby/object:Gem::Version
|
127
155
|
version: 1.3.1
|
128
|
-
requirements:
|
156
|
+
requirements:
|
157
|
+
- json if you plan to use json parameters format
|
129
158
|
rubyforge_project:
|
130
159
|
rubygems_version: 2.0.3
|
131
160
|
signing_key:
|