Class: CookbookOmnifetch::BaseLocation
- Inherits:
-
Object
- Object
- CookbookOmnifetch::BaseLocation
- Defined in:
- lib/cookbook-omnifetch/base.rb
Direct Known Subclasses
ArtifactoryLocation, ArtifactserverLocation, ChefServerArtifactLocation, ChefServerLocation, GitLocation, PathLocation
Instance Attribute Summary collapse
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#cached_cookbook ⇒ CachedCookbook
The cached cookbook for this location.
-
#initialize(dependency, options = {}) ⇒ BaseLocation
constructor
A new instance of BaseLocation.
-
#install ⇒ void
Install the given cookbook.
-
#installed? ⇒ Boolean
Determine if this revision is installed.
-
#lock_data ⇒ Hash
A representation of this location suitable for a lockfile, given as a Hash.
-
#to_lock ⇒ string
The lockfile representation of this location.
-
#validate_cached!(path) ⇒ true
Ensure the given CachedCookbook is valid.
Constructor Details
#initialize(dependency, options = {}) ⇒ BaseLocation
Returns a new instance of BaseLocation.
8 9 10 11 |
# File 'lib/cookbook-omnifetch/base.rb', line 8 def initialize(dependency, = {}) @dependency = dependency @options = end |
Instance Attribute Details
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
5 6 7 |
# File 'lib/cookbook-omnifetch/base.rb', line 5 def dependency @dependency end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/cookbook-omnifetch/base.rb', line 6 def @options end |
Instance Method Details
#cached_cookbook ⇒ CachedCookbook
The cached cookbook for this location.
33 34 35 36 |
# File 'lib/cookbook-omnifetch/base.rb', line 33 def cached_cookbook raise AbstractFunction, "#cached_cookbook must be implemented on #{self.class.name}!" end |
#install ⇒ void
This method returns an undefined value.
Install the given cookbook. Subclasses that implement this method should perform all the installation and validation steps required.
25 26 27 28 |
# File 'lib/cookbook-omnifetch/base.rb', line 25 def install raise AbstractFunction, "#install must be implemented on #{self.class.name}!" end |
#installed? ⇒ Boolean
Determine if this revision is installed.
16 17 18 19 |
# File 'lib/cookbook-omnifetch/base.rb', line 16 def installed? raise AbstractFunction, "#installed? must be implemented on #{self.class.name}!" end |
#lock_data ⇒ Hash
A representation of this location suitable for a lockfile, given as a Hash
41 42 43 44 |
# File 'lib/cookbook-omnifetch/base.rb', line 41 def lock_data raise AbstractFunction, "#to_lock must be implemented on #{self.class.name}!" end |
#to_lock ⇒ string
The lockfile representation of this location.
49 50 51 52 |
# File 'lib/cookbook-omnifetch/base.rb', line 49 def to_lock raise AbstractFunction, "#to_lock must be implemented on #{self.class.name}!" end |
#validate_cached!(path) ⇒ true
Ensure the given CachedCookbook is valid
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cookbook-omnifetch/base.rb', line 67 def validate_cached!(path) unless CookbookOmnifetch.cookbook?(path) raise NotACookbook.new(path) end cookbook = CookbookOmnifetch.cached_cookbook_class.from_path(path) unless @dependency.version_constraint.satisfies?(cookbook.version) raise CookbookValidationFailure.new(dependency, cookbook) end unless @dependency.name == cookbook.cookbook_name raise MismatchedCookbookName.new(dependency, cookbook) end true end |