Class: Puppet::Module::Tool::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/module/tool/metadata.rb

Overview

Metadata

This class provides a data structure representing a module’s metadata. It provides some basic parsing, but other data is injected into it using annotate methods in other classes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings = {}) ⇒ Metadata

Instantiate from a hash, whose keys are setters in this class.



24
25
26
27
28
# File 'lib/puppet/module/tool/metadata.rb', line 24

def initialize(settings={})
  settings.each do |key, value|
    send("#{key}=", value)
  end
end

Instance Attribute Details

#full_nameObject

The full name of the module, which is a dash-separated combination of the username and module name.



12
13
14
# File 'lib/puppet/module/tool/metadata.rb', line 12

def full_name
  @full_name
end

#nameObject (readonly)

The name of this module. See also full_name.



18
19
20
# File 'lib/puppet/module/tool/metadata.rb', line 18

def name
  @name
end

#usernameObject (readonly)

The name of the user that owns this module.



15
16
17
# File 'lib/puppet/module/tool/metadata.rb', line 15

def username
  @username
end

#versionObject

The version of this module, a string like ‘0.1.0’.



21
22
23
# File 'lib/puppet/module/tool/metadata.rb', line 21

def version
  @version
end

Instance Method Details

#checksumsObject

Return module’s file checksums.



50
51
52
# File 'lib/puppet/module/tool/metadata.rb', line 50

def checksums
  return @checksums ||= {}
end

#dashed_nameObject

Return the dashed name of the module, which may either be the dash-separated combination of the username and module name, or just the module name.



57
58
59
# File 'lib/puppet/module/tool/metadata.rb', line 57

def dashed_name
  return [@username, @name].compact.join('-')
end

#dependenciesObject

Return an array of the module’s Dependency objects.



38
39
40
# File 'lib/puppet/module/tool/metadata.rb', line 38

def dependencies
  return @dependencies ||= []
end

#release_nameObject

Return the release name, which is the combination of the dashed_name of the module and its version number.



63
64
65
# File 'lib/puppet/module/tool/metadata.rb', line 63

def release_name
  return [dashed_name, @version].join('-')
end

#to_pson(*args) ⇒ Object

Return the PSON record representing this instance.



68
69
70
71
72
73
74
75
76
# File 'lib/puppet/module/tool/metadata.rb', line 68

def to_pson(*args)
  return {
    :name         => @full_name,
    :version      => @version,
    :dependencies => dependencies,
    :types        => types,
    :checksums    => checksums
  }.to_pson(*args)
end

#typesObject

Return an array of the module’s Puppet types, each one is a hash containing :name and :doc. TODO Shouldn’t this be it’s own class?



45
46
47
# File 'lib/puppet/module/tool/metadata.rb', line 45

def types
  return @types ||= []
end