Class: Puppet::ModuleTool::InstalledModules Private

Inherits:
SemanticPuppet::Dependency::Source
  • Object
show all
Defined in:
lib/puppet/module_tool/installed_modules.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: ModuleRelease

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ InstalledModules

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of InstalledModules.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/puppet/module_tool/installed_modules.rb', line 16

def initialize(env)
  @env = env
  modules = env.modules_by_path

  @fetched = []
  @modules = {}
  @by_name = {}
  env.modulepath.each do |path|
    modules[path].each do |mod|
      @by_name[mod.name] = mod
      next unless mod.has_metadata?

      release = ModuleRelease.new(self, mod)
      @modules[release.name] ||= release
    end
  end

  @modules.freeze
end

Instance Attribute Details

#by_nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/puppet/module_tool/installed_modules.rb', line 10

def by_name
  @by_name
end

#modulesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/puppet/module_tool/installed_modules.rb', line 10

def modules
  @modules
end

Instance Method Details

#fetch(name) ⇒ Array<SemanticPuppet::Dependency::ModuleRelease>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Fetches ModuleRelease entries for each release of the named module.

Parameters:

  • name (String)

    the module name to look up

Returns:

  • (Array<SemanticPuppet::Dependency::ModuleRelease>)

    a list of releases for the given name

See Also:

  • SemanticPuppet::Dependency::Source#fetch


42
43
44
45
46
47
48
49
50
51
# File 'lib/puppet/module_tool/installed_modules.rb', line 42

def fetch(name)
  name = name.tr('/', '-')

  if @modules.key? name
    @fetched << name
    [@modules[name]]
  else
    []
  end
end

#fetchedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
# File 'lib/puppet/module_tool/installed_modules.rb', line 53

def fetched
  @fetched
end

#priorityObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/puppet/module_tool/installed_modules.rb', line 12

def priority
  10
end