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,86 +1,86 @@
1
- module Nugrant
2
- module Helper
3
- class Stack
4
- @@DEFAULT_MATCHER = /^(.+):([0-9]+)/
5
-
6
- def self.fetch_error_region(stack, options = {})
7
- entry = find_entry(stack, options)
8
- location = extract_error_location(entry, options)
9
-
10
- return (options[:unknown] || "Unknown") if not location[:file] and not location[:line]
11
- return location[:file] if not location[:line]
12
-
13
- fetch_error_region_from_location(location, options)
14
- end
15
-
16
- def self.fetch_error_region_from_location(location, options = {})
17
- prefix = options[:prefix] || " "
18
- width = options[:width] || 4
19
- file = File.new(location[:file], "r")
20
- line = location[:line]
21
-
22
- index = 0
23
-
24
- lines = []
25
- while (line_string = file.gets())
26
- index += 1
27
- next if (line - index).abs > width
28
-
29
- line_prefix = "#{prefix}#{index}:"
30
- line_prefix += (line == index ? ">> " : " ")
31
-
32
- lines << "#{line_prefix}#{line_string}"
33
- end
34
-
35
- lines.join().chomp()
36
- rescue
37
- return (options[:unknown] || "Unknown") if not location[:file] and not location[:line]
38
- return location[:file] if not location[:line]
39
-
40
- "#{location[:file]}:#{location[:line]}"
41
- ensure
42
- file.close() if file
43
- end
44
-
45
- ##
46
- # Search a stack list (as simple string array) for the first
47
- # entry that match the +:matcher+.
48
- #
49
- def self.find_entry(stack, options = {})
50
- matcher = options[:matcher] || @@DEFAULT_MATCHER
51
-
52
- stack.find do |entry|
53
- entry =~ matcher
54
- end
55
- end
56
-
57
- ##
58
- # Extract error location information from a stack entry using the
59
- # matcher received in arguments.
60
- #
61
- # The usual stack entry format is:
62
- # > /home/users/joe/work/lib/ruby.rb:4:Error message
63
- #
64
- # This function will extract the file and line information from
65
- # the stack entry using the matcher. The matcher is expected to
66
- # have two groups, the first for the file and the second for
67
- # line.
68
- #
69
- # The results is returned in form of a hash with two keys, +:file+
70
- # for the file information and +:line+ for the line information.
71
- #
72
- # If the matcher matched zero group, return +{:file => nil, :line => nil}+.
73
- # If the matcher matched one group, return +{:file => file, :line => nil}+.
74
- # If the matcher matched two groups, return +{:file => file, :line => line}+.
75
- #
76
- def self.extract_error_location(entry, options = {})
77
- matcher = options[:matcher] || @@DEFAULT_MATCHER
78
-
79
- result = matcher.match(entry)
80
- captures = result ? result.captures : []
81
-
82
- {:file => captures[0], :line => captures[1] ? captures[1].to_i() : nil}
83
- end
84
- end
85
- end
86
- end
1
+ module Nugrant
2
+ module Helper
3
+ class Stack
4
+ @@DEFAULT_MATCHER = /^(.+):([0-9]+)/
5
+
6
+ def self.fetch_error_region(stack, options = {})
7
+ entry = find_entry(stack, options)
8
+ location = extract_error_location(entry, options)
9
+
10
+ return (options[:unknown] || "Unknown") if not location[:file] and not location[:line]
11
+ return location[:file] if not location[:line]
12
+
13
+ fetch_error_region_from_location(location, options)
14
+ end
15
+
16
+ def self.fetch_error_region_from_location(location, options = {})
17
+ prefix = options[:prefix] || " "
18
+ width = options[:width] || 4
19
+ file = File.new(location[:file], "r")
20
+ line = location[:line]
21
+
22
+ index = 0
23
+
24
+ lines = []
25
+ while (line_string = file.gets())
26
+ index += 1
27
+ next if (line - index).abs > width
28
+
29
+ line_prefix = "#{prefix}#{index}:"
30
+ line_prefix += (line == index ? ">> " : " ")
31
+
32
+ lines << "#{line_prefix}#{line_string}"
33
+ end
34
+
35
+ lines.join().chomp()
36
+ rescue
37
+ return (options[:unknown] || "Unknown") if not location[:file] and not location[:line]
38
+ return location[:file] if not location[:line]
39
+
40
+ "#{location[:file]}:#{location[:line]}"
41
+ ensure
42
+ file.close() if file
43
+ end
44
+
45
+ ##
46
+ # Search a stack list (as simple string array) for the first
47
+ # entry that match the +:matcher+.
48
+ #
49
+ def self.find_entry(stack, options = {})
50
+ matcher = options[:matcher] || @@DEFAULT_MATCHER
51
+
52
+ stack.find do |entry|
53
+ entry =~ matcher
54
+ end
55
+ end
56
+
57
+ ##
58
+ # Extract error location information from a stack entry using the
59
+ # matcher received in arguments.
60
+ #
61
+ # The usual stack entry format is:
62
+ # > /home/users/joe/work/lib/ruby.rb:4:Error message
63
+ #
64
+ # This function will extract the file and line information from
65
+ # the stack entry using the matcher. The matcher is expected to
66
+ # have two groups, the first for the file and the second for
67
+ # line.
68
+ #
69
+ # The results is returned in form of a hash with two keys, +:file+
70
+ # for the file information and +:line+ for the line information.
71
+ #
72
+ # If the matcher matched zero group, return +{:file => nil, :line => nil}+.
73
+ # If the matcher matched one group, return +{:file => file, :line => nil}+.
74
+ # If the matcher matched two groups, return +{:file => file, :line => line}+.
75
+ #
76
+ def self.extract_error_location(entry, options = {})
77
+ matcher = options[:matcher] || @@DEFAULT_MATCHER
78
+
79
+ result = matcher.match(entry)
80
+ captures = result ? result.captures : []
81
+
82
+ {:file => captures[0], :line => captures[1] ? captures[1].to_i() : nil}
83
+ end
84
+ end
85
+ end
86
+ end
@@ -1,178 +1,178 @@
1
- require 'nugrant/bag'
2
- require 'nugrant/config'
3
- require 'nugrant/helper/bag'
4
-
5
- module Nugrant
6
- module Mixin
7
- ##
8
- # Mixin module so it's possible to share parameters
9
- # logic between default Parameters class and Vagrant
10
- # implementation.
11
- #
12
- # This module delegates method missing to the final
13
- # bag hierarchy (@__all). This means that even if the class
14
- # including this module doesn't inherit Bag directly,
15
- # it act exactly like one.
16
- #
17
- # When including this module, you must respect an important
18
- # constraint.
19
- #
20
- # The including class must call `setup!` before starting using
21
- # parameters retrieval. This is usually performed in
22
- # the `initialize` method directly but could be in a different place
23
- # depending on the including class lifecycle. The call to `setup!` is
24
- # important to initialize all required instance variables.
25
- #
26
- # Here an example where `setup!` is called in constructor. Your constructor
27
- # does not need to have these arguments, they are there as an example.
28
- #
29
- # ```
30
- # def initialize(defaults = {}, config = {}, options = {})
31
- # setup!(defaults, config, options)
32
- # end
33
- # ```
34
- #
35
- module Parameters
36
- attr_reader :__config, :__current, :__user, :__system, :__defaults, :__all
37
-
38
- def method_missing(method, *args, &block)
39
- case
40
- when @__all.class.method_defined?(method)
41
- @__all.send(method, *args, &block)
42
- else
43
- @__all[method]
44
- end
45
- end
46
-
47
- def array_merge_strategy
48
- @__config.array_merge_strategy
49
- end
50
-
51
- def auto_export
52
- @__config.auto_export
53
- end
54
-
55
- def auto_export_script_path
56
- @__config.auto_export_script_path
57
- end
58
-
59
- ##
60
- # Change the current array merge strategy for this parameters.
61
- #
62
- # @param strategy The new strategy to use.
63
- def array_merge_strategy=(strategy)
64
- return if not Nugrant::Config.supported_array_merge_strategy(strategy)
65
-
66
- @__config.array_merge_strategy = strategy
67
-
68
- # When array_merge_strategy change, we need to recompute parameters hierarchy
69
- compute_all!()
70
- end
71
-
72
- def auto_export=(auto_export)
73
- @__config.auto_export = auto_export
74
- end
75
-
76
- def auto_export_script_path=(path)
77
- @__config.auto_export_script_path = path
78
- end
79
-
80
- def defaults()
81
- @__defaults
82
- end
83
-
84
- ##
85
- # Set the new default values for the
86
- # various parameters contain by this instance.
87
- # This will call `compute_all!` to recompute
88
- # correct precedences.
89
- #
90
- # =| Attributes
91
- # * +elements+ - The new default elements
92
- #
93
- def defaults=(elements)
94
- @__defaults = Bag.new(elements, @__config)
95
-
96
- # When defaults change, we need to recompute parameters hierarchy
97
- compute_all!()
98
- end
99
-
100
- def merge(other)
101
- result = dup()
102
- result.merge!(other)
103
- end
104
-
105
- def merge!(other)
106
- @__config.merge!(other.__config)
107
-
108
- # Updated Bags' config
109
- @__current.config = @__config
110
- @__user.config = @__config
111
- @__system.config = @__config
112
- @__defaults.config = @__config
113
-
114
- # Merge other into Bags
115
- @__current.merge!(other.__current, :array_merge_strategy => :replace)
116
- @__user.merge!(other.__user, :array_merge_strategy => :replace)
117
- @__system.merge!(other.__system, :array_merge_strategy => :replace)
118
- @__defaults.merge!(other.__defaults, :array_merge_strategy => :replace)
119
-
120
- # Recompute all from merged Bags
121
- compute_all!()
122
-
123
- self
124
- end
125
-
126
- ##
127
- # Setup instance variables of the mixin. It will compute all parameters bags
128
- # (current, user, system, default and all) and stored them to these respective
129
- # instance variables:
130
- #
131
- # * @__current
132
- # * @__user
133
- # * @__system
134
- # * @__defaults
135
- #
136
- # =| Arguments
137
- # * `defaults`
138
- # A hash that is used as the initial data for the defaults bag. Defaults
139
- # to an empty hash.
140
- #
141
- # * `config`
142
- # A Nugrant::Config object or hash passed to Nugrant::Config
143
- # convert method. Used to determine where to find the various
144
- # bag data sources and other configuration options.
145
- #
146
- # Passed to nested structures that requires a Nugrant::Config object
147
- # like the Bag object and Helper::Bag module.
148
- #
149
- # * `options`
150
- # Options hash used by this method exclusively. No options yet, added
151
- # for future improvements.
152
- #
153
- def setup!(defaults = {}, config = {}, options = {})
154
- @__config = Nugrant::Config::convert(config);
155
-
156
- @__defaults = Bag.new(defaults, @__config)
157
- @__current = Helper::Bag.read(@__config.current_path, @__config.params_format, @__config)
158
- @__user = Helper::Bag.read(@__config.user_path, @__config.params_format, @__config)
159
- @__system = Helper::Bag.read(@__config.system_path, @__config.params_format, @__config)
160
-
161
- compute_all!()
162
- end
163
-
164
- ##
165
- # Recompute the correct precedences by merging the various
166
- # bag in the right order and return the result as a Nugrant::Bag
167
- # object.
168
- #
169
- def compute_all!()
170
- @__all = Bag.new({}, @__config)
171
- @__all.merge!(@__defaults)
172
- @__all.merge!(@__system)
173
- @__all.merge!(@__user)
174
- @__all.merge!(@__current)
175
- end
176
- end
177
- end
178
- end
1
+ require 'nugrant/bag'
2
+ require 'nugrant/config'
3
+ require 'nugrant/helper/bag'
4
+
5
+ module Nugrant
6
+ module Mixin
7
+ ##
8
+ # Mixin module so it's possible to share parameters
9
+ # logic between default Parameters class and Vagrant
10
+ # implementation.
11
+ #
12
+ # This module delegates method missing to the final
13
+ # bag hierarchy (@__all). This means that even if the class
14
+ # including this module doesn't inherit Bag directly,
15
+ # it act exactly like one.
16
+ #
17
+ # When including this module, you must respect an important
18
+ # constraint.
19
+ #
20
+ # The including class must call `setup!` before starting using
21
+ # parameters retrieval. This is usually performed in
22
+ # the `initialize` method directly but could be in a different place
23
+ # depending on the including class lifecycle. The call to `setup!` is
24
+ # important to initialize all required instance variables.
25
+ #
26
+ # Here an example where `setup!` is called in constructor. Your constructor
27
+ # does not need to have these arguments, they are there as an example.
28
+ #
29
+ # ```
30
+ # def initialize(defaults = {}, config = {}, options = {})
31
+ # setup!(defaults, config, options)
32
+ # end
33
+ # ```
34
+ #
35
+ module Parameters
36
+ attr_reader :__config, :__current, :__user, :__system, :__defaults, :__all
37
+
38
+ def method_missing(method, *args, &block)
39
+ case
40
+ when @__all.class.method_defined?(method)
41
+ @__all.send(method, *args, &block)
42
+ else
43
+ @__all[method]
44
+ end
45
+ end
46
+
47
+ def array_merge_strategy
48
+ @__config.array_merge_strategy
49
+ end
50
+
51
+ def auto_export
52
+ @__config.auto_export
53
+ end
54
+
55
+ def auto_export_script_path
56
+ @__config.auto_export_script_path
57
+ end
58
+
59
+ ##
60
+ # Change the current array merge strategy for this parameters.
61
+ #
62
+ # @param strategy The new strategy to use.
63
+ def array_merge_strategy=(strategy)
64
+ return if not Nugrant::Config.supported_array_merge_strategy(strategy)
65
+
66
+ @__config.array_merge_strategy = strategy
67
+
68
+ # When array_merge_strategy change, we need to recompute parameters hierarchy
69
+ compute_all!()
70
+ end
71
+
72
+ def auto_export=(auto_export)
73
+ @__config.auto_export = auto_export
74
+ end
75
+
76
+ def auto_export_script_path=(path)
77
+ @__config.auto_export_script_path = path
78
+ end
79
+
80
+ def defaults()
81
+ @__defaults
82
+ end
83
+
84
+ ##
85
+ # Set the new default values for the
86
+ # various parameters contain by this instance.
87
+ # This will call `compute_all!` to recompute
88
+ # correct precedences.
89
+ #
90
+ # =| Attributes
91
+ # * +elements+ - The new default elements
92
+ #
93
+ def defaults=(elements)
94
+ @__defaults = Bag.new(elements, @__config)
95
+
96
+ # When defaults change, we need to recompute parameters hierarchy
97
+ compute_all!()
98
+ end
99
+
100
+ def merge(other)
101
+ result = dup()
102
+ result.merge!(other)
103
+ end
104
+
105
+ def merge!(other)
106
+ @__config.merge!(other.__config)
107
+
108
+ # Updated Bags' config
109
+ @__current.config = @__config
110
+ @__user.config = @__config
111
+ @__system.config = @__config
112
+ @__defaults.config = @__config
113
+
114
+ # Merge other into Bags
115
+ @__current.merge!(other.__current, :array_merge_strategy => :replace)
116
+ @__user.merge!(other.__user, :array_merge_strategy => :replace)
117
+ @__system.merge!(other.__system, :array_merge_strategy => :replace)
118
+ @__defaults.merge!(other.__defaults, :array_merge_strategy => :replace)
119
+
120
+ # Recompute all from merged Bags
121
+ compute_all!()
122
+
123
+ self
124
+ end
125
+
126
+ ##
127
+ # Setup instance variables of the mixin. It will compute all parameters bags
128
+ # (current, user, system, default and all) and stored them to these respective
129
+ # instance variables:
130
+ #
131
+ # * @__current
132
+ # * @__user
133
+ # * @__system
134
+ # * @__defaults
135
+ #
136
+ # =| Arguments
137
+ # * `defaults`
138
+ # A hash that is used as the initial data for the defaults bag. Defaults
139
+ # to an empty hash.
140
+ #
141
+ # * `config`
142
+ # A Nugrant::Config object or hash passed to Nugrant::Config
143
+ # convert method. Used to determine where to find the various
144
+ # bag data sources and other configuration options.
145
+ #
146
+ # Passed to nested structures that requires a Nugrant::Config object
147
+ # like the Bag object and Helper::Bag module.
148
+ #
149
+ # * `options`
150
+ # Options hash used by this method exclusively. No options yet, added
151
+ # for future improvements.
152
+ #
153
+ def setup!(defaults = {}, config = {}, options = {})
154
+ @__config = Nugrant::Config::convert(config);
155
+
156
+ @__defaults = Bag.new(defaults, @__config)
157
+ @__current = Helper::Bag.read(@__config.current_path, @__config.params_format, @__config)
158
+ @__user = Helper::Bag.read(@__config.user_path, @__config.params_format, @__config)
159
+ @__system = Helper::Bag.read(@__config.system_path, @__config.params_format, @__config)
160
+
161
+ compute_all!()
162
+ end
163
+
164
+ ##
165
+ # Recompute the correct precedences by merging the various
166
+ # bag in the right order and return the result as a Nugrant::Bag
167
+ # object.
168
+ #
169
+ def compute_all!()
170
+ @__all = Bag.new({}, @__config)
171
+ @__all.merge!(@__defaults)
172
+ @__all.merge!(@__system)
173
+ @__all.merge!(@__user)
174
+ @__all.merge!(@__current)
175
+ end
176
+ end
177
+ end
178
+ end
@@ -1,29 +1,29 @@
1
- require 'nugrant/mixin/parameters'
2
-
3
- module Nugrant
4
- class Parameters
5
-
6
- include Mixin::Parameters
7
-
8
- ##
9
- # Create a new parameters object which holds completed
10
- # merged values. The following precedence is used to decide
11
- # which location has precedence over which location:
12
- #
13
- # (Highest) ------------------ (Lowest)
14
- # project < user < system < defaults
15
- #
16
- # =| Arguments
17
- # * `defaults`
18
- # Passed to Mixin::Parameters setup! method. See mixin
19
- # module for further information.
20
- #
21
- # * `config`
22
- # Passed to Mixin::Parameters setup! method. See mixin
23
- # module for further information.
24
- #
25
- def initialize(defaults = {}, config = {}, options = {})
26
- setup!(defaults, config, options)
27
- end
28
- end
29
- end
1
+ require 'nugrant/mixin/parameters'
2
+
3
+ module Nugrant
4
+ class Parameters
5
+
6
+ include Mixin::Parameters
7
+
8
+ ##
9
+ # Create a new parameters object which holds completed
10
+ # merged values. The following precedence is used to decide
11
+ # which location has precedence over which location:
12
+ #
13
+ # (Highest) ------------------ (Lowest)
14
+ # project < user < system < defaults
15
+ #
16
+ # =| Arguments
17
+ # * `defaults`
18
+ # Passed to Mixin::Parameters setup! method. See mixin
19
+ # module for further information.
20
+ #
21
+ # * `config`
22
+ # Passed to Mixin::Parameters setup! method. See mixin
23
+ # module for further information.
24
+ #
25
+ def initialize(defaults = {}, config = {}, options = {})
26
+ setup!(defaults, config, options)
27
+ end
28
+ end
29
+ end
@@ -1,35 +1,35 @@
1
- require 'vagrant/errors'
2
-
3
- require 'nugrant/helper/stack'
4
-
5
- module Nugrant
6
- module Vagrant
7
- module Errors
8
- class NugrantVagrantError < ::Vagrant::Errors::VagrantError
9
- error_namespace("nugrant.vagrant.errors")
10
-
11
- def compute_context()
12
- Helper::Stack.fetch_error_region(caller(), {
13
- :matcher => /(.+Vagrantfile):([0-9]+)/
14
- })
15
- end
16
- end
17
-
18
- class ParameterNotFoundError < NugrantVagrantError
19
- error_key(:parameter_not_found)
20
-
21
- def initialize(options = nil, *args)
22
- super({:context => compute_context()}.merge(options || {}), *args)
23
- end
24
- end
25
-
26
- class VagrantUserParseError < NugrantVagrantError
27
- error_key(:parse_error)
28
-
29
- def initialize(options = nil, *args)
30
- super(options, *args)
31
- end
32
- end
33
- end
34
- end
35
- end
1
+ require 'vagrant/errors'
2
+
3
+ require 'nugrant/helper/stack'
4
+
5
+ module Nugrant
6
+ module Vagrant
7
+ module Errors
8
+ class NugrantVagrantError < ::Vagrant::Errors::VagrantError
9
+ error_namespace("nugrant.vagrant.errors")
10
+
11
+ def compute_context()
12
+ Helper::Stack.fetch_error_region(caller(), {
13
+ :matcher => /(.+Vagrantfile):([0-9]+)/
14
+ })
15
+ end
16
+ end
17
+
18
+ class ParameterNotFoundError < NugrantVagrantError
19
+ error_key(:parameter_not_found)
20
+
21
+ def initialize(options = nil, *args)
22
+ super({:context => compute_context()}.merge(options || {}), *args)
23
+ end
24
+ end
25
+
26
+ class VagrantUserParseError < NugrantVagrantError
27
+ error_key(:parse_error)
28
+
29
+ def initialize(options = nil, *args)
30
+ super(options, *args)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end