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

#authorObject



42
43
44
# File 'lib/puppet/module/tool/metadata.rb', line 42

def author
  @author || @username
end

#author=(author) ⇒ Object



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

def author=(author)
  @author = author
end

#checksumsObject

Return module’s file checksums.



98
99
100
# File 'lib/puppet/module/tool/metadata.rb', line 98

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.



105
106
107
# File 'lib/puppet/module/tool/metadata.rb', line 105

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

#descriptionObject



74
75
76
# File 'lib/puppet/module/tool/metadata.rb', line 74

def description
  @description || 'UNKNOWN'
end

#description=(description) ⇒ Object



78
79
80
# File 'lib/puppet/module/tool/metadata.rb', line 78

def description=(description)
  @description = description
end

#licenseObject



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

def license
  @license || 'UNKNOWN'
end

#license=(license) ⇒ Object



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

def license=(license)
  @license = license
end

#project_pageObject



82
83
84
# File 'lib/puppet/module/tool/metadata.rb', line 82

def project_page
  @project_page || 'UNKNOWN'
end

#project_page=(project_page) ⇒ Object



86
87
88
# File 'lib/puppet/module/tool/metadata.rb', line 86

def project_page=(project_page)
  @project_page = project_page
end

#release_nameObject

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



111
112
113
# File 'lib/puppet/module/tool/metadata.rb', line 111

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

#sourceObject



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

def source
  @source || 'UNKNOWN'
end

#source=(source) ⇒ Object



54
55
56
# File 'lib/puppet/module/tool/metadata.rb', line 54

def source=(source)
  @source = source
end

#summaryObject



66
67
68
# File 'lib/puppet/module/tool/metadata.rb', line 66

def summary
  @summary || 'UNKNOWN'
end

#summary=(summary) ⇒ Object



70
71
72
# File 'lib/puppet/module/tool/metadata.rb', line 70

def summary=(summary)
  @summary = summary
end

#to_pson(*args) ⇒ Object

Return the PSON record representing this instance.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/puppet/module/tool/metadata.rb', line 116

def to_pson(*args)
  return {
    :name         => @full_name,
    :version      => @version,
    :source       => source,
    :author       => author,
    :license      => license,
    :summary      => summary,
    :description  => description,
    :project_page => project_page,
    :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?



93
94
95
# File 'lib/puppet/module/tool/metadata.rb', line 93

def types
  return @types ||= []
end