Class: ConfigTemplates::Models::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/config_templates/models/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_path, config) ⇒ Template

Returns a new instance of Template.



5
6
7
8
# File 'lib/config_templates/models/template.rb', line 5

def initialize(source_path, config)
  @source_path = source_path
  @config = config
end

Instance Attribute Details

#source_pathObject (readonly)

Returns the value of attribute source_path.



3
4
5
# File 'lib/config_templates/models/template.rb', line 3

def source_path
  @source_path
end

Instance Method Details

#contentObject



10
11
12
# File 'lib/config_templates/models/template.rb', line 10

def content
  @content ||= ::File.read @source_path
end

#destination_pathObject



18
19
20
# File 'lib/config_templates/models/template.rb', line 18

def destination_path
  ::File.join @config.destination_path, @config.stage.to_s, @source_path.sub(@config.templates_path, '')
end

#extensionObject



14
15
16
# File 'lib/config_templates/models/template.rb', line 14

def extension
  ::File.extname @source_path
end