Skip to content

Instantly share code, notes, and snippets.

@aitor
Forked from salicio/test_tog.sh
Created August 27, 2008 16:11
Show Gist options
  • Save aitor/7520 to your computer and use it in GitHub Desktop.
Save aitor/7520 to your computer and use it in GitHub Desktop.
.DS_Store
myapp/
#!/usr/bin/env ruby
require 'rubygems'
$COLORED_ENABLED = false
begin
require 'colored'
$COLORED_ENABLED = true
rescue LoadError
end
def log(text)
puts text unless text.empty?
text
end
def colored(text, color=:green )
$COLORED_ENABLED ? text.send(color) : text
end
def run (command)
log colored("[RUNNING] #{command}")
log `#{command}`
end
def rm (file)
log colored("[DELETING] #{file}", :yellow)
FileUtils.rm_rf(file)
end
def with_migration_tpl_file(tpl_file)
File.open(tpl_file, 'w') {|file|
file.write <<-eos
class CreateComments < ActiveRecord::Migration
def self.up
create_table "comments", :force => true do |t|
t.column "title", :string, :limit => 50, :default => ""
t.column "comment", :text, :default => ""
t.column "created_at", :datetime, :null => false
t.column "commentable_id", :integer, :default => 0, :null => false
t.column "commentable_type", :string, :limit => 15, :default => "", :null => false
t.column "user_id", :integer, :default => 0, :null => false
end
add_index "comments", ["user_id"], :name => "fk_comments_user"
end
def self.down
drop_table :comments
end
end
eos
}
yield tpl_file
rm tpl_file
end
app = ARGV.first || "myapp"
rm app
run "rails -q #{app}"
rm File.join(app , "public", "index.html")
Dir.chdir app do
run "script/plugin install git://github.com/thoughtbot/shoulda.git"
run "script/plugin install http://juixe.com/svn/acts_as_commentable"
migration_name = run 'script/generate migration create_comments | grep "create db/migrate/" | sed -e "s/[ ]*create[ ]*//"'
with_migration_tpl_file("tmp_tpl.rb") do |file|
run "cat #{file} > #{migration_name}"
end
run "script/plugin install git://github.com/linkingpaths/acts_as_scribe.git"
run 'script/generate acts_as_scribe_migration'
run "script/plugin install git://github.com/linkingpaths/acts_as_abusable.git"
run 'script/generate acts_as_abusable_migration'
run "script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids"
run "script/generate acts_as_taggable_migration"
run "script/plugin install http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk"
run "script/plugin install http://svn.redshiftmedia.com/svn/plugins/seo_urls"
run "script/plugin install http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk"
run "togify ."
run "rake db:migrate"
run "rake tog:plugins:copy_resources"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment