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,45 +1,45 @@
1
- require 'nugrant'
2
- require 'nugrant/helper/env/exporter'
3
- require 'nugrant/parameters'
4
-
5
- module Nugrant
6
- module Vagrant
7
- module V2
8
- module Action
9
- EnvExporter = Nugrant::Helper::Env::Exporter
10
-
11
- class AutoExport
12
- def initialize(app, env)
13
- @app = app
14
- @config = env[:machine].env.vagrantfile.config
15
- end
16
-
17
- def call(env)
18
- return @app.call(env) if not @config.user.auto_export
19
-
20
- options = {
21
- :type => :export,
22
- :script_path => @config.user.auto_export_script_path
23
- }
24
-
25
- Array(@config.user.auto_export).each do |exporter|
26
- if exporter == :terminal or not EnvExporter.valid?(exporter)
27
- env[:ui].warn("ERROR: Invalid config.user.auto_export value '#{exporter}'", :prefix => false)
28
- next
29
- end
30
-
31
- env[:ui].info("Configuration exported '#{exporter}'", :prefix => false)
32
-
33
- case
34
- when exporter == :script
35
- EnvExporter.script_exporter(@config.user.__all, options)
36
- when exporter == :autoenv
37
- EnvExporter.autoenv_exporter(@config.user.__all, options)
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
1
+ require 'nugrant'
2
+ require 'nugrant/helper/env/exporter'
3
+ require 'nugrant/parameters'
4
+
5
+ module Nugrant
6
+ module Vagrant
7
+ module V2
8
+ module Action
9
+ EnvExporter = Nugrant::Helper::Env::Exporter
10
+
11
+ class AutoExport
12
+ def initialize(app, env)
13
+ @app = app
14
+ @config = env[:machine].env.vagrantfile.config
15
+ end
16
+
17
+ def call(env)
18
+ return @app.call(env) if not @config.user.auto_export
19
+
20
+ options = {
21
+ :type => :export,
22
+ :script_path => @config.user.auto_export_script_path
23
+ }
24
+
25
+ Array(@config.user.auto_export).each do |exporter|
26
+ if exporter == :terminal or not EnvExporter.valid?(exporter)
27
+ env[:ui].warn("ERROR: Invalid config.user.auto_export value '#{exporter}'", :prefix => false)
28
+ next
29
+ end
30
+
31
+ env[:ui].info("Configuration exported '#{exporter}'", :prefix => false)
32
+
33
+ case
34
+ when exporter == :script
35
+ EnvExporter.script_exporter(@config.user.__all, options)
36
+ when exporter == :autoenv
37
+ EnvExporter.autoenv_exporter(@config.user.__all, options)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,17 +1,17 @@
1
- require 'nugrant/vagrant/v2/action/auto_export'
2
-
3
- module Nugrant
4
- module Vagrant
5
- module V2
6
- module Action
7
- class << self
8
- def auto_export
9
- @auto_export ||= ::Vagrant::Action::Builder.new.tap do |builder|
10
- builder.use Nugrant::Vagrant::V2::Action::AutoExport
11
- end
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end
1
+ require 'nugrant/vagrant/v2/action/auto_export'
2
+
3
+ module Nugrant
4
+ module Vagrant
5
+ module V2
6
+ module Action
7
+ class << self
8
+ def auto_export
9
+ @auto_export ||= ::Vagrant::Action::Builder.new.tap do |builder|
10
+ builder.use Nugrant::Vagrant::V2::Action::AutoExport
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,118 +1,118 @@
1
- require 'nugrant'
2
- require 'nugrant/helper/env/exporter'
3
- require 'nugrant/parameters'
4
-
5
- module Nugrant
6
- module Vagrant
7
- module V2
8
- module Command
9
- class Env < ::Vagrant.plugin("2", :command)
10
- EnvExporter = Nugrant::Helper::Env::Exporter
11
-
12
- def self.synopsis
13
- "env utilities to export config.user as environment variables in host machine"
14
- end
15
-
16
- def initialize(arguments, environment)
17
- super(arguments, environment)
18
-
19
- @unset = false
20
- @format = :terminal
21
- @script_path = false
22
- @show_help = false
23
- end
24
-
25
- def create_parser()
26
- return OptionParser.new do |parser|
27
- parser.banner = "Usage: vagrant user env [<options>]"
28
- parser.separator ""
29
-
30
- parser.separator "Outputs the commands that should be executed to export\n" +
31
- "the various parameter as environment variables. By default,\n" +
32
- "existing ones are overridden. The --format argument can be used\n" +
33
- "to choose in which format the variables should be displayed.\n" +
34
- "Changing the format will also change where they are displayed.\n"
35
- parser.separator ""
36
-
37
- parser.separator "Available options:"
38
- parser.separator ""
39
-
40
- parser.on("-u", "--unset", "Generates commands needed to unset environment variables, default false") do
41
- @unset = true
42
- end
43
-
44
- parser.on("-f", "--format FORMAT", "Determines in what format variables are output, default to terminal") do |format|
45
- @format = format.to_sym()
46
- end
47
-
48
- parser.on("-s", "--script-path PATH", "Specifies path of the generated bash script, default to #{EnvExporter::DEFAULT_SCRIPT_PATH}") do |path|
49
- @script_path = path
50
- end
51
-
52
- parser.on("-h", "--help", "Prints this help") do
53
- @show_help = true
54
- end
55
-
56
- parser.separator ""
57
- parser.separator "Available formats:"
58
- parser.separator " autoenv Write commands to a file named `.env` in the current directory."
59
- parser.separator " See https://github.com/kennethreitz/autoenv for more info."
60
- parser.separator " terminal Write commands to terminal so they can be sourced."
61
- parser.separator " script Write commands to a bash script named `nugrant2env.sh` so it can be sourced."
62
- parser.separator ""
63
- end
64
- end
65
-
66
- def error(message, parser)
67
- @env.ui.info("ERROR: #{message}", :prefix => false)
68
- @env.ui.info("", :prefix => false)
69
-
70
- help(parser)
71
-
72
- return 1
73
- end
74
-
75
- def help(parser)
76
- @env.ui.info(parser.help, :prefix => false)
77
- end
78
-
79
- def execute
80
- parser = create_parser()
81
- arguments = parse_options(parser)
82
-
83
- return error("Invalid format value '#{@format}'", parser) if not EnvExporter.valid?(@format)
84
- return help(parser) if @show_help
85
-
86
- @logger.debug("Nugrant 'Env'")
87
- with_target_vms(arguments) do |vm|
88
- parameters = vm.config.user
89
- if not parameters
90
- @env.ui.info("# Vm '#{vm.name}' : unable to retrieve `config.user`, report as bug https://github.com/maoueh/nugrant/issues", :prefix => false)
91
- next
92
- end
93
-
94
- bag = parameters.__all
95
-
96
- options = {
97
- :type => @unset ? :unset : :export,
98
- :script_path => @script_path
99
- }
100
-
101
- case
102
- when @format == :script
103
- EnvExporter.script_exporter(bag, options)
104
- when @format == :autoenv
105
- EnvExporter.autoenv_exporter(bag, options)
106
- when @format == :terminal
107
- EnvExporter.terminal_exporter(bag, options)
108
- end
109
-
110
- # No need to execute for the other VMs
111
- return 0
112
- end
113
- end
114
- end
115
- end
116
- end
117
- end
118
- end
1
+ require 'nugrant'
2
+ require 'nugrant/helper/env/exporter'
3
+ require 'nugrant/parameters'
4
+
5
+ module Nugrant
6
+ module Vagrant
7
+ module V2
8
+ module Command
9
+ class Env < ::Vagrant.plugin("2", :command)
10
+ EnvExporter = Nugrant::Helper::Env::Exporter
11
+
12
+ def self.synopsis
13
+ "env utilities to export config.user as environment variables in host machine"
14
+ end
15
+
16
+ def initialize(arguments, environment)
17
+ super(arguments, environment)
18
+
19
+ @unset = false
20
+ @format = :terminal
21
+ @script_path = false
22
+ @show_help = false
23
+ end
24
+
25
+ def create_parser()
26
+ return OptionParser.new do |parser|
27
+ parser.banner = "Usage: vagrant user env [<options>]"
28
+ parser.separator ""
29
+
30
+ parser.separator "Outputs the commands that should be executed to export\n" +
31
+ "the various parameter as environment variables. By default,\n" +
32
+ "existing ones are overridden. The --format argument can be used\n" +
33
+ "to choose in which format the variables should be displayed.\n" +
34
+ "Changing the format will also change where they are displayed.\n"
35
+ parser.separator ""
36
+
37
+ parser.separator "Available options:"
38
+ parser.separator ""
39
+
40
+ parser.on("-u", "--unset", "Generates commands needed to unset environment variables, default false") do
41
+ @unset = true
42
+ end
43
+
44
+ parser.on("-f", "--format FORMAT", "Determines in what format variables are output, default to terminal") do |format|
45
+ @format = format.to_sym()
46
+ end
47
+
48
+ parser.on("-s", "--script-path PATH", "Specifies path of the generated bash script, default to #{EnvExporter::DEFAULT_SCRIPT_PATH}") do |path|
49
+ @script_path = path
50
+ end
51
+
52
+ parser.on("-h", "--help", "Prints this help") do
53
+ @show_help = true
54
+ end
55
+
56
+ parser.separator ""
57
+ parser.separator "Available formats:"
58
+ parser.separator " autoenv Write commands to a file named `.env` in the current directory."
59
+ parser.separator " See https://github.com/kennethreitz/autoenv for more info."
60
+ parser.separator " terminal Write commands to terminal so they can be sourced."
61
+ parser.separator " script Write commands to a bash script named `nugrant2env.sh` so it can be sourced."
62
+ parser.separator ""
63
+ end
64
+ end
65
+
66
+ def error(message, parser)
67
+ @env.ui.info("ERROR: #{message}", :prefix => false)
68
+ @env.ui.info("", :prefix => false)
69
+
70
+ help(parser)
71
+
72
+ return 1
73
+ end
74
+
75
+ def help(parser)
76
+ @env.ui.info(parser.help, :prefix => false)
77
+ end
78
+
79
+ def execute
80
+ parser = create_parser()
81
+ arguments = parse_options(parser)
82
+
83
+ return error("Invalid format value '#{@format}'", parser) if not EnvExporter.valid?(@format)
84
+ return help(parser) if @show_help
85
+
86
+ @logger.debug("Nugrant 'Env'")
87
+ with_target_vms(arguments) do |vm|
88
+ parameters = vm.config.user
89
+ if not parameters
90
+ @env.ui.info("# Vm '#{vm.name}' : unable to retrieve `config.user`, report as bug https://github.com/maoueh/nugrant/issues", :prefix => false)
91
+ next
92
+ end
93
+
94
+ bag = parameters.__all
95
+
96
+ options = {
97
+ :type => @unset ? :unset : :export,
98
+ :script_path => @script_path
99
+ }
100
+
101
+ case
102
+ when @format == :script
103
+ EnvExporter.script_exporter(bag, options)
104
+ when @format == :autoenv
105
+ EnvExporter.autoenv_exporter(bag, options)
106
+ when @format == :terminal
107
+ EnvExporter.terminal_exporter(bag, options)
108
+ end
109
+
110
+ # No need to execute for the other VMs
111
+ return 0
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -1,153 +1,153 @@
1
- require 'nugrant'
2
- require 'nugrant/helper/yaml'
3
- require 'nugrant/vagrant/v2/helper'
4
-
5
- module Nugrant
6
- module Vagrant
7
- module V2
8
- module Command
9
- class Parameters < ::Vagrant.plugin("2", :command)
10
- def self.synopsis
11
- "prints parameters hierarchy as seen by Nugrant"
12
- end
13
-
14
- def initialize(arguments, environment)
15
- super(arguments, environment)
16
-
17
- @show_help = false
18
- @show_defaults = false
19
- @show_system = false
20
- @show_user = false
21
- @show_project = false
22
- end
23
-
24
- def create_parser()
25
- return OptionParser.new do |parser|
26
- parser.banner = "Usage: vagrant user parameters [<options>]"
27
- parser.separator ""
28
-
29
- parser.separator "Available options:"
30
- parser.separator ""
31
-
32
- parser.on("-h", "--help", "Prints this help") do
33
- @show_help = true
34
- end
35
-
36
- parser.on("-d", "--defaults", "Show only defaults parameters") do
37
- @show_defaults = true
38
- end
39
-
40
- parser.on("-s", "--system", "Show only system parameters") do
41
- @show_system = true
42
- end
43
-
44
- parser.on("-u", "--user", "Show only user parameters") do
45
- @show_user = true
46
- end
47
-
48
- parser.on("-p", "--project", "Show only project parameters") do
49
- @show_project = true
50
- end
51
-
52
- parser.separator ""
53
- parser.separator "When no options is provided, the command prints the names and values \n" +
54
- "of all parameters that would be available for usage in the Vagrantfile.\n" +
55
- "The hierarchy of the parameters is respected, so the final values are\n" +
56
- "displayed."
57
- end
58
- end
59
-
60
- def execute
61
- parser = create_parser()
62
- arguments = parse_options(parser)
63
-
64
- return help(parser) if @show_help
65
-
66
- @logger.debug("'Parameters' each target VM...")
67
- with_target_vms(arguments) do |vm|
68
- parameters = vm.config.user
69
- if not parameters
70
- @env.ui.info("# Vm '#{vm.name}' : unable to retrieve `config.user`, report as bug https://github.com/maoueh/nugrant/issues", :prefix => false)
71
- next
72
- end
73
-
74
- @env.ui.info("# Vm '#{vm.name}'", :prefix => false)
75
-
76
- defaults(parameters) if @show_defaults
77
- system(parameters) if @show_system
78
- user(parameters) if @show_user
79
- project(parameters) if @show_project
80
-
81
- all(parameters) if !@show_defaults && !@show_system && !@show_user && !@show_project
82
- end
83
-
84
- return 0
85
- end
86
-
87
- def help(parser)
88
- @env.ui.info(parser.help, :prefix => false)
89
- end
90
-
91
- def defaults(parameters)
92
- print_bag("Defaults", parameters.__defaults)
93
- end
94
-
95
- def system(parameters)
96
- print_bag("System", parameters.__system)
97
- end
98
-
99
- def user(parameters)
100
- print_bag("User", parameters.__user)
101
- end
102
-
103
- def project(parameters)
104
- print_bag("Project", parameters.__current)
105
- end
106
-
107
- def all(parameters)
108
- print_bag("All", parameters.__all)
109
- end
110
-
111
- def print_bag(kind, bag)
112
- if !bag || bag.empty?()
113
- print_header(kind)
114
- @env.ui.info(" Empty", :prefix => false)
115
- @env.ui.info("", :prefix => false)
116
- return
117
- end
118
-
119
- print_parameters(kind, {
120
- 'config' => {
121
- 'user' => bag.to_hash(:use_string_key => true)
122
- }
123
- })
124
- end
125
-
126
- def print_parameters(kind, hash)
127
- string = Nugrant::Helper::Yaml.format(hash.to_yaml, :indent => 1)
128
- used_restricted_keys = Helper::get_used_restricted_keys(hash, Helper::get_restricted_keys())
129
-
130
- print_warning(used_restricted_keys) if !used_restricted_keys.empty?()
131
-
132
- print_header(kind)
133
- @env.ui.info(string, :prefix => false)
134
- @env.ui.info("", :prefix => false)
135
- end
136
-
137
- def print_header(kind, length = 50)
138
- @env.ui.info(" #{kind.capitalize} Parameters", :prefix => false)
139
- @env.ui.info(" " + "-" * length, :prefix => false)
140
- end
141
-
142
- def print_warning(used_restricted_keys)
143
- @env.ui.info("", :prefix => false)
144
- @env.ui.info(" You are using some restricted keys. Method access (using .<key>) will", :prefix => false)
145
- @env.ui.info(" not work, only array access ([<key>]) will. Offending keys:", :prefix => false)
146
- @env.ui.info(" #{used_restricted_keys.join(", ")}", :prefix => false)
147
- @env.ui.info("", :prefix => false)
148
- end
149
- end
150
- end
151
- end
152
- end
153
- end
1
+ require 'nugrant'
2
+ require 'nugrant/helper/yaml'
3
+ require 'nugrant/vagrant/v2/helper'
4
+
5
+ module Nugrant
6
+ module Vagrant
7
+ module V2
8
+ module Command
9
+ class Parameters < ::Vagrant.plugin("2", :command)
10
+ def self.synopsis
11
+ "prints parameters hierarchy as seen by Nugrant"
12
+ end
13
+
14
+ def initialize(arguments, environment)
15
+ super(arguments, environment)
16
+
17
+ @show_help = false
18
+ @show_defaults = false
19
+ @show_system = false
20
+ @show_user = false
21
+ @show_project = false
22
+ end
23
+
24
+ def create_parser()
25
+ return OptionParser.new do |parser|
26
+ parser.banner = "Usage: vagrant user parameters [<options>]"
27
+ parser.separator ""
28
+
29
+ parser.separator "Available options:"
30
+ parser.separator ""
31
+
32
+ parser.on("-h", "--help", "Prints this help") do
33
+ @show_help = true
34
+ end
35
+
36
+ parser.on("-d", "--defaults", "Show only defaults parameters") do
37
+ @show_defaults = true
38
+ end
39
+
40
+ parser.on("-s", "--system", "Show only system parameters") do
41
+ @show_system = true
42
+ end
43
+
44
+ parser.on("-u", "--user", "Show only user parameters") do
45
+ @show_user = true
46
+ end
47
+
48
+ parser.on("-p", "--project", "Show only project parameters") do
49
+ @show_project = true
50
+ end
51
+
52
+ parser.separator ""
53
+ parser.separator "When no options is provided, the command prints the names and values \n" +
54
+ "of all parameters that would be available for usage in the Vagrantfile.\n" +
55
+ "The hierarchy of the parameters is respected, so the final values are\n" +
56
+ "displayed."
57
+ end
58
+ end
59
+
60
+ def execute
61
+ parser = create_parser()
62
+ arguments = parse_options(parser)
63
+
64
+ return help(parser) if @show_help
65
+
66
+ @logger.debug("'Parameters' each target VM...")
67
+ with_target_vms(arguments) do |vm|
68
+ parameters = vm.config.user
69
+ if not parameters
70
+ @env.ui.info("# Vm '#{vm.name}' : unable to retrieve `config.user`, report as bug https://github.com/maoueh/nugrant/issues", :prefix => false)
71
+ next
72
+ end
73
+
74
+ @env.ui.info("# Vm '#{vm.name}'", :prefix => false)
75
+
76
+ defaults(parameters) if @show_defaults
77
+ system(parameters) if @show_system
78
+ user(parameters) if @show_user
79
+ project(parameters) if @show_project
80
+
81
+ all(parameters) if !@show_defaults && !@show_system && !@show_user && !@show_project
82
+ end
83
+
84
+ return 0
85
+ end
86
+
87
+ def help(parser)
88
+ @env.ui.info(parser.help, :prefix => false)
89
+ end
90
+
91
+ def defaults(parameters)
92
+ print_bag("Defaults", parameters.__defaults)
93
+ end
94
+
95
+ def system(parameters)
96
+ print_bag("System", parameters.__system)
97
+ end
98
+
99
+ def user(parameters)
100
+ print_bag("User", parameters.__user)
101
+ end
102
+
103
+ def project(parameters)
104
+ print_bag("Project", parameters.__current)
105
+ end
106
+
107
+ def all(parameters)
108
+ print_bag("All", parameters.__all)
109
+ end
110
+
111
+ def print_bag(kind, bag)
112
+ if !bag || bag.empty?()
113
+ print_header(kind)
114
+ @env.ui.info(" Empty", :prefix => false)
115
+ @env.ui.info("", :prefix => false)
116
+ return
117
+ end
118
+
119
+ print_parameters(kind, {
120
+ 'config' => {
121
+ 'user' => bag.to_hash(:use_string_key => true)
122
+ }
123
+ })
124
+ end
125
+
126
+ def print_parameters(kind, hash)
127
+ string = Nugrant::Helper::Yaml.format(hash.to_yaml, :indent => 1)
128
+ used_restricted_keys = Helper::get_used_restricted_keys(hash, Helper::get_restricted_keys())
129
+
130
+ print_warning(used_restricted_keys) if !used_restricted_keys.empty?()
131
+
132
+ print_header(kind)
133
+ @env.ui.info(string, :prefix => false)
134
+ @env.ui.info("", :prefix => false)
135
+ end
136
+
137
+ def print_header(kind, length = 50)
138
+ @env.ui.info(" #{kind.capitalize} Parameters", :prefix => false)
139
+ @env.ui.info(" " + "-" * length, :prefix => false)
140
+ end
141
+
142
+ def print_warning(used_restricted_keys)
143
+ @env.ui.info("", :prefix => false)
144
+ @env.ui.info(" You are using some restricted keys. Method access (using .<key>) will", :prefix => false)
145
+ @env.ui.info(" not work, only array access ([<key>]) will. Offending keys:", :prefix => false)
146
+ @env.ui.info(" #{used_restricted_keys.join(", ")}", :prefix => false)
147
+ @env.ui.info("", :prefix => false)
148
+ end
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end