class RailsGae

Attributes

app_name[R]
destination_folder[R]
rails_version[R]

Public Class Methods

new(app_name) click to toggle source
# File lib/rails_gae.rb, line 10
def initialize(app_name)
  rails_version = '2.3.11'
  @app_name = app_name
  @rails_version = rails_version
end

Public Instance Methods

copy_files() click to toggle source
# File lib/rails_gae.rb, line 26
def copy_files
  FileUtils.cp_r(File.join(files_dir, '.'), destination_folder)
end
create_rails_project() click to toggle source
# File lib/rails_gae.rb, line 22
def create_rails_project
  puts `rails _#{rails_version}_ #{app_name}`
end
files_dir() click to toggle source
# File lib/rails_gae.rb, line 38
def files_dir
  File.join(File.dirname(__FILE__), 'generator', 'files')
end
generate_templates() click to toggle source
# File lib/rails_gae.rb, line 30
def generate_templates
  FileUtils.cp_r(File.join(templates_dir, '.'), destination_folder)
  templates.each do |template|
    file = ERB.new(File.open(template).read)
    File.open(template, 'w+').write(file.result(binding))
  end
end
run!() click to toggle source
# File lib/rails_gae.rb, line 16
def run!
  create_rails_project
  copy_files
  generate_templates
end
templates() click to toggle source
# File lib/rails_gae.rb, line 46
def templates
  templates = Dir.glob(File.join(templates_dir, '**', '*')).select{ |f| File.file?(f) }
  templates.map do |template_path|
    relative_path = template_path.sub(templates_dir, '')
    File.join(destination_folder, relative_path)
  end
end
templates_dir() click to toggle source
# File lib/rails_gae.rb, line 42
def templates_dir
  File.join(File.dirname(__FILE__), 'generator', 'templates')
end