Class: PuppetLibrary::PuppetModule::Modulefile

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_library/puppet_module/modulefile.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



53
54
55
# File 'lib/puppet_library/puppet_module/modulefile.rb', line 53

def method_missing(name, *args, &block)
    Modulefile.log "Unsupported config parsed from Modulefile: #{name}(#{args.join", "})"
end

Class Method Details

.parse(modulefile_source) ⇒ Object



23
24
25
26
27
# File 'lib/puppet_library/puppet_module/modulefile.rb', line 23

def self.parse(modulefile_source)
    Modulefile.new.tap do |modulefile|
        modulefile.instance_eval(modulefile_source)
    end
end

.read(modulefile_path) ⇒ Object



19
20
21
# File 'lib/puppet_library/puppet_module/modulefile.rb', line 19

def self.read(modulefile_path)
    parse(File.read(modulefile_path))
end

Instance Method Details

#dependency(name, spec) ⇒ Object



41
42
43
# File 'lib/puppet_library/puppet_module/modulefile.rb', line 41

def dependency(name, spec)
    get_dependencies.push("name" => name, "version_requirement" => spec)
end

#get_dependenciesObject



45
46
47
# File 'lib/puppet_library/puppet_module/modulefile.rb', line 45

def get_dependencies
    @dependencies ||= []
end

#get_simple_nameObject



49
50
51
# File 'lib/puppet_library/puppet_module/modulefile.rb', line 49

def get_simple_name
    @name.split("-").last
end

#to_metadataObject



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/puppet_library/puppet_module/modulefile.rb', line 57

def 
    {
        "name" => get_name,
        "version" => get_version,
        "source" => get_source,
        "author" => get_author,
        "license" => get_license,
        "summary" => get_summary,
        "description" => get_description,
        "project_page" => get_project_page,
        "dependencies" => get_dependencies
    }
end