nugrant 2.1.2 → 2.1.4

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 (71) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +23 -23
  3. data/.travis.yml +15 -10
  4. data/CHANGELOG.md +347 -338
  5. data/CONTRIBUTORS.md +7 -5
  6. data/Gemfile +13 -13
  7. data/README.md +601 -601
  8. data/lib/nugrant/bag.rb +264 -264
  9. data/lib/nugrant/config.rb +201 -201
  10. data/lib/nugrant/helper/bag.rb +38 -38
  11. data/lib/nugrant/helper/env/exporter.rb +195 -195
  12. data/lib/nugrant/helper/env/namer.rb +47 -47
  13. data/lib/nugrant/helper/parameters.rb +12 -12
  14. data/lib/nugrant/helper/stack.rb +86 -86
  15. data/lib/nugrant/mixin/parameters.rb +178 -178
  16. data/lib/nugrant/parameters.rb +29 -29
  17. data/lib/nugrant/vagrant/errors.rb +35 -35
  18. data/lib/nugrant/vagrant/v2/action/auto_export.rb +45 -45
  19. data/lib/nugrant/vagrant/v2/action.rb +17 -17
  20. data/lib/nugrant/vagrant/v2/command/env.rb +118 -118
  21. data/lib/nugrant/vagrant/v2/command/parameters.rb +153 -153
  22. data/lib/nugrant/vagrant/v2/command/restricted_keys.rb +64 -64
  23. data/lib/nugrant/vagrant/v2/command/root.rb +95 -95
  24. data/lib/nugrant/vagrant/v2/config/user.rb +29 -29
  25. data/lib/nugrant/vagrant/v2/helper.rb +96 -96
  26. data/lib/nugrant/vagrant/v2/plugin.rb +34 -34
  27. data/lib/nugrant/version.rb +3 -3
  28. data/lib/nugrant.rb +31 -31
  29. data/locales/en.yml +24 -24
  30. data/locales/fr.yml +24 -24
  31. data/nugrant.gemspec +32 -32
  32. data/test/lib/nugrant/helper/env/test_exporter.rb +238 -238
  33. data/test/lib/nugrant/helper/test_bag.rb +16 -16
  34. data/test/lib/nugrant/helper/test_parameters.rb +17 -17
  35. data/test/lib/nugrant/helper/test_stack.rb +152 -152
  36. data/test/lib/nugrant/test_bag.rb +450 -450
  37. data/test/lib/nugrant/test_config.rb +201 -201
  38. data/test/lib/nugrant/test_parameters.rb +438 -438
  39. data/test/lib/test_helper.rb +3 -3
  40. data/test/resources/README.md +52 -52
  41. data/test/resources/json/params_current_1.json +6 -6
  42. data/test/resources/json/params_current_2.json +29 -29
  43. data/test/resources/json/params_user_nil_values.json +9 -9
  44. data/test/resources/vagrantfiles/v2.auto_export +13 -13
  45. data/test/resources/vagrantfiles/v2.bag_inside_array +15 -15
  46. data/test/resources/vagrantfiles/v2.defaults_mixed_string_symbols +18 -18
  47. data/test/resources/vagrantfiles/v2.defaults_null_values_in_vagrantuser +23 -23
  48. data/test/resources/vagrantfiles/v2.defaults_using_string +18 -18
  49. data/test/resources/vagrantfiles/v2.defaults_using_symbol +18 -18
  50. data/test/resources/vagrantfiles/v2.empty +2 -2
  51. data/test/resources/vagrantfiles/v2.fake +29 -29
  52. data/test/resources/vagrantfiles/v2.missing_parameter +3 -3
  53. data/test/resources/vagrantfiles/v2.real +22 -22
  54. data/test/resources/yaml/params_array.yml +5 -5
  55. data/test/resources/yaml/params_boolean.yml +1 -1
  56. data/test/resources/yaml/params_combinations.yml +72 -72
  57. data/test/resources/yaml/params_current_1.yml +4 -4
  58. data/test/resources/yaml/params_current_2.yml +23 -23
  59. data/test/resources/yaml/params_defaults_at_root.yml +1 -1
  60. data/test/resources/yaml/params_defaults_not_at_root.yml +2 -2
  61. data/test/resources/yaml/params_list.yml +2 -2
  62. data/test/resources/yaml/params_numeric_key.yml +3 -3
  63. data/test/resources/yaml/params_simple.yml +1 -1
  64. data/test/resources/yaml/params_system_1.yml +4 -4
  65. data/test/resources/yaml/params_system_2.yml +25 -25
  66. data/test/resources/yaml/params_unix_eol.yml +3 -3
  67. data/test/resources/yaml/params_user_1.yml +4 -4
  68. data/test/resources/yaml/params_user_2.yml +23 -23
  69. data/test/resources/yaml/params_user_nil_values.yml +5 -5
  70. data/test/resources/yaml/params_windows_eol.yml +3 -3
  71. metadata +12 -13
