Class: VagrantPlugins::Sprinkle::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-sprinkle/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



11
12
13
14
15
16
17
18
# File 'lib/vagrant-sprinkle/config.rb', line 11

def initialize
  self.script   = UNSET_VALUE
  self.only     = UNSET_VALUE
  self.test     = UNSET_VALUE
  self.verbose  = UNSET_VALUE
  self.cloud    = UNSET_VALUE
  self.force    = UNSET_VALUE
end

Instance Attribute Details

#cloudObject

Returns the value of attribute cloud.



8
9
10
# File 'lib/vagrant-sprinkle/config.rb', line 8

def cloud
  @cloud
end

#forceObject

Returns the value of attribute force.



9
10
11
# File 'lib/vagrant-sprinkle/config.rb', line 9

def force
  @force
end

#onlyObject

Returns the value of attribute only.



5
6
7
# File 'lib/vagrant-sprinkle/config.rb', line 5

def only
  @only
end

#scriptObject

Returns the value of attribute script.



4
5
6
# File 'lib/vagrant-sprinkle/config.rb', line 4

def script
  @script
end

#testObject

Returns the value of attribute test.



6
7
8
# File 'lib/vagrant-sprinkle/config.rb', line 6

def test
  @test
end

#verboseObject

Returns the value of attribute verbose.



7
8
9
# File 'lib/vagrant-sprinkle/config.rb', line 7

def verbose
  @verbose
end

Instance Method Details

#finalize!Object



20
21
22
23
24
25
26
27
# File 'lib/vagrant-sprinkle/config.rb', line 20

def finalize!
  self.script   = nil if script == UNSET_VALUE
  self.only     = nil if only == UNSET_VALUE
  self.test     = nil if test == UNSET_VALUE
  self.verbose  = nil if verbose == UNSET_VALUE
  self.cloud    = nil if cloud == UNSET_VALUE
  self.force    = nil if force == UNSET_VALUE
end

#validate(machine) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vagrant-sprinkle/config.rb', line 29

def validate(machine)
  errors = []

  if script
    unless Pathname.new(script).expand_path(machine.env.root_path).file?
      errors << I18n.t(
        'vagrant.provisioners.sprinkle.script_path_invalid',
        :path => expanded_path
      )
    end
  else
    errors << I18n.t('vagrant.provisioners.sprinkle.no_script')
  end

  { 'Sprinkle provisioner' => errors }
end