Skip to content

Instantly share code, notes, and snippets.

@dsisnero
Forked from barinek/app_builder.rb
Created October 6, 2010 20:21
Show Gist options
  • Save dsisnero/614006 to your computer and use it in GitHub Desktop.
Save dsisnero/614006 to your computer and use it in GitHub Desktop.
class AppBuilder < Rails::AppBuilder
#include Thor::Actions
#include Thor::Shell
@@versions = %w( 1.4.2 1.4.1 1.4.0 1.3.2 1.3.1 1.3.0 1.2.6 )
def test
append_test_gems
rspec
cucumber
# jasmine
end
def rspec
say("Installing rspec from generator", :yellow)
generate('rspec:install')
create_file 'spec/lib/example_spec.rb', <<-DOC
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
describe "example_spec" do
pending
end
DOC
create_file 'spec/support/example.rb'
end
def cucumber
say("Installing cucumber from generator", :yellow)
generate('cucumber:install')
end
def jasmine
say("Installing jasmine from generator", :yellow)
#system('rails generate jasmine:install')
end
def rvm_gemset
say("Installing rvm gemset from templates", :yellow)
create_file ".rvmrc", "rvm 1.8.7-p174@#{app_name}"
end
def ey_cloud_recipes
say("Installing ey_cloud_recipes from github.com", :yellow)
# system('git clone http://github.com/engineyard/ey-cloud-recipes.git /tmp/ey-cloud-recipes')
# directory "/tmp/ey-cloud-recipes/cookbooks", "cookbooks"
end
def cruise
say("Installing cruise from from github.com", :yellow)
# system('git clone http://github.com/thoughtworks/cruisecontrol.rb.git /tmp/cruisecontrol')
#copy_file "/tmp/cruisecontrol/config/cruise_config.rb.example", "cruise_config.rb"
#copy_file "/tmp/cruisecontrol/tasks/cc_build.rake", 'lib/tasks/cruise.rake'
end
def newrelic
say("Installing newrelic from github.com", :yellow)
#system('git clone http://github.com/smtlaissezfaire/newrelic_rpm.git /tmp/newrelic_rpm')
#copy_file "/tmp/newrelic_rpm/newrelic.yml", 'config/newrelic_rpm.yml'
end
def hoptoad
say("Installing hoptoad", :yellow)
end
def append_test_gems
append_file 'Gemfile', <<-DOC
group :test do
gem "rspec-rails", '2.0.0.beta.22'
gem "rspec", '2.0.0.beta.22'
gem 'capybara', '0.3.9'
gem 'database_cleaner', '0.5.2'
gem 'cucumber-rails', '0.3.2'
gem 'cucumber', '0.9.0'
gem 'rspec-rails', '2.0.0.beta.22'
gem 'spork', '0.8.4'
gem 'launchy', '0.3.7'
#gem 'jasmine', :submodules => true
end
DOC
end
def javascripts
super
add_jquery if options[:skip_prototype]
end
def append_jquery_gem
@generator.append_file 'Gemfile', <<-DOC
gem 'jquery-rails'
DOC
end
# def add_jquery
# say("Install jquery-rails")
# # append_jquery_gem
# say("Installing rspec from jquery:install generator")
# system('rails generate jquery:install')
# end
def add_jquery
download_jquery
download_ujs_driver
end
def download_jquery
# Downloading latest jQuery
if @@versions.include?(options.version)
puts "Fetching JQuery version #{options.version}!"
get "http://ajax.googleapis.com/ajax/libs/jquery/#{options.version}/jquery.min.js", "public/javascripts/jquery.min.js"
get "http://ajax.googleapis.com/ajax/libs/jquery/#{options.version}/jquery.js", "public/javascripts/jquery.js"
else
puts "JQuery #{options.version} is invalid; fetching #{@@versions[1]} instead."
get "http://ajax.googleapis.com/ajax/libs/jquery/#{@@versions[1]}/jquery.min.js", "public/javascripts/jquery.min.js"
get "http://ajax.googleapis.com/ajax/libs/jquery/#{@@versions[1]}/jquery.js", "public/javascripts/jquery.js"
end
# Downloading latest jQueryUI minified
get "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js", "public/javascripts/jquery-ui.min.js" #if options.ui?
get "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.js", "public/javascripts/jquery-ui.js" #if options.ui?
end
def download_ujs_driver
# Downloading latest jQuery drivers
get "http://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
end
def leftovers
#rvm_gemset
# ey_cloud_recipes unless @options[:skip_ey_cloud_recipes]
# cruise unless @options[:skip_cruise]
# newrelic unless @options[:skip_newrelic]
# hoptoad unless @options[:skip_hoptoad]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment