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.
The full name of the module, which is a dash-separated combination of the
username and module name.
The name of this module. See also full_module_name.
The name of the user that owns this module.
The version of this module.
Instantiate from a hash, whose keys are setters in this class.
# File lib/puppet/module_tool/metadata.rb, line 26 def initialize(settings={}) set_options(settings) end
Return module’s file checksums.
# File lib/puppet/module_tool/metadata.rb, line 97 def checksums return @checksums ||= {} end
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.
# File lib/puppet/module_tool/metadata.rb, line 104 def dashed_name return [@username, @name].compact.join('-') end
Return an array of the module’s Dependency objects.
# File lib/puppet/module_tool/metadata.rb, line 38 def dependencies return @dependencies ||= [] end
# File lib/puppet/module_tool/metadata.rb, line 74 def description @description || 'UNKNOWN' end
# File lib/puppet/module_tool/metadata.rb, line 78 def description=(description) @description = description end
Set the full name of this module, and from it, the username
and module name.
# File lib/puppet/module_tool/metadata.rb, line 32 def full_module_name=(full_module_name) @full_module_name = full_module_name @username, @name = Puppet::ModuleTool::username_and_modname_from(full_module_name) end
# File lib/puppet/module_tool/metadata.rb, line 58 def license @license || 'Apache License, Version 2.0' end
# File lib/puppet/module_tool/metadata.rb, line 62 def license=(license) @license = license end
# File lib/puppet/module_tool/metadata.rb, line 82 def project_page @project_page || 'UNKNOWN' end
# File lib/puppet/module_tool/metadata.rb, line 86 def project_page=(project_page) @project_page = project_page end
Return the release name, which is the combination of the
dashed_name of the module and its version number.
# File lib/puppet/module_tool/metadata.rb, line 110 def release_name return [dashed_name, @version].join('-') end
# File lib/puppet/module_tool/metadata.rb, line 50 def source @source || 'UNKNOWN' end
# File lib/puppet/module_tool/metadata.rb, line 54 def source=(source) @source = source end
# File lib/puppet/module_tool/metadata.rb, line 66 def summary @summary || 'UNKNOWN' end
# File lib/puppet/module_tool/metadata.rb, line 70 def summary=(summary) @summary = summary end
Return the PSON record representing this instance.
# File lib/puppet/module_tool/metadata.rb, line 125 def to_pson(*args) return { :name => @full_module_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
Return an array of the module’s Puppet types, each one is a hash containing :name and :doc.
# File lib/puppet/module_tool/metadata.rb, line 92 def types return @types ||= [] end
Set the version of this module, ensure a string like ‘0.1.0’ see the Semantic Versions here: semver.org
# File lib/puppet/module_tool/metadata.rb, line 116 def version=(version) if SemVer.valid?(version) @version = version else raise ArgumentError, "Invalid version format: #{@version} (Semantic Versions are acceptable: http://semver.org)" end end