Class: Librarian::Puppet::Source::Forge
- Inherits:
-
Object
- Object
- Librarian::Puppet::Source::Forge
- 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 (also: #eql?)
- #cache_path ⇒ Object
- #fetch_dependencies(name, version, version_uri) ⇒ Object
- #fetch_version(name, version_uri) ⇒ Object
- #hash ⇒ 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.
206 207 208 209 210 |
# File 'lib/librarian/puppet/source/forge.rb', line 206 def initialize(environment, uri, = {}) self.environment = environment @uri = uri @cache_path = nil end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
202 203 204 |
# File 'lib/librarian/puppet/source/forge.rb', line 202 def environment @environment end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
204 205 206 |
# File 'lib/librarian/puppet/source/forge.rb', line 204 def uri @uri end |
Class Method Details
.from_lock_options(environment, options) ⇒ Object
187 188 189 |
# File 'lib/librarian/puppet/source/forge.rb', line 187 def (environment, ) new(environment, [:remote], .reject { |k, v| k == :remote }) end |
.from_spec_args(environment, uri, options) ⇒ Object
191 192 193 194 195 196 197 198 199 |
# File 'lib/librarian/puppet/source/forge.rb', line 191 def from_spec_args(environment, uri, ) = [] = .keys - unless .empty? raise Error, "unrecognised options: #{.join(", ")}" end new(environment, uri, ) end |
.lock_name ⇒ Object
183 184 185 |
# File 'lib/librarian/puppet/source/forge.rb', line 183 def lock_name LOCK_NAME end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
216 217 218 219 220 |
# File 'lib/librarian/puppet/source/forge.rb', line 216 def ==(other) other && self.class == other.class && self.uri == other.uri end |
#cache_path ⇒ Object
266 267 268 269 270 271 |
# File 'lib/librarian/puppet/source/forge.rb', line 266 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
286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/librarian/puppet/source/forge.rb', line 286 def fetch_dependencies(name, version, version_uri) environment.logger.debug { " Fetching dependencies for #{name} #{version}" } repo(name).dependencies(version).map do |k, v| begin v = Requirement.new(v).gem_requirement Dependency.new(k, v, nil) rescue ArgumentError => e raise Error, "Error fetching dependency for #{name} [#{version}]: #{k} [#{v}]: #{e}" end end end |
#fetch_version(name, version_uri) ⇒ Object
277 278 279 280 281 282 283 284 |
# File 'lib/librarian/puppet/source/forge.rb', line 277 def fetch_version(name, version_uri) versions = repo(name).versions if versions.include? version_uri version_uri else versions.first end end |
#hash ⇒ Object
223 224 225 |
# File 'lib/librarian/puppet/source/forge.rb', line 223 def hash self.uri.hash end |
#install!(manifest) ⇒ Object
248 249 250 251 252 253 254 255 256 257 |
# File 'lib/librarian/puppet/source/forge.rb', line 248 def install!(manifest) manifest.source == self or raise ArgumentError name = manifest.name version = manifest.version install_path = install_path(name) repo = repo(name) repo.install_version! version, install_path end |
#install_path(name) ⇒ Object
273 274 275 |
# File 'lib/librarian/puppet/source/forge.rb', line 273 def install_path(name) environment.install_path.join(name.split('/').last) end |
#manifest(name, version, dependencies) ⇒ Object
259 260 261 262 263 264 |
# File 'lib/librarian/puppet/source/forge.rb', line 259 def manifest(name, version, dependencies) manifest = Manifest.new(self, name) manifest.version = version manifest.dependencies = dependencies manifest end |
#manifests(name) ⇒ Object
298 299 300 |
# File 'lib/librarian/puppet/source/forge.rb', line 298 def manifests(name) repo(name).manifests end |
#pinned? ⇒ Boolean
241 242 243 |
# File 'lib/librarian/puppet/source/forge.rb', line 241 def pinned? false end |
#to_lock_options ⇒ Object
237 238 239 |
# File 'lib/librarian/puppet/source/forge.rb', line 237 def {:remote => uri} end |
#to_s ⇒ Object
212 213 214 |
# File 'lib/librarian/puppet/source/forge.rb', line 212 def to_s uri end |
#to_spec_args ⇒ Object
233 234 235 |
# File 'lib/librarian/puppet/source/forge.rb', line 233 def to_spec_args [uri, {}] end |
#unpin! ⇒ Object
245 246 |
# File 'lib/librarian/puppet/source/forge.rb', line 245 def unpin! end |