class Berkshelf::PathLocation

Public Instance Methods

==(other) click to toggle source
# File lib/berkshelf/locations/path.rb, line 50
def ==(other)
  other.is_a?(PathLocation) &&
    other.metadata? == metadata? &&
    other.relative_path == relative_path
end
cached_cookbook() click to toggle source

@see BaseLocation#cached_cookbook

# File lib/berkshelf/locations/path.rb, line 20
def cached_cookbook
  @cached_cookbook ||= CachedCookbook.from_path(expanded_path)
end
expanded_path() click to toggle source

The fully expanded path of this cookbook on disk, relative to the Berksfile.

@return [Pathname]

# File lib/berkshelf/locations/path.rb, line 46
def expanded_path
  @expanded_path ||= Pathname.new File.expand_path(options[:path], File.dirname(dependency.berksfile.filepath))
end
inspect() click to toggle source
# File lib/berkshelf/locations/path.rb, line 66
def inspect
  "#<Berkshelf::PathLocation metadata: #{metadata?}, path: #{relative_path}>"
end
install() click to toggle source

The installation for a path location is actually just a noop

@see BaseLocation#install

# File lib/berkshelf/locations/path.rb, line 15
def install
  validate_cached!(expanded_path)
end
installed?() click to toggle source

Technically path locations are always installed, but this method intentionally returns false to force validation of the cookbook at the path.

@see BaseLocation#installed?

# File lib/berkshelf/locations/path.rb, line 8
def installed?
  false
end
metadata?() click to toggle source

Returns true if the location is a metadata location. By default, no locations are the metadata location.

@return [Boolean]

# File lib/berkshelf/locations/path.rb, line 28
def metadata?
  !!options[:metadata]
end
relative_path() click to toggle source

Return this PathLocation’s path relative to the associated Berksfile. It is actually the path reative to the associated Berksfile’s parent directory.

@return [Pathname]

the relative path relative to the target
# File lib/berkshelf/locations/path.rb, line 38
def relative_path
  @relative_path ||= expanded_path.relative_path_from(Pathname.new(File.dirname(dependency.berksfile.filepath)))
end
to_lock() click to toggle source
# File lib/berkshelf/locations/path.rb, line 56
def to_lock
  out =  "    path: #{relative_path}\n"
  out << "    metadata: true\n" if metadata?
  out
end
to_s() click to toggle source
# File lib/berkshelf/locations/path.rb, line 62
def to_s
  "source at #{relative_path}"
end