Module: EasyType::FileIncluder

Defined in:
lib/easy_type/file_includer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(parent) ⇒ Object



10
11
12
# File 'lib/easy_type/file_includer.rb', line 10

def self.included(parent)
  parent.extend(FileIncluder)
end

Instance Method Details

#include_file(name, context = nil) ⇒ Object

This is an implementation of a C like include. You can use this at places where Puppet doesn’t support parent-classed like when defining Custum Types. include_file uses the already established search path. If you need to include a file from a subdirectory, use the subdirectory name

Examples:


include_file 'puppet/types/ora'

Parameters:

  • name (String)

    this is the name of the file to be included

Returns:

  • the evaluated content of the file

Raises:

  • (ArgumentError)

    when the specified file is not found



31
32
33
34
35
# File 'lib/easy_type/file_includer.rb', line 31

def include_file(name, context = nil)
  full_name = get_ruby_file(name)
  raise ArgumentError, "file #{name} not found" unless full_name
  eval(IO.read(full_name), context, full_name)
end