Class: Librarian::Puppet::Source::Forge
- Inherits:
-
Object
- Object
- Librarian::Puppet::Source::Forge
- Includes:
- Helpers::Debug
- Defined in:
- lib/librarian/puppet/source/forge.rb
Defined Under Namespace
Classes: Repo
Constant Summary collapse
- LOCK_NAME =
'FORGE'
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
- .from_lock_options(environment, options) ⇒ Object
- .from_spec_args(environment, uri, options) ⇒ Object
- .lock_name ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cache_path ⇒ Object
- #fetch_dependencies(name, version, version_uri) ⇒ Object
- #fetch_version(name, version_uri) ⇒ Object
-
#initialize(environment, uri, options = {}) ⇒ Forge
constructor
A new instance of Forge.
- #install!(manifest) ⇒ Object
- #install_path(name) ⇒ Object
- #manifest(name, version, dependencies) ⇒ Object
- #manifests(name) ⇒ Object
- #pinned? ⇒ Boolean
- #to_lock_options ⇒ Object
- #to_s ⇒ Object
- #to_spec_args ⇒ Object
- #unpin! ⇒ Object
Constructor Details
#initialize(environment, uri, options = {}) ⇒ Forge
Returns a new instance of Forge.
121 122 123 124 125 |
# File 'lib/librarian/puppet/source/forge.rb', line 121 def initialize(environment, uri, = {}) self.environment = environment @uri = uri @cache_path = nil end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
117 118 119 |
# File 'lib/librarian/puppet/source/forge.rb', line 117 def environment @environment end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
119 120 121 |
# File 'lib/librarian/puppet/source/forge.rb', line 119 def uri @uri end |
Class Method Details
.from_lock_options(environment, options) ⇒ Object
102 103 104 |
# File 'lib/librarian/puppet/source/forge.rb', line 102 def (environment, ) new(environment, [:remote], .reject { |k, v| k == :remote }) end |
.from_spec_args(environment, uri, options) ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'lib/librarian/puppet/source/forge.rb', line 106 def from_spec_args(environment, uri, ) = [] = .keys - unless .empty? raise Error, "unrecognised options: #{.join(", ")}" end new(environment, uri, ) end |
.lock_name ⇒ Object
98 99 100 |
# File 'lib/librarian/puppet/source/forge.rb', line 98 def lock_name LOCK_NAME end |
Instance Method Details
#==(other) ⇒ Object
131 132 133 134 135 |
# File 'lib/librarian/puppet/source/forge.rb', line 131 def ==(other) other && self.class == other.class && self.uri == other.uri end |
#cache_path ⇒ Object
172 173 174 175 176 177 |
# File 'lib/librarian/puppet/source/forge.rb', line 172 def cache_path @cache_path ||= begin dir = Digest::MD5.hexdigest(uri) environment.cache_path.join("source/puppet/forge/#{dir}") end end |
#fetch_dependencies(name, version, version_uri) ⇒ Object
192 193 194 195 196 |
# File 'lib/librarian/puppet/source/forge.rb', line 192 def fetch_dependencies(name, version, version_uri) repo(name).dependencies(version).map do |k, v| Dependency.new(k, v, nil) end end |
#fetch_version(name, version_uri) ⇒ Object
183 184 185 186 187 188 189 190 |
# File 'lib/librarian/puppet/source/forge.rb', line 183 def fetch_version(name, version_uri) versions = repo(name).versions if versions.include? version_uri version_uri else versions.first end end |
#install!(manifest) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/librarian/puppet/source/forge.rb', line 152 def install!(manifest) manifest.source == self or raise ArgumentError name = manifest.name version = manifest.version install_path = install_path(name) repo = repo(name) debug { "Installing #{manifest}" } repo.install_version! version, install_path end |
#install_path(name) ⇒ Object
179 180 181 |
# File 'lib/librarian/puppet/source/forge.rb', line 179 def install_path(name) environment.install_path.join(name.split('/').last) end |
#manifest(name, version, dependencies) ⇒ Object
165 166 167 168 169 170 |
# File 'lib/librarian/puppet/source/forge.rb', line 165 def manifest(name, version, dependencies) manifest = Manifest.new(self, name) manifest.version = version manifest.dependencies = dependencies manifest end |
#manifests(name) ⇒ Object
198 199 200 |
# File 'lib/librarian/puppet/source/forge.rb', line 198 def manifests(name) repo(name).manifests end |
#pinned? ⇒ Boolean
145 146 147 |
# File 'lib/librarian/puppet/source/forge.rb', line 145 def pinned? false end |
#to_lock_options ⇒ Object
141 142 143 |
# File 'lib/librarian/puppet/source/forge.rb', line 141 def {:remote => uri} end |
#to_s ⇒ Object
127 128 129 |
# File 'lib/librarian/puppet/source/forge.rb', line 127 def to_s uri end |
#to_spec_args ⇒ Object
137 138 139 |
# File 'lib/librarian/puppet/source/forge.rb', line 137 def to_spec_args [uri, {}] end |
#unpin! ⇒ Object
149 150 |
# File 'lib/librarian/puppet/source/forge.rb', line 149 def unpin! end |