Class: Pathname
- Inherits:
-
Object
- Object
- Pathname
- Defined in:
- lib/berkshelf/core_ext/pathname.rb
Instance Method Summary collapse
-
#cookbook? ⇒ Boolean
(also: #chef_cookbook?)
Returns true or false if the path contains a “metadata.json” or a “metadata.rb” file.
-
#cookbook_root ⇒ Pathname?
(also: #chef_cookbook_root)
Ascend the directory structure from the given path to find the root of a Cookbook.
Instance Method Details
#cookbook? ⇒ Boolean Also known as: chef_cookbook?
Returns true or false if the path contains a “metadata.json” or a “metadata.rb” file.
5 6 7 |
# File 'lib/berkshelf/core_ext/pathname.rb', line 5 def cookbook? join("metadata.json").exist? || join("metadata.rb").exist? end |
#cookbook_root ⇒ Pathname? Also known as: chef_cookbook_root
Ascend the directory structure from the given path to find the root of a Cookbook. If no Cookbook is found, nil is returned.
14 15 16 17 18 19 20 |
# 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 |