Class: VagrantPlugins::Fractal::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Fractal::Config
- Defined in:
- lib/vagrant-fractal/config.rb
Constant Summary collapse
- DEFAULT_SETTINGS =
{ file: 'fractal.yaml' }.freeze
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
- #data ⇒ Object
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(_) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
13 14 15 16 17 |
# File 'lib/vagrant-fractal/config.rb', line 13 def initialize @file = UNSET_VALUE @filter = UNSET_VALUE @raw = nil end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
7 8 9 |
# File 'lib/vagrant-fractal/config.rb', line 7 def active @active end |
#file ⇒ Object
Returns the value of attribute file.
6 7 8 |
# File 'lib/vagrant-fractal/config.rb', line 6 def file @file end |
Instance Method Details
#data ⇒ Object
28 29 30 31 |
# File 'lib/vagrant-fractal/config.rb', line 28 def data validate(nil) raw.select { |key,_| active.include? key } end |
#finalize! ⇒ Object
54 55 56 57 |
# File 'lib/vagrant-fractal/config.rb', line 54 def finalize! @file = DEFAULT_SETTINGS[:file] if @file == UNSET_VALUE @filter = docker_boxes.split(',').map{|box| box.strip } unless docker_boxes == UNSET_VALUE end |
#validate(_) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vagrant-fractal/config.rb', line 33 def validate(_) finalize! errors = _detected_errors if File.file?(@file) begin unless @filter == UNSET_VALUE @filter.each do |box| errors.push("There is no #{box} box in #{@file}") unless raw.has_key?(box) end end rescue Exception errors.push("file #{@file} have wrong format") end else errors.push("file #{@file} does not exists") end { 'fractal' => errors } end |