def cookbook_base_path(file)
      file = File.expand_path(file) # make sure we get an absolute path
      file = File.dirname(file) unless File.directory?(file) # get the dir only

      # get list of items in the dir and intersect with metadata array.
      # until we get an interfact (we have a metadata) walk up the dir structure
      until (Dir.entries(file) & %w{metadata.rb metadata.json}).any?
        file = File.dirname(file)
      end

      file
    end
def cookbook_base_path(file)
      file = File.expand_path(file) # make sure we get an absolute path
      file = File.dirname(file) unless File.directory?(file) # get the dir only

      # get list of items in the dir and intersect with metadata array.
      # until we get an interfact (we have a metadata) walk up the dir structure
      until (Dir.entries(file) & %w{metadata.rb metadata.json}).any?
        file = File.dirname(file)
      end

      file
    end
The absolute path of a cookbook from the specified file.

 @author Tim Smith - tsmith@chef.io
 @since 10.1
 @param file [String, Pathname] relative or absolute path to a file in the cookbook
 @return [String] the absolute path to the base of the cookbook