Permalink
Browse files

Do useful things to add a Gemfile if one does not exist

  • Loading branch information...
1 parent 048d16a commit 51a83f020e3afe41af0d5d841ec8535ba97cd008 @wycats committed Aug 3, 2010
Showing with 53 additions and 1 deletion.
  1. +53 −1 rails_upgrade.rb
View
@@ -1,9 +1,61 @@
$:.push File.expand_path("..", __FILE__)
require "rubygems"
+
+gemfile = File.expand_path("../../Gemfile", caller[0].split(":")[0])
+
+gemfile_contents = <<GEMFILE
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.0.rc'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3-ruby'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug'
+
+# Bundle the extra gems:
+# gem 'bj'
+# gem 'nokogiri'
+# gem 'sqlite3-ruby', :require => 'sqlite3'
+# gem 'aws-s3', :require => 'aws/s3'
+
+# Bundle gems for the local environment. Make sure to
+# put test-only gems in this group so their generators
+# and rake tasks are available in development mode:
+# group :development, :test do
+# gem 'webrat'
+# end
+GEMFILE
+
+def require_bundler
+ require "bundler/setup"
+rescue LoadError
+ puts "Please install bundler with `gem install bundler --pre` and then try again"
+ exit
+end
+
+
+if File.exist?(gemfile)
+ require_bundler
+else
+ puts "The default Rails Gemfile has been added to your application."
+ File.open(gemfile, "w") { |file| file.puts gemfile_contents }
+end
+
+require_bundler
+
require "rails/all"
require "active_support/all"
-require "rails_upgrade/application"
require "rails_upgrade/action_controller"
require "rails_upgrade/active_record"
require "rails_upgrade/action_view"

0 comments on commit 51a83f0

Please sign in to comment.