lib/berkshelf/cached_cookbook.rb in berkshelf-1.1.2 vs lib/berkshelf/cached_cookbook.rb in berkshelf-1.1.3

- old
+ new

@@ -1,6 +1,11 @@ -require 'chef/checksum_cache' +if Berkshelf.chef_11? + require 'chef/digester' +else + require 'chef/checksum_cache' +end + require 'chef/cookbook/syntax_check' module Berkshelf # @author Jamie Winsor <jamie@vialstudios.com> class CachedCookbook @@ -47,20 +52,26 @@ metadata.from_file(path.join("metadata.rb").to_s) rescue IOError raise CookbookNotFound, "No 'metadata.rb' file found at: '#{path}'" end + metadata.name cached_name if metadata.name.empty? + new(cached_name, path, metadata) end # @param [String] filepath # a path on disk to the location of a file to checksum # # @return [String] # a checksum that can be used to uniquely identify the file understood # by a Chef Server. def checksum(filepath) - Chef::ChecksumCache.generate_md5_checksum_for_file(filepath) + if Berkshelf.chef_11? + Chef::Digester.generate_md5_checksum_for_file(filepath) + else + Chef::ChecksumCache.generate_md5_checksum_for_file(filepath) + end end end DIRNAME_REGEXP = /^(.+)-(.+)$/ CHEF_TYPE = "cookbook_version".freeze