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.
244 245 246 247 248 |
# File 'lib/librarian/puppet/source/forge.rb', line 244 def initialize(environment, uri, = {}) self.environment = environment @uri = uri @cache_path = nil end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
240 241 242 |
# File 'lib/librarian/puppet/source/forge.rb', line 240 def environment @environment end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
242 243 244 |
# File 'lib/librarian/puppet/source/forge.rb', line 242 def uri @uri end |
Class Method Details
.from_lock_options(environment, options) ⇒ Object
225 226 227 |
# File 'lib/librarian/puppet/source/forge.rb', line 225 def (environment, ) new(environment, [:remote], .reject { |k, v| k == :remote }) end |
.from_spec_args(environment, uri, options) ⇒ Object
229 230 231 232 233 234 235 236 237 |
# File 'lib/librarian/puppet/source/forge.rb', line 229 def from_spec_args(environment, uri, ) = [] = .keys - unless .empty? raise Error, "unrecognised options: #{.join(", ")}" end new(environment, uri, ) end |
.lock_name ⇒ Object
221 222 223 |
# File 'lib/librarian/puppet/source/forge.rb', line 221 def lock_name LOCK_NAME end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
254 255 256 257 258 |
# File 'lib/librarian/puppet/source/forge.rb', line 254 def ==(other) other && self.class == other.class && self.uri == other.uri end |
#cache_path ⇒ Object
304 305 306 307 308 309 |
# File 'lib/librarian/puppet/source/forge.rb', line 304 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
324 325 326 327 328 329 330 331 332 333 |
# File 'lib/librarian/puppet/source/forge.rb', line 324 def fetch_dependencies(name, version, version_uri) environment.logger.debug { " Fetching dependencies for #{name} #{version}" } repo(name).dependencies(version).map do |k, v| begin 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
315 316 317 318 319 320 321 322 |
# File 'lib/librarian/puppet/source/forge.rb', line 315 def fetch_version(name, version_uri) versions = repo(name).versions if versions.include? version_uri version_uri else versions.first end end |
#hash ⇒ Object
261 262 263 |
# File 'lib/librarian/puppet/source/forge.rb', line 261 def hash self.uri.hash end |
#install!(manifest) ⇒ Object
286 287 288 289 290 291 292 293 294 295 |
# File 'lib/librarian/puppet/source/forge.rb', line 286 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
311 312 313 |
# File 'lib/librarian/puppet/source/forge.rb', line 311 def install_path(name) environment.install_path.join(name.split('/').last) end |
#manifest(name, version, dependencies) ⇒ Object
297 298 299 300 301 302 |
# File 'lib/librarian/puppet/source/forge.rb', line 297 def manifest(name, version, dependencies) manifest = Manifest.new(self, name) manifest.version = version manifest.dependencies = dependencies manifest end |
#manifests(name) ⇒ Object
335 336 337 |
# File 'lib/librarian/puppet/source/forge.rb', line 335 def manifests(name) repo(name).manifests end |
#pinned? ⇒ Boolean
279 280 281 |
# File 'lib/librarian/puppet/source/forge.rb', line 279 def pinned? false end |
#to_lock_options ⇒ Object
275 276 277 |
# File 'lib/librarian/puppet/source/forge.rb', line 275 def {:remote => uri} end |
#to_s ⇒ Object
250 251 252 |
# File 'lib/librarian/puppet/source/forge.rb', line 250 def to_s uri end |
#to_spec_args ⇒ Object
271 272 273 |
# File 'lib/librarian/puppet/source/forge.rb', line 271 def to_spec_args [uri, {}] end |
#unpin! ⇒ Object
283 284 |
# File 'lib/librarian/puppet/source/forge.rb', line 283 def unpin! end |