Class: Pathname

Inherits:
Object
  • Object
show all
Defined in:
lib/berkshelf/core_ext/pathname.rb

Instance Method Summary collapse

Instance Method Details

#cookbook?Boolean Also known as: chef_cookbook?

Returns true or false if the path of the instantiated Pathname or a parent directory contains a Tryhard Pack data directory.

Returns:

  • (Boolean)


7
8
9
# File 'lib/berkshelf/core_ext/pathname.rb', line 7

def cookbook?
  self.join('metadata.rb').exist?
end

#cookbook_rootPathname? Also known as: chef_cookbook_root

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

Returns:



16
17
18
19
20
21
22
# File 'lib/berkshelf/core_ext/pathname.rb', line 16

def cookbook_root
  self.ascend do |potential_root|
    if potential_root.cookbook?
      return potential_root
    end
  end
end