Skip to content

Instantly share code, notes, and snippets.

@aitor
Created December 18, 2008 15:08
Show Gist options
  • Save aitor/37522 to your computer and use it in GitHub Desktop.
Save aitor/37522 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'tools'
require 'tog'
require 'plugins'
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
def install_plugins
install_plugin "http://juixe.com/svn/acts_as_commentable"
run "script/generate migration create_comments"
pattern = File.join Dir.pwd, "db" , "migrate", "*create_comments.rb"
create_migration = Dir.glob(pattern).first
with_migration_tpl_file("tmp_tpl.rb") do |file|
rm create_migration
FileUtils.cp file, create_migration
end
install_plugin "git://github.com/linkingpaths/acts_as_scribe.git"
run 'script/generate acts_as_scribe_migration'
install_plugin "git://github.com/linkingpaths/acts_as_abusable.git"
run 'script/generate acts_as_abusable_migration'
install_plugin "http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids"
run "script/generate acts_as_taggable_migration"
install_plugin "http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk"
install_plugin "http://svn.redshiftmedia.com/svn/plugins/seo_urls"
install_plugin "git://github.com/thoughtbot/paperclip.git"
install_plugin "git://github.com/technoweenie/viking.git"
end
# #####
# # # #
# # #
# # #####
####### #
# #
# #######
app = ARGV.select{|a| a =~ /^\w/}.first || "sample_tog_app_v#{TOG_RELEASE_NUMBER}"
plugins = ARGV.select{|a| a =~ /--./}.collect{|e| e.gsub('--','')}
rm app
run "rails -q #{app}"
rm File.join(app , "public", "index.html")
Dir.chdir app do
install_plugins
run "togify . --development"
run "rake db:migrate"
run "rake tog:plugins:copy_resources"
install_tog_plugins(plugins)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment