Class: Berkshelf::BaseLocation
- Inherits:
-
Object
- Object
- Berkshelf::BaseLocation
- Defined in:
- lib/berkshelf/locations/base.rb
Direct Known Subclasses
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.
-
#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.
6 7 8 9 |
# File 'lib/berkshelf/locations/base.rb', line 6 def initialize(dependency, = {}) @dependency = dependency @options = end |
Instance Attribute Details
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
3 4 5 |
# File 'lib/berkshelf/locations/base.rb', line 3 def dependency @dependency end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/berkshelf/locations/base.rb', line 4 def @options end |
Instance Method Details
#cached_cookbook ⇒ CachedCookbook
The cached cookbook for this location.
31 32 33 34 |
# File 'lib/berkshelf/locations/base.rb', line 31 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.
23 24 25 26 |
# File 'lib/berkshelf/locations/base.rb', line 23 def install raise AbstractFunction, "#install must be implemented on #{self.class.name}!" end |
#installed? ⇒ Boolean
Determine if this revision is installed.
14 15 16 17 |
# File 'lib/berkshelf/locations/base.rb', line 14 def installed? raise AbstractFunction, "#installed? must be implemented on #{self.class.name}!" end |
#to_lock ⇒ string
The lockfile representation of this location.
39 40 41 42 |
# File 'lib/berkshelf/locations/base.rb', line 39 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
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/berkshelf/locations/base.rb', line 57 def validate_cached!(path) unless File.cookbook?(path) raise NotACookbook.new(path) end begin cookbook = CachedCookbook.from_path(path) rescue => e raise InternalError, "The following error occurred while reading the " \ "cookbook `#{dependency.name}':\n#{e.class}: #{e.}" end 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 |