Class: New::Template

Inherits:
Object
  • Object
show all
Includes:
Interpolate
Defined in:
lib/new/template.rb

Constant Summary collapse

CUSTOM_CONFIG_TEMPLATE =

The foundation for new template configuration files

{
  license: '[LICENSE]',
  version: '0.0.0',
  developer: {
    name: '[NAME]',
    email: '[EMAIL]'
  }
}

Constants included from Interpolate

Interpolate::FILENAME_RENAME_MATCH

Instance Method Summary collapse

Methods included from Interpolate

#dir, #dot_options, #interpolate, #to_filename

Constructor Details

#initialize(type, name) ⇒ Template

Returns a new instance of Template.



17
18
19
20
21
22
# File 'lib/new/template.rb', line 17

def initialize type, name
  @type = type
  @name = name

  interpolate template_dir, options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class New::Interpolate

Instance Method Details

#optionsObject

Create the options object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/new/template.rb', line 26

def options
  # merge options together
  CUSTOM_CONFIG_TEMPLATE.clone
    .deep_merge!(template_config)
    .deep_merge!(New.custom_config)
    .deep_merge!({
      project: {
        name: @name,
        filename: to_filename(@name)
      },
      type: @type.to_s
    })
end