Class: Redrum::Templates

Inherits:
Object
  • Object
show all
Defined in:
lib/redrum/templates.rb

Class Method Summary collapse

Class Method Details

.copy(project_dir, params = {}) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/redrum/templates.rb', line 3

def self.copy(project_dir, params = {})
  Dir[File.expand_path("../../../templates/#{params[:template]}/*", __FILE__)].each do |template|
    source = template.scan(/templates\/(.+)$/).flatten.to_s
    destination = project_dir + "/" + source.scan(/^.+?\/(.+)$/).to_s
    params[:output_to].puts "Overwriting #{destination} with #{source}" if params[:output_to]
    FileUtils.cp_r(template, project_dir)
  end
end

.list(out = STDOUT) ⇒ Object



12
13
14
15
16
# File 'lib/redrum/templates.rb', line 12

def self.list(out=STDOUT)
  Dir[File.expand_path("../../../templates/*", __FILE__)].each do |template|
   out.puts template.scan(/.+\/([^\/]+)$/).to_s
  end
end