Class: Puppet::ModuleTool::ModulefileReader

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/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

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ ModulefileReader

Instantiate with the Metadata metadata instance.



23
24
25
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 23

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.



12
13
14
15
16
17
18
19
20
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 12

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



51
52
53
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 51

def author(author)
    @metadata.author = 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.0.1”) and repository (a URL string). Optional. Can be called multiple times to add many dependencies.



41
42
43
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 41

def dependency(name, version_requirement = nil, repository = nil)
  @metadata.dependencies << Dependency.new(name, version_requirement, repository)
end

#description(description) ⇒ Object

Set the description



66
67
68
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 66

def description(description)
   @metadata.description = description
end

#license(license) ⇒ Object

Set the license



56
57
58
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 56

def license(license)
  @metadata.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.



29
30
31
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 29

def name(name)
  @metadata.full_module_name = name
end

#project_page(project_page) ⇒ Object

Set the project page



71
72
73
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 71

def project_page(project_page)
  @metadata.project_page = project_page
end

#source(source) ⇒ Object

Set the source



46
47
48
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 46

def source(source)
  @metadata.source = source
end

#summary(summary) ⇒ Object

Set the summary



61
62
63
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 61

def summary(summary)
  @metadata.summary = summary
end

#version(version) ⇒ Object

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



34
35
36
# File 'lib/vendor/puppet/module_tool/modulefile.rb', line 34

def version(version)
  @metadata.version = version
end