Class: Puppet::Module::Tool::Modulefile

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ Modulefile

Instantiate with the Metadata metadata instance.



23
24
25
# File 'lib/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/puppet/module/tool/modulefile.rb', line 12

def self.evaluate(, filename)
  returning(new()) do |builder|
    if File.file?(filename)
      builder.instance_eval(File.read(filename.to_s), filename.to_s, 1)
    else
      puts "No Modulefile: #{filename}"
    end
  end
end

Instance Method Details

#dependency(name, version_requirement = nil, repository = nil) ⇒ Object

Add a dependency with the full_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/puppet/module/tool/modulefile.rb', line 41

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

#name(name) ⇒ Object

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



29
30
31
# File 'lib/puppet/module/tool/modulefile.rb', line 29

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

#version(version) ⇒ Object

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



34
35
36
# File 'lib/puppet/module/tool/modulefile.rb', line 34

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