Class: Armature::Puppetfile
- Inherits:
-
Object
- Object
- Armature::Puppetfile
- Defined in:
- lib/armature/puppetfile.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #_mod_forge(full_name, name, version = :latest) ⇒ Object
- #_mod_git(name, options = {}) ⇒ Object
- #forge(url) ⇒ Object
-
#include(path) ⇒ Object
FIXME this will have access to @cache and @results.
-
#initialize(cache) ⇒ Puppetfile
constructor
A new instance of Puppetfile.
- #mod(full_name, options = {}) ⇒ Object
Constructor Details
#initialize(cache) ⇒ Puppetfile
Returns a new instance of Puppetfile.
5 6 7 8 9 10 |
# File 'lib/armature/puppetfile.rb', line 5 def initialize(cache) @cache = cache @results = {} @logger = Logging.logger[self] @forge_url = "https://forge.puppet.com" end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
3 4 5 |
# File 'lib/armature/puppetfile.rb', line 3 def results @results end |
Instance Method Details
#_mod_forge(full_name, name, version = :latest) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/armature/puppetfile.rb', line 44 def _mod_forge(full_name, name, version=:latest) if version == nil || version == {} version = "latest" else version = version.to_s end repo = Repo::Forge.from_url(@cache, @forge_url, full_name) ref = repo.general_ref(version) @logger.debug("mod #{name}: #{ref}") @results[name] = { :name => name, :ref => ref } end |
#_mod_git(name, options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/armature/puppetfile.rb', line 57 def _mod_git(name, ={}) = Armature::Util.(, { :commit => nil, :tag => nil, :branch => nil, :ref => nil, }, { :git => nil, }) repo = Repo::Git.from_url(@cache, [:git]) ref = nil if [:commit] if ref raise "Module #{name} has more than one of :commit, :tag, :branch, or :ref" end ref = repo.identity_ref([:commit]) end if [:tag] if ref raise "Module #{name} has more than one of :commit, :tag, :branch, or :ref" end ref = repo.tag_ref([:tag]) end if [:branch] if ref raise "Module #{name} has more than one of :commit, :tag, :branch, or :ref" end ref = repo.branch_ref([:branch]) end if [:ref] if ref raise "Module #{name} has more than one of :commit, :tag, :branch, or :ref" end ref = repo.general_ref([:ref]) end if ! ref ref = repo.branch_ref("master") end @logger.debug("mod #{name}: #{ref}") @results[name] = { :name => name, :ref => ref } end |
#forge(url) ⇒ Object
18 19 20 |
# File 'lib/armature/puppetfile.rb', line 18 def forge(url) @forge_url = url.chomp("/") end |
#include(path) ⇒ Object
FIXME this will have access to @cache and @results
13 14 15 16 |
# File 'lib/armature/puppetfile.rb', line 13 def include(path) instance_eval(IO.read(path), path) @results end |
#mod(full_name, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/armature/puppetfile.rb', line 22 def mod(full_name, ={}) name = full_name.split("-", 2).last() Armature::Environments.assert_valid_module_name(name) if @results[name] raise "Module #{name} declared twice" end is_forge = .is_a?(Symbol) \ || .is_a?(String) \ || == {} \ || == nil if is_forge _mod_forge(full_name, name, ) elsif [:git] _mod_git(name, ) else raise "Invalid mod call: #{full_name} #{}" end end |