Class: CookbookOmnifetch::PathLocation
- Inherits:
-
BaseLocation
- Object
- BaseLocation
- CookbookOmnifetch::PathLocation
- Defined in:
- lib/cookbook-omnifetch/path.rb
Instance Attribute Summary
Attributes inherited from BaseLocation
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cached_cookbook ⇒ Object
-
#expanded_path ⇒ Pathname
The fully expanded path of this cookbook on disk, relative to the Berksfile.
- #inspect ⇒ Object
-
#install ⇒ Object
The installation for a path location is actually just a noop.
- #install_path ⇒ Object
-
#installed? ⇒ Boolean
Technically path locations are always installed, but this method intentionally returns
false
to force validation of the cookbook at the path. - #lock_data ⇒ Object
-
#metadata? ⇒ Boolean
Returns true if the location is a metadata location.
-
#relative_path ⇒ Pathname
Return this PathLocation’s path relative to the associated Berksfile.
- #to_lock ⇒ Object
- #to_s ⇒ Object
Methods inherited from BaseLocation
#initialize, #validate_cached!
Constructor Details
This class inherits a constructor from CookbookOmnifetch::BaseLocation
Instance Method Details
#==(other) ⇒ Object
66 67 68 69 70 |
# File 'lib/cookbook-omnifetch/path.rb', line 66 def ==(other) other.is_a?(PathLocation) && other. == && other.relative_path == relative_path end |
#cached_cookbook ⇒ Object
22 23 24 |
# File 'lib/cookbook-omnifetch/path.rb', line 22 def cached_cookbook @cached_cookbook ||= CookbookOmnifetch.cached_cookbook_class.from_path() end |
#expanded_path ⇒ Pathname
The fully expanded path of this cookbook on disk, relative to the Berksfile.
57 58 59 60 61 62 63 64 |
# File 'lib/cookbook-omnifetch/path.rb', line 57 def # TODO: this requires Berkshelf::Dependency to provide a delegate (ish) method that does # # def relative_paths_root # File.dirname(berksfile.filepath) # end @expanded_path ||= Pathname.new File.([:path], dependency.relative_paths_root) end |
#inspect ⇒ Object
89 90 91 |
# File 'lib/cookbook-omnifetch/path.rb', line 89 def inspect "#<CookbookOmnifetch::PathLocation metadata: #{}, path: #{relative_path}>" end |
#install ⇒ Object
The installation for a path location is actually just a noop
17 18 19 |
# File 'lib/cookbook-omnifetch/path.rb', line 17 def install validate_cached!() end |
#install_path ⇒ Object
34 35 36 |
# File 'lib/cookbook-omnifetch/path.rb', line 34 def install_path relative_path end |
#installed? ⇒ Boolean
Technically path locations are always installed, but this method intentionally returns false
to force validation of the cookbook at the path.
10 11 12 |
# File 'lib/cookbook-omnifetch/path.rb', line 10 def installed? false end |
#lock_data ⇒ Object
72 73 74 75 76 77 |
# File 'lib/cookbook-omnifetch/path.rb', line 72 def lock_data out = {} out["path"] = relative_path.to_s out["metadata"] = true if out end |
#metadata? ⇒ Boolean
Returns true if the location is a metadata location. By default, no locations are the metadata location.
30 31 32 |
# File 'lib/cookbook-omnifetch/path.rb', line 30 def !![:metadata] end |
#relative_path ⇒ Pathname
Return this PathLocation’s path relative to the associated Berksfile. It is actually the path reative to the associated Berksfile’s parent directory.
44 45 46 47 48 49 50 51 |
# File 'lib/cookbook-omnifetch/path.rb', line 44 def relative_path # TODO: this requires Berkshelf::Dependency to provide a delegate (ish) method that does # # def relative_paths_root # File.dirname(berksfile.filepath) # end @relative_path ||= .relative_path_from(Pathname.new(dependency.relative_paths_root)) end |
#to_lock ⇒ Object
79 80 81 82 83 |
# File 'lib/cookbook-omnifetch/path.rb', line 79 def to_lock out = " path: #{relative_path}\n" out << " metadata: true\n" if out end |
#to_s ⇒ Object
85 86 87 |
# File 'lib/cookbook-omnifetch/path.rb', line 85 def to_s "source at #{relative_path}" end |