nugrant 1.4.2 → 2.0.0.dev1

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 (72) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -2
  3. data/.travis.yml +0 -6
  4. data/CHANGELOG.md +3 -79
  5. data/Gemfile +8 -8
  6. data/README.md +10 -146
  7. data/lib/nugrant.rb +4 -19
  8. data/lib/nugrant/bag.rb +8 -12
  9. data/lib/nugrant/config.rb +55 -24
  10. data/lib/nugrant/helper/bag.rb +19 -17
  11. data/lib/nugrant/parameters.rb +37 -9
  12. data/lib/nugrant/vagrant/v1/command/parameters.rb +13 -13
  13. data/lib/nugrant/vagrant/v1/command/root.rb +2 -7
  14. data/lib/nugrant/vagrant/v1/config/user.rb +1 -10
  15. data/lib/nugrant/vagrant/v2/command/parameters.rb +1 -1
  16. data/lib/nugrant/vagrant/v2/command/root.rb +2 -7
  17. data/lib/nugrant/vagrant/v2/config/user.rb +1 -10
  18. data/lib/nugrant/version.rb +1 -1
  19. data/nugrant.gemspec +1 -4
  20. data/test/lib/nugrant/test_bag.rb +19 -33
  21. data/test/lib/nugrant/test_config.rb +92 -100
  22. data/test/lib/nugrant/test_parameters.rb +186 -203
  23. data/test/resources/README.md +11 -11
  24. data/test/resources/{vagrantfiles/v1.empty → Vagrantfile.v1.empty} +0 -0
  25. data/test/resources/{vagrantfiles/v1.fake → Vagrantfile.v1.fake} +0 -0
  26. data/test/resources/{vagrantfiles/v1.real → Vagrantfile.v1.real} +0 -0
  27. data/test/resources/{vagrantfiles/v2.empty → Vagrantfile.v2.empty} +0 -0
  28. data/test/resources/{vagrantfiles/v2.fake → Vagrantfile.v2.fake} +1 -4
  29. data/test/resources/{vagrantfiles/v2.real → Vagrantfile.v2.real} +0 -0
  30. data/test/resources/json/params_current_1.json +6 -0
  31. data/test/resources/json/params_current_2.json +29 -0
  32. data/test/resources/{yml → yaml}/params_array.yml +0 -0
  33. data/test/resources/{yml → yaml}/params_boolean.yml +0 -0
  34. data/test/resources/{yml → yaml}/params_combinations.yml +0 -0
  35. data/test/resources/yaml/params_current_1.yml +4 -0
  36. data/test/resources/yaml/params_current_2.yml +23 -0
  37. data/test/resources/{yml → yaml}/params_defaults_at_root.yml +0 -0
  38. data/test/resources/{yml → yaml}/params_defaults_not_at_root.yml +0 -0
  39. data/test/resources/{yml → yaml}/params_empty.yml +0 -0
  40. data/test/resources/{yml → yaml}/params_list.yml +0 -0
  41. data/test/resources/{yml → yaml}/params_simple.yml +0 -0
  42. data/test/resources/{yml → yaml}/params_system_1.yml +0 -0
  43. data/test/resources/{yml → yaml}/params_system_2.yml +0 -0
  44. data/test/resources/{yml → yaml}/params_unix_eol.yml +0 -0
  45. data/test/resources/{yml → yaml}/params_user_1.yml +0 -0
  46. data/test/resources/{yml → yaml}/params_user_2.yml +0 -0
  47. data/test/resources/{yml → yaml}/params_windows_eol.yml +0 -0
  48. metadata +71 -95
  49. data/lib/nugrant/helper/env/exporter.rb +0 -208
  50. data/lib/nugrant/helper/env/namer.rb +0 -47
  51. data/lib/nugrant/helper/stack.rb +0 -86
  52. data/lib/nugrant/vagrant/errors.rb +0 -27
  53. data/lib/nugrant/vagrant/v1/command/env.rb +0 -107
  54. data/lib/nugrant/vagrant/v2/command/env.rb +0 -107
  55. data/locales/en.yml +0 -13
  56. data/test/lib/nugrant/helper/env/test_exporter.rb +0 -238
  57. data/test/lib/nugrant/helper/test_stack.rb +0 -149
  58. data/test/resources/json/params_project_1.json +0 -6
  59. data/test/resources/json/params_project_2.json +0 -29
  60. data/test/resources/json/params_user_nil_values.json +0 -9
  61. data/test/resources/vagrantfiles/v1.defaults_mixed_string_symbols +0 -18
  62. data/test/resources/vagrantfiles/v1.defaults_using_string +0 -18
  63. data/test/resources/vagrantfiles/v1.defaults_using_symbol +0 -18
  64. data/test/resources/vagrantfiles/v1.missing_parameter +0 -3
  65. data/test/resources/vagrantfiles/v2.defaults_mixed_string_symbols +0 -20
  66. data/test/resources/vagrantfiles/v2.defaults_null_values_in_vagrantuser +0 -25
  67. data/test/resources/vagrantfiles/v2.defaults_using_string +0 -20
  68. data/test/resources/vagrantfiles/v2.defaults_using_symbol +0 -20
  69. data/test/resources/vagrantfiles/v2.missing_parameter +0 -5
  70. data/test/resources/yml/params_project_1.yml +0 -4
  71. data/test/resources/yml/params_project_2.yml +0 -23
  72. data/test/resources/yml/params_user_nil_values.yml +0 -5
