Created
October 13, 2008 08:04
-
-
Save bruce/16508 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Tuneup | |
module Bootstrap | |
module Utils | |
private | |
def build_dir | |
'tuneup-bootstrap' | |
end | |
def sudo | |
@sudo ||= RUBY_PLATFORM[/win32/] ? '' : 'sudo ' | |
end | |
def append(filename, content) | |
File.open(filename, 'a') { |f| f.puts content } | |
end | |
end | |
class Merb < Thor | |
include Utils | |
desc 'run', "Bootstrap merb app + tuneup" | |
method_options :gems => :boolean | |
def run | |
FileUtils.rm_rf build_dir rescue nil | |
if options.gems? | |
system "#{sudo}gem install merb fiveruns_tuneup_merb --no-rdoc" | |
end | |
system steps | |
end | |
private | |
def steps | |
%{ | |
merb-gen app #{build_dir}; | |
cd #{build_dir}; | |
merb-gen controller items; | |
echo ';dependency "fiveruns_tuneup_merb"' >> config/environments/development.rb; | |
echo '<li><%= num %></li>' > app/views/items/_num.html.erb | |
echo '<ul><%= partial "num", :with => (1..10).to_a %></ul>' >> app/views/items/index.html.erb | |
mv config/dependencies.rb config/dependencies.bak; | |
cat config/dependencies.bak | sed 's/dependency "merb-auth"/#dependency "merb-auth"/' > config/dependencies.rb; | |
rake slices:fiveruns_tuneup_merb:install; | |
merb -d; | |
sleep 2; | |
open -W 'http://localhost:4000/items'; | |
killall merb; | |
} | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment