Class: Generamba::TemplateHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/generamba/helpers/template_helper.rb

Overview

Provides a number of helper methods for manipulating Generamba template files

Class Method Summary collapse

Class Method Details

.obtain_path(template_name) ⇒ Pathname

Returns a file path for a specific template folder

Parameters:

  • template_name (String)

    The Generamba template name

Returns:

  • (Pathname)

Raises:

  • (StandardError)


19
20
21
22
23
24
25
26
27
28
# File 'lib/generamba/helpers/template_helper.rb', line 19

def self.obtain_path(template_name)
  path = Pathname.new(Dir.getwd)
                 .join(TEMPLATES_FOLDER)
                 .join(template_name)

  error_description = "Cannot find template named #{template_name}! Add it to the Rambafile and run *generamba template install*".red
  raise StandardError, error_description unless path.exist?

  path
end

.obtain_spec(template_name) ⇒ Pathname

Returns a file path for a specific template .rambaspec file

Parameters:

  • template_name (String)

    The Generamba template name

Returns:

  • (Pathname)


8
9
10
11
12
13
# File 'lib/generamba/helpers/template_helper.rb', line 8

def self.obtain_spec(template_name)
  template_path = self.obtain_path(template_name)
  spec_path = template_path.join(template_name + RAMBASPEC_EXTENSION)

  spec_path
end