Permalink
Browse files

Cleanup the Gemfile and compute whats needed depending on whether we …

…are on 1.8 or 1.9
  • Loading branch information...
1 parent 1f4dae9 commit bd3b2241a43982f4f96015a1f841942cb8b0b973 @dhh dhh committed Apr 13, 2011
@@ -124,7 +124,7 @@ def database_gemfile_entry
entry += "\n# gem 'mysql2', :git => 'git://github.com/brianmario/mysql2.git'"
end
end
- entry
+ entry + "\n"
end
def rails_gemfile_entry
@@ -165,6 +165,25 @@ def gem_for_database
else options[:database]
end
end
+
+ def gem_for_ruby_debugger
+ if RUBY_VERSION < "1.9.2"
+ "gem 'ruby-debug'"
+ else
+ "gem 'ruby-debug19', :require => 'ruby-debug'"
+ end
+ end
+
+ def gem_for_turn
+ unless RUBY_VERSION < "1.9.2"
+ <<-GEMFILE.strip_heredoc
+ group :test do
+ # Pretty printed test output
+ gem 'turn', :require => false
+ end
+ GEMFILE
+ end
+ end
def bundle_if_dev_or_edge
bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
@@ -5,8 +5,8 @@ source 'http://rubygems.org'
<%= database_gemfile_entry -%>
# Asset template engines
-gem 'json' # Not needed on Ruby 1.9
-gem 'sass', :git => 'git://github.com/nex3/sass.git'
+<%= "gem 'json'\n" if RUBY_VERSION < "1.9.2" -%>
+gem 'sass', '~> 3.1.0.alpha'
gem 'coffee-script'
# Use unicorn as the web server
@@ -15,24 +15,7 @@ gem 'coffee-script'
# Deploy with Capistrano
# gem 'capistrano'
-# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
-# gem 'ruby-debug'
-# gem 'ruby-debug19', :require => 'ruby-debug'
+# To use debugger
+# <%= gem_for_ruby_debugger %>
-# Bundle the extra gems:
-# gem 'bj'
-# gem 'nokogiri'
-# gem 'sqlite3'
-# gem 'rack-bug', :require => 'rack/bug'
-
-# 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
- # Pretty printed test output for minitest on Ruby 1.9.2+
- gem 'turn', :require => false
-end
-
-# Needed for guides generation
-# gem "RedCloth", "~> 4.2"
+<%= gem_for_turn -%>

4 comments on commit bd3b224

Contributor

iain commented on bd3b224 Apr 13, 2011

For the ruby 1.9 related gems, why don't you use the :platform option of bundler?

Not that it matters much, because most rails apps don't need to run on both 1.8 and 1.9...

Contributor

parndt replied Apr 13, 2011

@iain Yes they do, e.g. https://github.com/resolve/refinerycms
Using :platform would be very welcome.

+1 @parndt - most apps might not need to run on both versions, but the default Gemfile shouldn't be built assuming the current Ruby will remain the same.

Owner

dhh replied Apr 14, 2011

If you're starting a new app on 1.9, we're already doing other 1.9-specific things. Like the scaffold generators create 1.9-style hashes that won't work on 1.8. I'd rather have a clean Gemfile that doesn't pretend that the app will work on 1.8 out the gate if it was started on 1.9. But of course it's still possible to make it so by manually using :platform in case you want to put in the diligence to allow your app to run under both 1.8 and 1.9.

Please sign in to comment.