Class: Cog::GeneratorSandbox

Inherits:
Object
  • Object
show all
Includes:
Generator
Defined in:
lib/cog/generator_sandbox.rb

Overview

Generators files are executed as instances of this type. Plugins make themselves available to generators via a call to DSL::Cogfile#autoload_plugin

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Generator

#embed, #gcontext, #stamp

Methods included from Cog::Generator::LanguageMethods

#end_all_scopes, #include_guard_begin, #named_scope_begin, #scope_begin, #scope_end, #use_named_scope, #warning

Methods included from Cog::Generator::Filters

#call_filter, #comment

Methods included from Cog::Generator::FileMethods

#copy_file_if_missing, #files_are_same?, #get_template, #touch_directory, #touch_file

Constructor Details

#initialize(path) ⇒ GeneratorSandbox

Returns a new instance of GeneratorSandbox.

Parameters:

  • path (String)

    path to the generator ruby file



11
12
13
# File 'lib/cog/generator_sandbox.rb', line 11

def initialize(path)
  @path = path
end

Class Method Details

.autoload_plugin(name, path) ⇒ nil

Register an autoload variable.

Returns:

  • (nil)


26
27
28
29
# File 'lib/cog/generator_sandbox.rb', line 26

def self.autoload_plugin(name, path)
  autoload name, path
  nil
end

Instance Method Details

#interpretnil

Interpret the generator ruby file as this instance

Returns:

  • (nil)


18
19
20
21
# File 'lib/cog/generator_sandbox.rb', line 18

def interpret
  eval File.read(@path), binding
  nil
end