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.
396 397 398 399 |
# File 'lib/librarian/chef/source/site.rb', line 396 def initialize(environment, uri, = {}) self.environment = environment self.uri = uri end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
393 394 395 |
# File 'lib/librarian/chef/source/site.rb', line 393 def environment @environment end |
#uri ⇒ Object
Returns the value of attribute uri.
393 394 395 |
# File 'lib/librarian/chef/source/site.rb', line 393 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
405 406 407 408 409 |
# File 'lib/librarian/chef/source/site.rb', line 405 def ==(other) other && self.class == other.class && self.uri == other.uri end |
#cache_path ⇒ Object
447 448 449 450 451 452 |
# File 'lib/librarian/chef/source/site.rb', line 447 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
462 463 464 |
# File 'lib/librarian/chef/source/site.rb', line 462 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
458 459 460 |
# File 'lib/librarian/chef/source/site.rb', line 458 def fetch_version(name, version_uri) line(name).to_version(version_uri) end |
#install!(manifest) ⇒ Object
426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/librarian/chef/source/site.rb', line 426 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
454 455 456 |
# File 'lib/librarian/chef/source/site.rb', line 454 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
443 444 445 |
# File 'lib/librarian/chef/source/site.rb', line 443 def manifests(name) line(name).manifests end |
#pinned? ⇒ Boolean
419 420 421 |
# File 'lib/librarian/chef/source/site.rb', line 419 def pinned? false end |
#to_lock_options ⇒ Object
415 416 417 |
# File 'lib/librarian/chef/source/site.rb', line 415 def {:remote => uri} end |
#to_s ⇒ Object
401 402 403 |
# File 'lib/librarian/chef/source/site.rb', line 401 def to_s uri end |
#to_spec_args ⇒ Object
411 412 413 |
# File 'lib/librarian/chef/source/site.rb', line 411 def to_spec_args [uri, {}] end |
#unpin! ⇒ Object
423 424 |
# File 'lib/librarian/chef/source/site.rb', line 423 def unpin! end |