Method: Connect::Includer#include

Defined in:
lib/connect/includer.rb

#include(name, &proc) {|name, content| ... } ⇒ Object

Check the the name of the inclusion and decide what to do. The result(s) will be yielded to the specfied closure. This routine can handle:

  • absolute file names without wildcards

  • absolute file names with a wildcard

  • relative file names without wildcards

  • relative file names with a wildcard

If a file extention is not givcen, it will use the default_type

Parameters:

  • name (String)

    the file name.

  • proc (Proc)

    the closure to be yielded.

Yield Parameters:

  • name (String)

    The name of the file to be included

  • content (String)

    The actual content of the file to be included



33
34
35
36
37
38
39
40
41
# File 'lib/connect/includer.rb', line 33

def include(name, &proc)
  path = Pathname.new(name)
  path = with_extension(path) if no_extension?(path)
  path = with_folder(path) unless path.absolute?
  files = Dir.glob(path).each do |file|
    include_file(file, &proc)
  end
  fail ArgumentError, "No files found for #{name}" if files.empty?
end