Class: Berkshelf::Vagrant::BerksConfig

Inherits:
Vagrant::Util::HashWithIndifferentAccess
  • Object
show all
Defined in:
lib/berkshelf/vagrant/berks_config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBerksConfig

Returns a new instance of BerksConfig.



35
36
37
# File 'lib/berkshelf/vagrant/berks_config.rb', line 35

def initialize
  super(chef: ChefConfig.instance, ssl: ::Vagrant::Util::HashWithIndifferentAccess.new(verify: false))
end

Class Method Details

.instanceConfig

Instantiate and return or just return the currently instantiated Berkshelf configuration

Returns:



26
27
28
29
30
31
32
# File 'lib/berkshelf/vagrant/berks_config.rb', line 26

def instance
  @instance ||= if File.exists?(path) && File.readable?(path)
    JSON.parse(File.read(path))
  else
    new
  end
end

.local_locationString

Returns:

  • (String)


12
13
14
# File 'lib/berkshelf/vagrant/berks_config.rb', line 12

def local_location
  ENV['BERKSHELF_CONFIG'] || File.join('.', '.berkshelf', 'config.json')
end

.pathString

Returns:

  • (String)


17
18
19
20
# File 'lib/berkshelf/vagrant/berks_config.rb', line 17

def path
  path = File.exists?(local_location) ? local_location : store_location
  File.expand_path(path)
end

.store_locationString

Returns:

  • (String)


7
8
9
# File 'lib/berkshelf/vagrant/berks_config.rb', line 7

def store_location
  File.join(Berkshelf.berkshelf_path, 'config.json')
end

Instance Method Details

#chefObject



39
40
41
# File 'lib/berkshelf/vagrant/berks_config.rb', line 39

def chef
  self[:chef]
end

#sslObject



43
44
45
# File 'lib/berkshelf/vagrant/berks_config.rb', line 43

def ssl
  self[:ssl]
end