Class: Generamba::ModuleTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/generamba/code_generation/module_template.rb

Overview

Represents a single Generamba module template

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = nil) ⇒ ModuleTemplate

Returns a new instance of ModuleTemplate.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generamba/code_generation/module_template.rb', line 9

def initialize(name, options = nil)
  spec_path = TemplateHelper.obtain_spec(name)

  unless options
    spec = YAML.load_file(spec_path)
  else
    spec_source = IO.read(spec_path)
    spec_template = Liquid::Template.parse(spec_source)
    spec_content = spec_template.render(options)
    spec = YAML.load(spec_content)
  end

  @code_files = spec[TEMPLATE_CODE_FILES_KEY]
  @test_files = spec[TEMPLATE_TEST_FILES_KEY]
  @template_name = spec[TEMPLATE_NAME_KEY]
  @template_path = TemplateHelper.obtain_path(name)
  @dependencies = spec[TEMPLATE_DEPENDENCIES_KEY]
end

Instance Attribute Details

#code_filesObject (readonly)

Returns the value of attribute code_files.



7
8
9
# File 'lib/generamba/code_generation/module_template.rb', line 7

def code_files
  @code_files
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



7
8
9
# File 'lib/generamba/code_generation/module_template.rb', line 7

def dependencies
  @dependencies
end

#template_nameObject (readonly)

Returns the value of attribute template_name.



7
8
9
# File 'lib/generamba/code_generation/module_template.rb', line 7

def template_name
  @template_name
end

#template_pathObject (readonly)

Returns the value of attribute template_path.



7
8
9
# File 'lib/generamba/code_generation/module_template.rb', line 7

def template_path
  @template_path
end

#test_filesObject (readonly)

Returns the value of attribute test_files.



7
8
9
# File 'lib/generamba/code_generation/module_template.rb', line 7

def test_files
  @test_files
end