Class: VagrantPlugins::Berkshelf::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Berkshelf::Config
- Defined in:
- lib/vagrant-berkshelf/config.rb
Instance Attribute Summary collapse
-
#args ⇒ Array<String>
An array of additional arguments to pass to the Berkshelf command.
-
#berksfile_path ⇒ String
The path to the Berksfile to use.
-
#enabled ⇒ Boolean
Disable the use of Berkshelf in Vagrant.
-
#except ⇒ Array<Symbol>
The array of cookbook groups to exclude during provisioning.
-
#only ⇒ Array<Symbol>
The array of cookbook groups to exclusively install during provisioning.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #to_hash ⇒ Object
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant-berkshelf/config.rb', line 27 def initialize super @berksfile_path = UNSET_VALUE @enabled = UNSET_VALUE @except = Array.new @only = Array.new @args = Array.new @__finalized = false end |
Instance Attribute Details
#args ⇒ Array<String>
An array of additional arguments to pass to the Berkshelf command.
25 26 27 |
# File 'lib/vagrant-berkshelf/config.rb', line 25 def args @args end |
#berksfile_path ⇒ String
The path to the Berksfile to use.
9 10 11 |
# File 'lib/vagrant-berkshelf/config.rb', line 9 def berksfile_path @berksfile_path end |
#enabled ⇒ Boolean
Disable the use of Berkshelf in Vagrant.
13 14 15 |
# File 'lib/vagrant-berkshelf/config.rb', line 13 def enabled @enabled end |
#except ⇒ Array<Symbol>
The array of cookbook groups to exclude during provisioning.
21 22 23 |
# File 'lib/vagrant-berkshelf/config.rb', line 21 def except @except end |
#only ⇒ Array<Symbol>
The array of cookbook groups to exclusively install during provisioning.
17 18 19 |
# File 'lib/vagrant-berkshelf/config.rb', line 17 def only @only end |
Instance Method Details
#finalize! ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vagrant-berkshelf/config.rb', line 39 def finalize! @berksfile_path = nil if @berksfile_path == UNSET_VALUE if @enabled == UNSET_VALUE if @berksfile_path # Automatically enable if a Berksfile path was given @enabled = true elsif File.exist?("Berksfile") # Automatically enable when a Berksfile is persent @berksfile_path = "Berksfile" @enabled = true end end @enabled = false if @enabled == UNSET_VALUE @__finalized = true end |
#to_hash ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/vagrant-berkshelf/config.rb', line 74 def to_hash raise "Must finalize first." if !@__finalized { enabled: @enabled, berksfile_path: @berksfile_path, except: @except, only: @only, args: @args, } end |
#validate(machine) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/vagrant-berkshelf/config.rb', line 58 def validate(machine) errors = _detected_errors if @enabled if @berksfile_path.to_s.strip.empty? errors << "berksfile_path must be set" else unless Pathname.new(@berksfile_path).absolute? @berksfile_path = File.(@berksfile_path, machine.env.root_path) end end end { "Berkshelf" => errors } end |