lib/berkshelf/locations/path_location.rb in berkshelf-3.0.0.beta6 vs lib/berkshelf/locations/path_location.rb in berkshelf-3.0.0.beta7

- old
+ new

@@ -47,10 +47,19 @@ return new_path if new_path.index('.') == 0 "./#{new_path}" end + # + # The expanded path of this path on disk, relative to the berksfile. + # + # @return [String] + # + def expanded_path + relative_path(dependency.berksfile.filepath) + end + # Valid if the path exists and is readable # # @return [Boolean] def valid? File.exist?(path) && File.readable?(path) @@ -58,16 +67,22 @@ def to_hash super.merge(value: self.path) end - # The string representation of this PathLocation - # - # @example - # loc.to_s #=> artifact (1.4.0) at path: '/Users/Seth/Dev/artifact' - # - # @return [String] + def ==(other) + other.is_a?(PathLocation) && + other.metadata? == metadata? && + other.expanded_path == expanded_path + end + + def to_lock + out = " path: #{relative_path(dependency.berksfile.filepath)}\n" + out << " metadata: true\n" if metadata? + out + end + def to_s - "#{self.class.location_key}: '#{File.expand_path(path)}'" + "source at #{relative_path(dependency.berksfile.filepath)}" end end end