Class: Puppet::ModuleTool::ModulefileReader
- Defined in:
- lib/puppet/module_tool/modulefile.rb
Overview
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.
Class Method Summary collapse
-
.evaluate(metadata, filename) ⇒ Object
Read the
filename
and eval its Ruby code to set values in the Metadatametadata
instance.
Instance Method Summary collapse
-
#author(author) ⇒ Object
Set the author or default to
username
. -
#dependency(name, version_requirement = nil, repository = nil) ⇒ Object
Add a dependency with the full_module_name
name
(e.g. “myuser-mymodule”), an optionalversion_requirement
(e.g. “0.1.0”) andrepository
(a URL string). -
#description(description) ⇒ Object
Set the description.
-
#initialize(metadata) ⇒ ModulefileReader
constructor
Instantiate with the Metadata
metadata
instance. -
#license(license) ⇒ Object
Set the license.
-
#name(name) ⇒ Object
Set the
full_module_name
(e.g. “myuser-mymodule”), which will also set theusername
and modulename
. -
#project_page(project_page) ⇒ Object
Set the project page.
-
#source(source) ⇒ Object
Set the source.
-
#summary(summary) ⇒ Object
Set the summary.
-
#version(version) ⇒ Object
Set the module
version
(e.g., “0.1.0”).
Constructor Details
#initialize(metadata) ⇒ ModulefileReader
Instantiate with the Metadata metadata
instance.
26 27 28 |
# File 'lib/puppet/module_tool/modulefile.rb', line 26 def initialize() @metadata = end |
Class Method Details
.evaluate(metadata, filename) ⇒ Object
Read the filename
and eval its Ruby code to set values in the Metadata metadata
instance.
15 16 17 18 19 20 21 22 23 |
# File 'lib/puppet/module_tool/modulefile.rb', line 15 def self.evaluate(, filename) builder = new() 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 |
Instance Method Details
#author(author) ⇒ Object
Set the author or default to username
54 55 56 |
# File 'lib/puppet/module_tool/modulefile.rb', line 54 def () @metadata.update('author' => ) end |
#dependency(name, version_requirement = nil, repository = nil) ⇒ Object
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.
44 45 46 |
# 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) ⇒ Object
Set the description
69 70 71 |
# File 'lib/puppet/module_tool/modulefile.rb', line 69 def description(description) @metadata.update('description' => description) end |
#license(license) ⇒ Object
Set the license
59 60 61 |
# File 'lib/puppet/module_tool/modulefile.rb', line 59 def license(license) @metadata.update('license' => license) end |
#name(name) ⇒ Object
Set the full_module_name
(e.g. “myuser-mymodule”), which will also set the username
and module name
. Required.
32 33 34 |
# File 'lib/puppet/module_tool/modulefile.rb', line 32 def name(name) @metadata.update('name' => name) end |
#project_page(project_page) ⇒ Object
Set the project page
74 75 76 |
# File 'lib/puppet/module_tool/modulefile.rb', line 74 def project_page(project_page) @metadata.update('project_page' => project_page) end |
#source(source) ⇒ Object
Set the source
49 50 51 |
# File 'lib/puppet/module_tool/modulefile.rb', line 49 def source(source) @metadata.update('source' => source) end |
#summary(summary) ⇒ Object
Set the summary
64 65 66 |
# File 'lib/puppet/module_tool/modulefile.rb', line 64 def summary(summary) @metadata.update('summary' => summary) end |
#version(version) ⇒ Object
Set the module version
(e.g., “0.1.0”). Required.
37 38 39 |
# File 'lib/puppet/module_tool/modulefile.rb', line 37 def version(version) @metadata.update('version' => version) end |