# class Puppet::ModuleTool::Metadata

# 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.

### Attributes

full_module_name[R]

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

name[R]

The name of this module. See also `full_module_name`.

username[R]

The name of the user that owns this module.

version[R]

The version of this module.

### Public Class Methods

new(settings={}) click to toggle source

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

### Public Instance Methods

author() click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 42
    def author
      @author || @username
    end

author=(author) click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 46
    def author=(author)
      @author = author
    end

checksums() click to toggle source

Return module’s file checksums.

    # File lib/puppet/module_tool/metadata.rb, line 97
    def checksums
      return @checksums ||= {}
    end

dashed_name() click to toggle source

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

dependencies() click to toggle source

Return an array of the module’s Dependency objects.

    # File lib/puppet/module_tool/metadata.rb, line 38
    def dependencies
      return @dependencies ||= []
    end

description() click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 74
    def description
      @description || 'UNKNOWN'
    end

description=(description) click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 78
    def description=(description)
      @description = description
    end

full_module_name=(full_module_name) click to toggle source

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

license() click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 58
    def license
      @license || 'Apache License, Version 2.0'
    end

license=(license) click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 62
    def license=(license)
      @license = license
    end

project_page() click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 82
    def project_page
      @project_page || 'UNKNOWN'
    end

project_page=(project_page) click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 86
    def project_page=(project_page)
      @project_page = project_page
    end

release_name() click to toggle source

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

source() click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 50
    def source
      @source || 'UNKNOWN'
    end

source=(source) click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 54
    def source=(source)
      @source = source
    end

summary() click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 66
    def summary
      @summary || 'UNKNOWN'
    end

summary=(summary) click to toggle source

    # File lib/puppet/module_tool/metadata.rb, line 70
    def summary=(summary)
      @summary = summary
    end

to_pson(*args) click to toggle source

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

types() click to toggle source

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

version=(version) click to toggle source

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