class Pathname

Public Instance Methods

chef_cookbook?()
Alias for: cookbook?
chef_cookbook_root()
Alias for: cookbook_root
cookbook?() click to toggle source

Returns true or false if the path contains a “metadata.json” or a “metadata.rb” file.

@return [Boolean]

# File lib/berkshelf/core_ext/pathname.rb, line 5
def cookbook?
  join("metadata.json").exist? || join("metadata.rb").exist?
end
Also aliased as: chef_cookbook?
cookbook_root() click to toggle source

Ascend the directory structure from the given path to find the root of a Cookbook. If no Cookbook is found, nil is returned.

@return [Pathname, nil]

# File lib/berkshelf/core_ext/pathname.rb, line 14
def cookbook_root
  ascend do |potential_root|
    if potential_root.cookbook?
      return potential_root
    end
  end
end
Also aliased as: chef_cookbook_root