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