Class: VagrantPlugins::PuppetModuleRegistry::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-puppet-module-registry/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



8
9
10
11
# File 'lib/vagrant-puppet-module-registry/config.rb', line 8

def initialize
  @puppet_module_paths = UNSET_VALUE
  @puppet_module_path_to_name = UNSET_VALUE
end

Instance Attribute Details

#puppet_module_path_to_nameObject

Returns the value of attribute puppet_module_path_to_name.



6
7
8
# File 'lib/vagrant-puppet-module-registry/config.rb', line 6

def puppet_module_path_to_name
  @puppet_module_path_to_name
end

#puppet_module_pathsObject

Returns the value of attribute puppet_module_paths.



5
6
7
# File 'lib/vagrant-puppet-module-registry/config.rb', line 5

def puppet_module_paths
  @puppet_module_paths
end

Instance Method Details

#finalize!Object



41
42
43
44
# File 'lib/vagrant-puppet-module-registry/config.rb', line 41

def finalize!
  @puppet_module_paths = [] if @puppet_module_paths == UNSET_VALUE
  @puppet_module_path_to_name = {} if @puppet_module_path_to_name == UNSET_VALUE
end

#get_puppet_module_path_mapObject

Return a hash which should be of the form module_path => name.



14
15
16
17
18
19
# File 'lib/vagrant-puppet-module-registry/config.rb', line 14

def get_puppet_module_path_map
  if @puppet_module_path_to_name == UNSET_VALUE
    @puppet_module_path_to_name = {}
  end
  return @puppet_module_path_to_name
end

#get_puppet_module_pathsObject

Return an array of modules to be added to puppet’s module path when provisioning



23
24
25
26
27
28
# File 'lib/vagrant-puppet-module-registry/config.rb', line 23

def get_puppet_module_paths
  if @puppet_module_paths == UNSET_VALUE
    @puppet_module_paths = []
  end
  return @puppet_module_paths
end

#register_module_path(name, path) ⇒ Object

Add a path to the ‘puppet_module_paths` array as well as the `puppet_module_path_to_name` hash. This gives us a mechanism to loop through `puppet_module_paths` and retrieve the name the path is associated with.



34
35
36
37
38
39
# File 'lib/vagrant-puppet-module-registry/config.rb', line 34

def register_module_path(name, path)
  module_map = get_puppet_module_path_map()
  module_paths = get_puppet_module_paths()
  module_map[path] = name
  module_paths.push(path)
end

#validate(machine) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/vagrant-puppet-module-registry/config.rb', line 46

def validate(machine)
  errors = []
  if @puppet_module_path_to_name and
    not @puppet_module_path_to_name.kind_of?(Hash)
    errors << "`puppet_module_path_to_name` must be a hash"
  end
  return { "puppet_module_registry" => errors }
end