class Ridley::Chef::Chefignore

Constants

FILENAME

The filename of the chefignore

@return [String]

Public Class Methods

new(path = Dir.pwd) click to toggle source

Create a new chefignore

@param [#to_s] path

the path to find a chefignore from (default: `Dir.pwd`)
Calls superclass method
# File lib/ridley/chef/chefignore.rb, line 16
def initialize(path = Dir.pwd)
  ignore = chefignore(path)

  if ignore
    log.debug "Using '#{FILENAME}' at '#{ignore}'"
  end

  super(ignore, base: path)
end

Private Instance Methods

chefignore(path) click to toggle source

Find the chefignore file in the current directory

@return [String, nil]

the path to the chefignore file or nil if one was not
found
# File lib/ridley/chef/chefignore.rb, line 33
def chefignore(path)
  Pathname.new(path).ascend do |dir|
    next unless dir.directory?

    [
      dir.join(FILENAME),
      dir.join('cookbooks', FILENAME),
      dir.join('.chef',     FILENAME),
    ].each do |possible|
      return possible.expand_path.to_s if possible.exist?
    end
  end

  nil
end