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



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

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

Class Method Details

.read(modulefile_path) ⇒ Object



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

def self.read(modulefile_path)
    Modulefile.new.tap do |modulefile|
        modulefile.instance_eval(File.read(modulefile_path))
    end
end

Instance Method Details

#dependency(name, spec) ⇒ Object



37
38
39
# File 'lib/puppet_library/puppet_module/modulefile.rb', line 37

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

#get_dependenciesObject



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

def get_dependencies
    @dependencies ||= []
end

#get_simple_nameObject



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

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

#to_metadataObject



53
54
55
56
57
58
59
60
61
# File 'lib/puppet_library/puppet_module/modulefile.rb', line 53

def 
    {
        "name" => get_name,
        "version" => get_version,
        "author" => get_author,
        "description" => get_description,
        "dependencies" => get_dependencies
    }
end