lib/berkshelf/lockfile.rb in berkshelf-2.0.5 vs lib/berkshelf/lockfile.rb in berkshelf-2.0.6

- old
+ new

@@ -11,14 +11,10 @@ # @return [Berkshelf::Berksfile] # the Berksfile for this Lockfile attr_reader :berksfile - # @return [String] - # the last known SHA of the Berksfile - attr_accessor :sha - # Create a new lockfile instance associated with the given Berksfile. If a # Lockfile exists, it is automatically loaded. Otherwise, an empty instance is # created and ready for use. # # @param berksfile [Berkshelf::Berksfile] @@ -32,25 +28,17 @@ end # Load the lockfile from file system. def load! contents = File.read(filepath).strip - hash = parse(contents) - @sha = hash[:sha] hash[:sources].each do |name, options| add(CookbookSource.new(berksfile, name.to_s, options)) end end - # Set the sha value to nil to mark that the lockfile is not out of - # sync with the Berksfile. - def reset_sha! - @sha = nil - end - # The list of sources constrained in this lockfile. # # @return [Array<Berkshelf::CookbookSource>] # the list of sources in this lockfile def sources @@ -84,14 +72,12 @@ # # @param [Array<Berkshelf::CookbookSource>] sources # the list of sources to update # @option options [String] :sha # the sha of the Berksfile updating the sources - def update(sources, options = {}) + def update(sources) reset_sources! - @sha = options[:sha] - sources.each { |source| append(source) } save end # Add the given source to the `sources` list, if it doesn't already exist. @@ -135,15 +121,13 @@ # Write the current lockfile to a hash # # @return [Hash] # the hash representation of this lockfile - # * :sha [String] the last-known sha for the berksfile # * :sources [Array<Berkshelf::CookbookSource>] the list of sources def to_hash { - sha: sha, sources: @sources } end # The JSON representation of this lockfile @@ -223,11 +207,10 @@ hash[source.name] = source.options end end { - sha: nil, - sources: sources + sources: sources, } end end # @return [Hash]