@@ -1,201 +1,201 @@
1
- require 'minitest/autorun'
2
- require 'tmpdir'
3
-
4
- require 'nugrant/config'
5
-
6
- module Nugrant
7
- class TestConfig < ::Minitest::Test
8
- def setup
9
- @default_param_filename = Nugrant::Config::DEFAULT_PARAMS_FILENAME
10
-
11
- @old_working_dir = Dir.getwd()
12
- @user_dir = Nugrant::Config.default_user_path()
13
- @system_dir = Nugrant::Config.default_system_path()
14
-
15
- Dir.chdir(Dir.tmpdir())
16
-
17
- @current_dir = Dir.getwd()
18
- end
19
-
20
- def teardown
21
- Dir.chdir(@old_working_dir)
22
-
23
- @old_working_dir = nil
24
- @current_dir = nil
25
- @user_dir = nil
26
- @system_dir = nil
27
- end
28
-
29
- def test_default_values
30
- config = Nugrant::Config.new()
31
-
32
- assert_equal(@default_param_filename, config.params_filename())
33
- assert_equal("#{@current_dir}/#{@default_param_filename}", config.current_path())
34
- assert_equal("#{@user_dir}/#{@default_param_filename}", config.user_path())
35
- assert_equal("#{@system_dir}/#{@default_param_filename}", config.system_path())
36
- end
37
-
38
- def test_custom_params_filename
39
- config = Nugrant::Config.new({:params_filename => ".customparams"})
40
-
41
- assert_equal(".customparams", config.params_filename())
42
- assert_equal("#{@current_dir}/.customparams", config.current_path())
43
- assert_equal("#{@user_dir}/.customparams", config.user_path())
44
- assert_equal("#{@system_dir}/.customparams", config.system_path())
45
- end
46
-
47
- def test_custom_current_path
48
- config = Nugrant::Config.new({
49
- :params_filename => ".customparams",
50
- :current_path => "#{@user_dir}/.currentcustomparams"
51
- })
52
-
53
- assert_equal(".customparams", config.params_filename())
54
- assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
55
- end
56
-
57
- def test_custom_current_path_without_filename
58
- config = Nugrant::Config.new({
59
- :params_filename => ".customparams",
60
- :current_path => "#{@user_dir}"
61
- })
62
-
63
- assert_equal(".customparams", config.params_filename())
64
- assert_equal("#{@user_dir}/.customparams", config.current_path())
65
- end
66
-
67
- def test_custom_current_path_using_callable
68
- config = Nugrant::Config.new({
69
- :params_filename => ".customparams",
70
- :current_path => lambda do ||
71
- "#{@user_dir}/"
72
- end
73
- })
74
-
75
- assert_equal(".customparams", config.params_filename())
76
- assert_equal("#{@user_dir}/.customparams", config.current_path())
77
- end
78
-
79
- def test_custom_user_path
80
- config = Nugrant::Config.new({
81
- :params_filename => ".customparams",
82
- :user_path => "#{@system_dir}/.usercustomparams"
83
- })
84
-
85
- assert_equal(".customparams", config.params_filename())
86
- assert_equal("#{@system_dir}/.usercustomparams", config.user_path()) end
87
-
88
- def test_custom_system_path
89
- config = Nugrant::Config.new({
90
- :params_filename => ".customparams",
91
- :system_path => "#{@current_dir}/.systemcustomparams"
92
- })
93
-
94
- assert_equal(".customparams", config.params_filename())
95
- assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
96
- end
97
-
98
- def test_custom_all
99
- config = Nugrant::Config.new({
100
- :params_filename => ".customparams",
101
- :current_path => "#{@user_dir}/.currentcustomparams",
102
- :user_path => "#{@system_dir}/.usercustomparams",
103
- :system_path => "#{@current_dir}/.systemcustomparams"
104
- })
105
-
106
- assert_equal(".customparams", config.params_filename())
107
- assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
108
- assert_equal("#{@system_dir}/.usercustomparams", config.user_path())
109
- assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
110
- end
111
-
112
- def test_nil_current
113
- config = Nugrant::Config.new({
114
- :params_filename => ".customparams",
115
- :current_path => nil,
116
- })
117
-
118
- assert_equal("#{@current_dir}/.customparams", config.current_path())
119
- end
120
-
121
- def test_nil_user
122
- config = Nugrant::Config.new({
123
- :params_filename => ".customparams",
124
- :user_path => nil,
125
- })
126
-
127
- assert_equal("#{@user_dir}/.customparams", config.user_path())
128
- end
129
-
130
- def test_nil_system
131
- config = Nugrant::Config.new({
132
- :params_filename => ".customparams",
133
- :system_path => nil,
134
- })
135
-
136
- assert_equal("#{@system_dir}/.customparams", config.system_path())
137
- end
138
-
139
- def test_invalid_format
140
- assert_raises(ArgumentError) do
141
- Nugrant::Config.new({:params_format => :invalid})
142
- end
143
- end
144
-
145
- def test_merge
146
- config1 = Nugrant::Config.new({
147
- :params_filename => ".customparams",
148
- :current_path => nil,
149
- })
150
-
151
- config2 = Nugrant::Config.new({
152
- :params_filename => ".overrideparams",
153
- :current_path => "something",
154
- })
155
-
156
- config3 = config1.merge(config2)
157
-
158
- refute_same(config1, config3)
159
- refute_same(config2, config3)
160
-
161
- assert_equal(Nugrant::Config.new({
162
- :params_filename => config2[:params_filename],
163
- :params_format => config2[:params_format],
164
- :current_path => config2[:current_path],
165
- :user_path => config2[:user_path],
166
- :system_path => config2[:system_path],
167
- :array_merge_strategy => config2[:array_merge_strategy],
168
- :key_error => config2[:key_error],
169
- :parse_error => config2[:parse_error],
170
- }), config3)
171
- end
172
-
173
- def test_merge!
174
- config1 = Nugrant::Config.new({
175
- :params_filename => ".customparams",
176
- :current_path => nil,
177
- })
178
-
179
- config2 = Nugrant::Config.new({
180
- :params_filename => ".overrideparams",
181
- :current_path => "something",
182
- })
183
-
184
- config3 = config1.merge!(config2)
185
-
186
- assert_same(config1, config3)
187
- refute_same(config2, config3)
188
-
189
- assert_equal(Nugrant::Config.new({
190
- :params_filename => config2[:params_filename],
191
- :params_format => config2[:params_format],
192
- :current_path => config2[:current_path],
193
- :user_path => config2[:user_path],
194
- :system_path => config2[:system_path],
195
- :array_merge_strategy => config2[:array_merge_strategy],
196
- :key_error => config2[:key_error],
197
- :parse_error => config2[:parse_error],
198
- }), config3)
199
- end
200
- end
201
- end
1
+ require 'minitest/autorun'
2
+ require 'tmpdir'
3
+
4
+ require 'nugrant/config'
5
+
6
+ module Nugrant
7
+ class TestConfig < ::Minitest::Test
8
+ def setup
9
+ @default_param_filename = Nugrant::Config::DEFAULT_PARAMS_FILENAME
10
+
11
+ @old_working_dir = Dir.getwd()
12
+ @user_dir = Nugrant::Config.default_user_path()
13
+ @system_dir = Nugrant::Config.default_system_path()
14
+
15
+ Dir.chdir(Dir.tmpdir())
16
+
17
+ @current_dir = Dir.getwd()
18
+ end
19
+
20
+ def teardown
21
+ Dir.chdir(@old_working_dir)
22
+
23
+ @old_working_dir = nil
24
+ @current_dir = nil
25
+ @user_dir = nil
26
+ @system_dir = nil
27
+ end
28
+
29
+ def test_default_values
30
+ config = Nugrant::Config.new()
31
+
32
+ assert_equal(@default_param_filename, config.params_filename())
33
+ assert_equal("#{@current_dir}/#{@default_param_filename}", config.current_path())
34
+ assert_equal("#{@user_dir}/#{@default_param_filename}", config.user_path())
35
+ assert_equal("#{@system_dir}/#{@default_param_filename}", config.system_path())
36
+ end
37
+
38
+ def test_custom_params_filename
39
+ config = Nugrant::Config.new({:params_filename => ".customparams"})
40
+
41
+ assert_equal(".customparams", config.params_filename())
42
+ assert_equal("#{@current_dir}/.customparams", config.current_path())
43
+ assert_equal("#{@user_dir}/.customparams", config.user_path())
44
+ assert_equal("#{@system_dir}/.customparams", config.system_path())
45
+ end
46
+
47
+ def test_custom_current_path
48
+ config = Nugrant::Config.new({
49
+ :params_filename => ".customparams",
50
+ :current_path => "#{@user_dir}/.currentcustomparams"
51
+ })
52
+
53
+ assert_equal(".customparams", config.params_filename())
54
+ assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
55
+ end
56
+
57
+ def test_custom_current_path_without_filename
58
+ config = Nugrant::Config.new({
59
+ :params_filename => ".customparams",
60
+ :current_path => "#{@user_dir}"
61
+ })
62
+
63
+ assert_equal(".customparams", config.params_filename())
64
+ assert_equal("#{@user_dir}/.customparams", config.current_path())
65
+ end
66
+
67
+ def test_custom_current_path_using_callable
68
+ config = Nugrant::Config.new({
69
+ :params_filename => ".customparams",
70
+ :current_path => lambda do ||
71
+ "#{@user_dir}/"
72
+ end
73
+ })
74
+
75
+ assert_equal(".customparams", config.params_filename())
76
+ assert_equal("#{@user_dir}/.customparams", config.current_path())
77
+ end
78
+
79
+ def test_custom_user_path
80
+ config = Nugrant::Config.new({
81
+ :params_filename => ".customparams",
82
+ :user_path => "#{@system_dir}/.usercustomparams"
83
+ })
84
+
85
+ assert_equal(".customparams", config.params_filename())
86
+ assert_equal("#{@system_dir}/.usercustomparams", config.user_path()) end
87
+
88
+ def test_custom_system_path
89
+ config = Nugrant::Config.new({
90
+ :params_filename => ".customparams",
91
+ :system_path => "#{@current_dir}/.systemcustomparams"
92
+ })
93
+
94
+ assert_equal(".customparams", config.params_filename())
95
+ assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
96
+ end
97
+
98
+ def test_custom_all
99
+ config = Nugrant::Config.new({
100
+ :params_filename => ".customparams",
101
+ :current_path => "#{@user_dir}/.currentcustomparams",
102
+ :user_path => "#{@system_dir}/.usercustomparams",
103
+ :system_path => "#{@current_dir}/.systemcustomparams"
104
+ })
105
+
106
+ assert_equal(".customparams", config.params_filename())
107
+ assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
108
+ assert_equal("#{@system_dir}/.usercustomparams", config.user_path())
109
+ assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
110
+ end
111
+
112
+ def test_nil_current
113
+ config = Nugrant::Config.new({
114
+ :params_filename => ".customparams",
115
+ :current_path => nil,
116
+ })
117
+
118
+ assert_equal("#{@current_dir}/.customparams", config.current_path())
119
+ end
120
+
121
+ def test_nil_user
122
+ config = Nugrant::Config.new({
123
+ :params_filename => ".customparams",
124
+ :user_path => nil,
125
+ })
126
+
127
+ assert_equal("#{@user_dir}/.customparams", config.user_path())
128
+ end
129
+
130
+ def test_nil_system
131
+ config = Nugrant::Config.new({
132
+ :params_filename => ".customparams",
133
+ :system_path => nil,
134
+ })
135
+
136
+ assert_equal("#{@system_dir}/.customparams", config.system_path())
137
+ end
138
+
139
+ def test_invalid_format
140
+ assert_raises(ArgumentError) do
141
+ Nugrant::Config.new({:params_format => :invalid})
142
+ end
143
+ end
144
+
145
+ def test_merge
146
+ config1 = Nugrant::Config.new({
147
+ :params_filename => ".customparams",
148
+ :current_path => nil,
149
+ })
150
+
151
+ config2 = Nugrant::Config.new({
152
+ :params_filename => ".overrideparams",
153
+ :current_path => "something",
154
+ })
155
+
156
+ config3 = config1.merge(config2)
157
+
158
+ refute_same(config1, config3)
159
+ refute_same(config2, config3)
160
+
161
+ assert_equal(Nugrant::Config.new({
162
+ :params_filename => config2[:params_filename],
163
+ :params_format => config2[:params_format],
164
+ :current_path => config2[:current_path],
165
+ :user_path => config2[:user_path],
166
+ :system_path => config2[:system_path],
167
+ :array_merge_strategy => config2[:array_merge_strategy],
168
+ :key_error => config2[:key_error],
169
+ :parse_error => config2[:parse_error],
170
+ }), config3)
171
+ end
172
+
173
+ def test_merge!
174
+ config1 = Nugrant::Config.new({
175
+ :params_filename => ".customparams",
176
+ :current_path => nil,
177
+ })
178
+
179
+ config2 = Nugrant::Config.new({
180
+ :params_filename => ".overrideparams",
181
+ :current_path => "something",
182
+ })
183
+
184
+ config3 = config1.merge!(config2)
185
+
186
+ assert_same(config1, config3)
187
+ refute_same(config2, config3)
188
+
189
+ assert_equal(Nugrant::Config.new({
190
+ :params_filename => config2[:params_filename],
191
+ :params_format => config2[:params_format],
192
+ :current_path => config2[:current_path],
193
+ :user_path => config2[:user_path],
194
+ :system_path => config2[:system_path],
195
+ :array_merge_strategy => config2[:array_merge_strategy],
196
+ :key_error => config2[:key_error],
197
+ :parse_error => config2[:parse_error],
198
+ }), config3)
199
+ end
200
+ end
201
+ end