Permalink
Browse files

To skip bundler, `rm Gemfile`. Create a Gemfile to use it again.

  • Loading branch information...
1 parent fc3a39b commit b3980af8d114b68a5e859ccea7c286f94189f713 @jeremy jeremy committed Mar 31, 2010
@@ -31,8 +31,8 @@ class AppGenerator < Base
class_option :edge, :type => :boolean, :default => false,
:desc => "Setup the application with Gemfile pointing to Rails repository"
- class_option :skip_bundler, :type => :boolean, :default => false,
- :desc => "Skip Bundler files"
+ class_option :skip_gemfile, :type => :boolean, :default => false,
+ :desc => "Don't create a Gemfile"
class_option :skip_activerecord, :type => :boolean, :aliases => "-O", :default => false,
:desc => "Skip ActiveRecord files"
@@ -74,7 +74,7 @@ def create_root_files
copy_file "gitignore", ".gitignore" unless options[:skip_git]
template "Rakefile"
template "config.ru"
- template "Gemfile" unless options[:skip_bundler]
+ template "Gemfile" unless options[:skip_gemfile]
end
def create_app_files
@@ -11,11 +11,10 @@
require "rails/test_unit/railtie"
<% end -%>
-<% unless options[:skip_bundler] -%>
-# Auto-require default libraries and those for the current Rails environment.
-Bundler.require :default, Rails.env
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
-<% end -%>
module <%= app_const_base %>
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
@@ -1,12 +1,14 @@
-<% if options[:skip_bundler] -%>
-require 'rubygems'
-<% else -%>
-# Use Bundler (preferred)
+# Use locked gems if present.
begin
require File.expand_path('../../.bundle/environment', __FILE__)
+
rescue LoadError
+ # Otherwise, use RubyGems.
require 'rubygems'
- require 'bundler'
- Bundler.setup
+
+ # And set up the gems listed in the Gemfile.
+ if File.exist?(File.expand_path('../../Gemfile'))
hasimo
hasimo Apr 1, 2010

I think File.expand_path is needed FILE args

if File.exist?(File.expand_path('../../Gemfile',__FILE__)) 
+ require 'bundler'
+ Bundler.setup
+ end
end
-<% end -%>

0 comments on commit b3980af

Please sign in to comment.