Skip to content

Instantly share code, notes, and snippets.

@ne-sachirou
Created November 11, 2011 05:32
Show Gist options
  • Save ne-sachirou/1357277 to your computer and use it in GitHub Desktop.
Save ne-sachirou/1357277 to your computer and use it in GitHub Desktop.
Rakefile generate_sinatra_project
function generate_sinatra_project(){
rake -f /home/ne_Sachirou/default.rake generate_sinatra_project\[$1\]
}
#encoding = utf-8
desc 'Generate Sinatra Project'
task :generate_sinatra_project, [:tamplate_engine] do |task_obj, args|
template_engine = args.template_engine || 'erubis'
text_gitignore = <<'GITIGNORE'
.bundle
vendor/bundler
*~
*.swp
*.swo
GITIGNORE
text_configru = <<'CONFIGRU'
require './main'
run Sinatra::Application
CONFIGRU
text_gemfile = <<"GEMFILE"
source :gemcutter
gem 'sinatra'
gem '#{template_engine}'
GEMFILE
text_mainrb = <<"MAINRB"
#encoding = utf-8
require 'sinatra'
require '#{template_engine}'
helpers do
end
get '/' do
end
MAINRB
text_rakefile = <<'RAKEFILE'
#encoding = utf-8
RAKEFILE
sh 'mkdir public'
sh 'mkdir public/style'
sh 'mkdir public/script'
sh 'mkdir public/image'
sh 'mkdir views'
open('.gitignore', 'w'){|file| file.write text_gitignore}
open('Gemfile', 'w'){|file| file.write text_gemfile}
open('main.rb', 'w'){|file| file.write text_mainrb}
open('Rakefile', 'w'){|file| file.write text_rakefile}
sh 'bundle install --path vendor/bundler'
sh 'git init'
end
task :default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment