Class: Librarian::Puppet::Source::Forge::Repo
- Inherits:
-
Object
- Object
- Librarian::Puppet::Source::Forge::Repo
- Includes:
- Helpers::Debug
- Defined in:
- lib/librarian/puppet/source/forge.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #cache_path ⇒ Object
- #cache_version_unpacked!(version) ⇒ Object
- #dependencies(version) ⇒ Object
- #environment ⇒ Object
- #hexdigest(value) ⇒ Object
-
#initialize(source, name) ⇒ Repo
constructor
A new instance of Repo.
- #install_version!(version, install_path) ⇒ Object
- #manifests ⇒ Object
- #version_unpacked_cache_path(version) ⇒ Object
- #versions ⇒ Object
Constructor Details
#initialize(source, name) ⇒ Repo
Returns a new instance of Repo.
17 18 19 20 |
# File 'lib/librarian/puppet/source/forge.rb', line 17 def initialize(source, name) self.source = source self.name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/librarian/puppet/source/forge.rb', line 14 def name @name end |
#source ⇒ Object
Returns the value of attribute source.
14 15 16 |
# File 'lib/librarian/puppet/source/forge.rb', line 14 def source @source end |
Instance Method Details
#cache_path ⇒ Object
59 60 61 |
# File 'lib/librarian/puppet/source/forge.rb', line 59 def cache_path @cache_path ||= source.cache_path.join(name) end |
#cache_version_unpacked!(version) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/librarian/puppet/source/forge.rb', line 71 def cache_version_unpacked!(version) path = version_unpacked_cache_path(version) return if path.directory? path.mkpath output = `puppet module install -i #{path.to_s} --modulepath #{path.to_s} --ignore-dependencies #{name} 2>&1` debug { output } end |
#dependencies(version) ⇒ Object
31 32 33 34 |
# File 'lib/librarian/puppet/source/forge.rb', line 31 def dependencies(version) data = api_call("api/v1/releases.json?module=#{name}&version=#{version}") data[name].first['dependencies'] end |
#environment ⇒ Object
55 56 57 |
# File 'lib/librarian/puppet/source/forge.rb', line 55 def environment source.environment end |
#hexdigest(value) ⇒ Object
67 68 69 |
# File 'lib/librarian/puppet/source/forge.rb', line 67 def hexdigest(value) Digest::MD5.hexdigest(value) end |
#install_version!(version, install_path) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/librarian/puppet/source/forge.rb', line 42 def install_version!(version, install_path) cache_version_unpacked! version if install_path.exist? debug { "Deleting #{relative_path_to(install_path)}" } install_path.rmtree end unpacked_path = version_unpacked_cache_path(version).join(name.split('/').last) debug { "Copying #{relative_path_to(unpacked_path)} to #{relative_path_to(install_path)}" } FileUtils.cp_r(unpacked_path, install_path) end |
#manifests ⇒ Object
36 37 38 39 40 |
# File 'lib/librarian/puppet/source/forge.rb', line 36 def manifests versions.map do |version| Manifest.new(source, name, version) end end |
#version_unpacked_cache_path(version) ⇒ Object
63 64 65 |
# File 'lib/librarian/puppet/source/forge.rb', line 63 def version_unpacked_cache_path(version) cache_path.join('version').join(hexdigest(version.to_s)) end |
#versions ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/librarian/puppet/source/forge.rb', line 22 def versions data = api_call("#{name}.json") if data.nil? raise Error, "Unable to find module '#{name}' on #{source}" end data['releases'].map { |r| r['version'] }.sort.reverse end |