lib/garcon/chef/chef_helpers.rb
# Checks for existence of a cookbook file or template source in a cookbook.
#
# @example
#   has_source?("foo.erb", :templates)
#   has_source?("bar.conf", :files, "a_cookbook")
#
# @param [String] source
#   Name of the desired template or cookbook file source.
#
# @param [Symbol] segment
#   One of `:files` or `:templates`.
#
# @param [String, Nil] cookbook
#   The name of the cookbook to look in, defaults to current cookbook.
#
# @return [String, Nil]
#   Full path to the source or nil if it doesn't exist.
#
Checks for existence of a cookbook file or template source in a cookbook.
Checks for existence of a cookbook file or template source in a cookbook .
def has_source?(source, segment, cookbook = nil)
      cookbook ||= cookbook_name
      begin
        run_context.cookbook_collection[cookbook].send(
          :find_preferred_manifest_record, run_context.node, segment, source
        )
      rescue Chef::Exceptions::FileNotFound
        nil
      end
    end
def has_source? ( source , segment , cookbook = nil ) cookbook ||= cookbook_name begin run_context . cookbook_collection [ cookbook ] . send ( :find_preferred_manifest_record , run_context . node , segment , source ) rescue Chef :: Exceptions :: FileNotFound nil end end
Checks for existence of a cookbook file or template source in a cookbook.
Checks for existence of a cookbook file or template source in a cookbook .
Full path to the source or nil if it doesn't exist.
Full path to the source or nil if it doesn ' t exist .
String, Nil
source
<not_specific>
segment
<not_specific>
cookbook
<not_specific>
<not_specific>
cookbook The name of the cookbook to look in, defaults to current cookbook.
cookbook The name of the cookbook to look in defaults to current cookbook .
current cookbook
example
has_source?("foo.erb", :templates) has_source?("bar.conf", :files, "a_cookbook")
has_source? ( " foo . erb " : templates ) has_source? ( " bar . conf " : files " a_cookbook " )