Class: Puppet::ModuleTool::InstalledModules

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

Defined Under Namespace

Classes: ModuleRelease

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ InstalledModules


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

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)

Returns the value of attribute by_name


8
9
10
# File 'lib/puppet/module_tool/installed_modules.rb', line 8

def by_name
  @by_name
end

#modulesObject (readonly)

Returns the value of attribute modules


8
9
10
# File 'lib/puppet/module_tool/installed_modules.rb', line 8

def modules
  @modules
end

Instance Method Details

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

Fetches ModuleRelease entries for each release of the named module.

See Also:

  • SemanticPuppet::Dependency::Source#fetch

39
40
41
42
43
44
45
46
47
48
# File 'lib/puppet/module_tool/installed_modules.rb', line 39

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

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

#fetchedObject


50
51
52
# File 'lib/puppet/module_tool/installed_modules.rb', line 50

def fetched
  @fetched
end

#priorityObject


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

def priority
  10
end