Class: Librarian::Chef::Source::Site
- Inherits:
-
Object
- Object
- Librarian::Chef::Source::Site
- Includes:
- Source::BasicApi
- Defined in:
- lib/librarian/chef/source/site.rb
Defined Under Namespace
Classes: Line
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
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 = {}) ⇒ Site
constructor
A new instance of Site.
- #install!(manifest) ⇒ Object
- #install_path(name) ⇒ Object
-
#manifests(name) ⇒ Object
NOTE: Assumes the Opscode Site API responds with versions in reverse sorted order.
- #pinned? ⇒ Boolean
- #to_lock_options ⇒ Object
- #to_s ⇒ Object
- #to_spec_args ⇒ Object
- #unpin! ⇒ Object
Constructor Details
#initialize(environment, uri, options = {}) ⇒ Site
Returns a new instance of Site.
395 396 397 398 |
# File 'lib/librarian/chef/source/site.rb', line 395 def initialize(environment, uri, = {}) self.environment = environment self.uri = uri end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
392 393 394 |
# File 'lib/librarian/chef/source/site.rb', line 392 def environment @environment end |
#uri ⇒ Object
Returns the value of attribute uri.
392 393 394 |
# File 'lib/librarian/chef/source/site.rb', line 392 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
404 405 406 407 408 |
# File 'lib/librarian/chef/source/site.rb', line 404 def ==(other) other && self.class == other.class && self.uri == other.uri end |
#cache_path ⇒ Object
446 447 448 449 450 451 |
# File 'lib/librarian/chef/source/site.rb', line 446 def cache_path @cache_path ||= begin dir = Digest::MD5.hexdigest(uri)[0..15] environment.cache_path.join("source/chef/site/#{dir}") end end |
#fetch_dependencies(name, version, version_uri) ⇒ Object
461 462 463 |
# File 'lib/librarian/chef/source/site.rb', line 461 def fetch_dependencies(name, version, version_uri) line(name).version_dependencies(version).map{|k, v| Dependency.new(k, v, nil)} end |
#fetch_version(name, version_uri) ⇒ Object
457 458 459 |
# File 'lib/librarian/chef/source/site.rb', line 457 def fetch_version(name, version_uri) line(name).to_version(version_uri) end |
#install!(manifest) ⇒ Object
425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/librarian/chef/source/site.rb', line 425 def install!(manifest) manifest.source == self or raise ArgumentError name = manifest.name version = manifest.version install_path = install_path(name) line = line(name) info { "Installing #{manifest.name} (#{manifest.version})" } debug { "Installing #{manifest}" } line.install_version! version, install_path end |
#install_path(name) ⇒ Object
453 454 455 |
# File 'lib/librarian/chef/source/site.rb', line 453 def install_path(name) environment.install_path.join(name) end |
#manifests(name) ⇒ Object
NOTE:
Assumes the Opscode Site API responds with versions in reverse sorted order
442 443 444 |
# File 'lib/librarian/chef/source/site.rb', line 442 def manifests(name) line(name).manifests end |
#pinned? ⇒ Boolean
418 419 420 |
# File 'lib/librarian/chef/source/site.rb', line 418 def pinned? false end |
#to_lock_options ⇒ Object
414 415 416 |
# File 'lib/librarian/chef/source/site.rb', line 414 def {:remote => uri} end |
#to_s ⇒ Object
400 401 402 |
# File 'lib/librarian/chef/source/site.rb', line 400 def to_s uri end |
#to_spec_args ⇒ Object
410 411 412 |
# File 'lib/librarian/chef/source/site.rb', line 410 def to_spec_args [uri, {}] end |
#unpin! ⇒ Object
422 423 |
# File 'lib/librarian/chef/source/site.rb', line 422 def unpin! end |