class Puppet::ModuleTool::ModulefileReader

Modulefile

This class provides the DSL used for evaluating the module’s ‘Modulefile’. These methods are used to concisely define this module’s attributes, which are later rendered as PSON into a ‘metadata.json’ file.

Public Instance Methods

author(author) click to toggle source

Set the author or default to username

# File lib/puppet/module_tool/modulefile.rb, line 54
def author(author)
  @metadata.update('author' => author)
end
dependency(name, version_requirement = nil, repository = nil) click to toggle source

Add a dependency with the full_module_name name (e.g. “myuser-mymodule”), an optional version_requirement (e.g. “0.1.0”) and repository (a URL string). Optional. Can be called multiple times to add many dependencies.

# File lib/puppet/module_tool/modulefile.rb, line 44
def dependency(name, version_requirement = nil, repository = nil)
  @metadata.add_dependency(name, version_requirement, repository)
end
description(description) click to toggle source

Set the description

# File lib/puppet/module_tool/modulefile.rb, line 69
def description(description)
  @metadata.update('description' => description)
end
license(license) click to toggle source

Set the license

# File lib/puppet/module_tool/modulefile.rb, line 59
def license(license)
  @metadata.update('license' => license)
end
name(name) click to toggle source

Set the full_module_name (e.g. “myuser-mymodule”), which will also set the username and module name. Required.

# File lib/puppet/module_tool/modulefile.rb, line 32
def name(name)
  @metadata.update('name' => name)
end
project_page(project_page) click to toggle source

Set the project page

# File lib/puppet/module_tool/modulefile.rb, line 74
def project_page(project_page)
  @metadata.update('project_page' => project_page)
end
source(source) click to toggle source

Set the source

# File lib/puppet/module_tool/modulefile.rb, line 49
def source(source)
  @metadata.update('source' => source)
end
summary(summary) click to toggle source

Set the summary

# File lib/puppet/module_tool/modulefile.rb, line 64
def summary(summary)
  @metadata.update('summary' => summary)
end
version(version) click to toggle source

Set the module version (e.g., “0.1.0”). Required.

# File lib/puppet/module_tool/modulefile.rb, line 37
def version(version)
  @metadata.update('version' => version)
end

Public Class Methods

evaluate(metadata, filename) click to toggle source

Read the filename and eval its Ruby code to set values in the Metadata metadata instance.

# File lib/puppet/module_tool/modulefile.rb, line 15
def self.evaluate(metadata, filename)
  builder = new(metadata)
  if File.file?(filename)
    builder.instance_eval(File.read(filename.to_s), filename.to_s, 1)
  else
    Puppet.warning "No Modulefile: #{filename}"
  end
  return builder
end
new(metadata) click to toggle source

Instantiate with the Metadata metadata instance.

# File lib/puppet/module_tool/modulefile.rb, line 26
def initialize(metadata)
  @metadata = metadata
end