@@ -1,149 +0,0 @@
1
- require 'minitest/autorun'
2
-
3
- require 'nugrant/helper/stack'
4
-
5
- module Nugrant
6
- module Helper
7
- class TestStack < ::Minitest::Test
8
- def assert_error_location(expected, entry, matcher = nil)
9
- assert_equal(expected, Stack::extract_error_location(entry, :matcher => matcher))
10
- end
11
-
12
- def assert_error_region(expected, region)
13
- expected_lines = expected.split()
14
- region_lines = region.split()
15
-
16
- assert_equal(expected_lines.length(), region_lines.length())
17
-
18
- expected_lines.each_with_index do |expected_line, index|
19
- assert_equal(expected_line.strip(), region_lines[index].strip())
20
- end
21
- end
22
-
23
- def create_stack(options = {})
24
- pattern = options[:pattern] || "Vagrantfile:%s"
25
- count = options[:count] || 4
26
-
27
- stack = []
28
- (0..count).each do |index|
29
- stack << pattern.gsub("%s", index.to_s())
30
- end
31
-
32
- stack
33
- end
34
-
35
- def create_location(name, line)
36
- resource_path = File.expand_path("#{File.dirname(__FILE__)}/../../../resources/vagrantfiles")
37
-
38
- {:file => "#{resource_path}/#{name}", :line => line}
39
- end
40
-
41
- def test_fetch_error_region_from_location()
42
- location = create_location("v1.defaults_using_symbol", 4)
43
- error_region = Stack::fetch_error_region_from_location(location)
44
- expected_region = <<-EOT
45
- 1: Vagrant::Config.run do |config|
46
- 2: config.user.defaults = {
47
- 3: :single => 1,
48
- 4:>> :local => {
49
- 5: :first => "value1",
50
- 6: :second => "value2"
51
- 7: }
52
- 8: }
53
- EOT
54
-
55
- assert_error_region(expected_region, error_region)
56
- end
57
-
58
- def test_fetch_error_region_from_location_custom_prefix()
59
- location = create_location("v1.defaults_using_symbol", 4)
60
- error_region = Stack::fetch_error_region_from_location(location, :prefix => "**")
61
- expected_region = <<-EOT
62
- **1: Vagrant::Config.run do |config|
63
- **2: config.user.defaults = {
64
- **3: :single => 1,
65
- **4:>> :local => {
66
- **5: :first => "value1",
67
- **6: :second => "value2"
68
- **7: }
69
- **8: }
70
- EOT
71
-
72
- assert_error_region(expected_region, error_region)
73
- end
74
-
75
- def test_fetch_error_region_from_location_custom_width()
76
- location = create_location("v1.defaults_using_symbol", 4)
77
- error_region = Stack::fetch_error_region_from_location(location, :width => 2)
78
- expected_region = <<-EOT
79
- 2: config.user.defaults = {
80
- 3: :single => 1,
81
- 4:>> :local => {
82
- 5: :first => "value1",
83
- 6: :second => "value2"
84
- EOT
85
-
86
- assert_error_region(expected_region, error_region)
87
- end
88
-
89
- def test_fetch_error_region_from_location_wrong_location()
90
- location = {:file => nil, :line => nil}
91
- assert_equal("Unknown", Stack::fetch_error_region_from_location(location))
92
- assert_equal("Failed", Stack::fetch_error_region_from_location(location, :unknown => "Failed"))
93
-
94
- location = {:file => "Vagrantfile", :line => nil}
95
- assert_equal("Vagrantfile", Stack::fetch_error_region_from_location(location))
96
-
97
- location = {:file => "NonExistingVagrantfile", :line => 4}
98
- assert_equal("NonExistingVagrantfile:4", Stack::fetch_error_region_from_location(location))
99
- end
100
-
101
- def test_find_entry()
102
- entries = ["First", "Second:", "Third:a", "Fourth:4"]
103
-
104
- assert_equal("Fourth:4", Stack::find_entry(entries))
105
- assert_equal("Third:a", Stack::find_entry(entries, :matcher => /^(.+):([a-z]+)/))
106
- end
107
-
108
- def test_extract_error_location_default_matcher()
109
- # Matches
110
- assert_error_location({:file => "/work/irb/workspace.rb", :line => 80}, "/work/irb/workspace.rb:80:in `eval'")
111
- assert_error_location({:file => "workspace.rb", :line => 80}, "workspace.rb:80:in `eval'")
112
- assert_error_location({:file => "/work/irb/workspace.rb", :line => 80}, "/work/irb/workspace.rb:80")
113
-
114
- # No match
115
- assert_error_location({:file => nil, :line => nil}, "/work/irb/workspace.rb?80")
116
- assert_error_location({:file => nil, :line => nil}, "/work/irb/workspace.rb")
117
- assert_error_location({:file =>nil, :line => nil}, "")
118
- end
119
-
120
- def test_extract_error_location_custom_matcher()
121
- # Matches
122
- assert_error_location(
123
- {:file => "/work/Vagrantfile", :line => 80},
124
- "/work/Vagrantfile:80:in `eval'",
125
- /(.*Vagrantfile):([0-9]+)/
126
- )
127
-
128
- assert_error_location(
129
- {:file => "Vagrantfile", :line => 80},
130
- "Vagrantfile:80:in `eval'",
131
- /(.*Vagrantfile):([0-9]+)/
132
- )
133
-
134
- assert_error_location(
135
- {:file => "/work/irb/Vagrantfile", :line => 80},
136
- "/work/irb/Vagrantfile:80",
137
- /(.*Vagrantfile):([0-9]+)/
138
- )
139
-
140
- # Partial match
141
- assert_error_location(
142
- {:file => "/work/Vagrantfile", :line => nil},
143
- "/work/Vagrantfile:80:in `eval'",
144
- /(.*Vagrantfile)/
145
- )
146
- end
147
- end
148
- end
149
- end
@@ -1,6 +0,0 @@
1
- {
2
- "1.1.1": "project",
3
- "1.1.0": "project",
4
- "1.0.1": "project",
5
- "1.0.0": "project"
6
- }
@@ -1,29 +0,0 @@
1
- {
2
- "1.1.1": {
3
- "1.1.1": "project",
4
- "1.1.0": "project",
5
- "1.0.1": "project",
6
- "1.0.0": "project"
7
- },
8
-
9
- "1.1.0": {
10
- "1.1.1": "project",
11
- "1.1.0": "project",
12
- "1.0.1": "project",
13
- "1.0.0": "project"
14
- },
15
-
16
- "1.0.1": {
17
- "1.1.1": "project",
18
- "1.1.0": "project",
19
- "1.0.1": "project",
20
- "1.0.0": "project"
21
- },
22
-
23
- "1.0.0": {
24
- "1.1.1": "project",
25
- "1.1.0": "project",
26
- "1.0.1": "project",
27
- "1.0.0": "project"
28
- }
29
- }
@@ -1,9 +0,0 @@
1
- {
2
- "nil": null,
3
- "deep": {
4
- "nil": null,
5
- "deeper": {
6
- "nil": null
7
- }
8
- }
9
- }
@@ -1,18 +0,0 @@
1
- Vagrant::Config.run do |config|
2
- config.user.defaults = {
3
- 'single' => 1,
4
- :local => {
5
- 'first' => "value1",
6
- :second => "value2"
7
- }
8
- }
9
-
10
- puts config.user.single
11
- puts config.user[:single]
12
-
13
- puts config.user.local.first
14
- puts config.user[:local]["first"]
15
-
16
- puts config.user.local.second
17
- puts config.user["local"][:second]
18
- end
@@ -1,18 +0,0 @@
1
- Vagrant::Config.run do |config|
2
- config.user.defaults = {
3
- 'single' => 1,
4
- 'local' => {
5
- 'first' => "value1",
6
- 'second' => "value2"
7
- }
8
- }
9
-
10
- puts config.user.single
11
- puts config.user[:single]
12
-
13
- puts config.user.local.first
14
- puts config.user[:local]["first"]
15
-
16
- puts config.user.local.second
17
- puts config.user["local"][:second]
18
- end
@@ -1,18 +0,0 @@
1
- Vagrant::Config.run do |config|
2
- config.user.defaults = {
3
- :single => 1,
4
- :local => {
5
- :first => "value1",
6
- :second => "value2"
7
- }
8
- }
9
-
10
- puts config.user.single
11
- puts config.user[:single]
12
-
13
- puts config.user.local.first
14
- puts config.user[:local]["first"]
15
-
16
- puts config.user.local.second
17
- puts config.user["local"][:second]
18
- end
@@ -1,3 +0,0 @@
1
- Vagrant::Config.run do |config|
2
- puts config.user.unkown_for_sure
3
- end
@@ -1,20 +0,0 @@
1
- Vagrant.require_plugin('nugrant')
2
-
3
- Vagrant.configure("2") do |config|
4
- config.user.defaults = {
5
- 'single' => 1,
6
- :local => {
7
- 'first' => "value1",
8
- :second => "value2"
9
- }
10
- }
11
-
12
- puts config.user.single
13
- puts config.user[:single]
14
-
15
- puts config.user.local.first
16
- puts config.user[:local]["first"]
17
-
18
- puts config.user.local.second
19
- puts config.user["local"][:second]
20
- end
@@ -1,25 +0,0 @@
1
- # Source from https://github.com/maoueh/nugrant/issues/12#issuecomment-27054150
2
- # but slightly modified
3
- Vagrant.require_plugin('nugrant')
4
-
5
- Vagrant.configure('2') do |config|
6
- config.user.defaults = {
7
- "host" => {
8
- "rails_server_port" => 3000,
9
- "apps_folder" => "../../rails-apps/" },
10
- "plugins" => {
11
- "vagrant_cachier" => {
12
- "enabled" => false
13
- }
14
- }
15
- }
16
-
17
- puts "Host Rails Server Port: #{config.user.host.rails_server_port}"
18
- puts "Host App Folder: #{config.user.host.apps_folder}"
19
- puts "Gitconfig Name: #{config.user.gitconfig.name}"
20
- puts "Gitconfig Email: #{config.user.gitconfig.email}"
21
-
22
- if config.user.plugins.vagrant_cachier.enabled
23
- puts "Vagrant Cachier is Enabled!"
24
- end
25
- end
@@ -1,20 +0,0 @@
1
- Vagrant.require_plugin('nugrant')
2
-
3
- Vagrant.configure("2") do |config|
4
- config.user.defaults = {
5
- 'single' => 1,
6
- 'local' => {
7
- 'first' => "value1",
8
- 'second' => "value2"
9
- }
10
- }
11
-
12
- puts config.user.single
13
- puts config.user[:single]
14
-
15
- puts config.user.local.first
16
- puts config.user[:local]["first"]
17
-
18
- puts config.user.local.second
19
- puts config.user["local"][:second]
20
- end
@@ -1,20 +0,0 @@
1
- Vagrant.require_plugin('nugrant')
2
-
3
- Vagrant.configure("2") do |config|
4
- config.user.defaults = {
5
- :single => 1,
6
- :local => {
7
- :first => "value1",
8
- :second => "value2"
9
- }
10
- }
11
-
12
- puts config.user.single
13
- puts config.user[:single]
14
-
15
- puts config.user.local.first
16
- puts config.user[:local]["first"]
17
-
18
- puts config.user.local.second
19
- puts config.user["local"][:second]
20
- end
@@ -1,5 +0,0 @@
1
- Vagrant.require_plugin('nugrant')
2
-
3
- Vagrant.configure("2") do |config|
4
- puts config.user.unkown_for_sure
5
- end
@@ -1,4 +0,0 @@
1
- "1.1.1": "project"
2
- "1.1.0": "project"
3
- "1.0.1": "project"
4
- "1.0.0": "project"
@@ -1,23 +0,0 @@
1
- "1.1.1":
2
- "1.1.1": "project"
3
- "1.1.0": "project"
4
- "1.0.1": "project"
5
- "1.0.0": "project"
6
-
7
- "1.1.0":
8
- "1.1.1": "project"
9
- "1.1.0": "project"
10
- "1.0.1": "project"
11
- "1.0.0": "project"
12
-
13
- "1.0.1":
14
- "1.1.1": "project"
15
- "1.1.0": "project"
16
- "1.0.1": "project"
17
- "1.0.0": "project"
18
-
19
- "1.0.0":
20
- "1.1.1": "project"
21
- "1.1.0": "project"
22
- "1.0.1": "project"
23
- "1.0.0": "project"
@@ -1,5 +0,0 @@
1
- nil:
2
- deep:
3
- nil:
4
- deeper:
5
- nil: