Class: Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/scaffolding/generator.rb

Class Method Summary collapse

Class Method Details

.create_stub(filename, template, options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/scaffolding/generator.rb', line 4

def self.create_stub(filename, template, options)
  template_content = ""
  File.open(File.dirname(__FILE__) + "/templates/#{template}.ftt") do |file|
    template_content = file.lines.to_a.join
  end
  options.keys.each do |param|
    template_content.gsub!("$#{param}".upcase, "#{options[param]}")
  end
  File.open(filename, 'w+') do |file|
    file << template_content
  end
end