Browse files

dev: much simpler management of multiple gemfiles

  • Loading branch information...
1 parent 130c94f commit 5687b8dac6bc3a3741f95f9d7ac102e43e18c530 @dchelimsky dchelimsky committed Nov 20, 2011
View
6 .gitignore
@@ -4,12 +4,10 @@ pkg
vendor
!lib/rspec/rails/vendor
*.gem
-Gemfile
Gemfile.lock
-gemfiles/*.lock
-gemfiles/bin/*
bin
.rvmrc
*.rbc
-.gemfile
.yardoc
+.bundle
+.rails-version
View
71 Gemfile
@@ -0,0 +1,71 @@
+source "http://rubygems.org"
+
+%w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
+ library_path = File.expand_path("../../#{lib}", __FILE__)
+ if File.exist?(library_path)
+ gem lib, :path => library_path
+ elsif ENV["CI"] || ENV["USE_GIT_REPOS"]
+ gem lib, :git => "git://github.com/rspec/#{lib}.git"
+ else
+ gem lib
+ end
+end
+
+gem 'rake', '0.9.2'
+gem 'rdoc'
+gem 'sqlite3-ruby', :require => 'sqlite3'
+gem "cucumber", "1.0.0"
+gem "aruba", "0.4.2"
+gem "ZenTest", "~> 4.4.2"
+gem 'ammeter', '~> 0.1'
+
+platforms :jruby do
+ gem "jruby-openssl"
+end
+
+# gem "webrat", "0.7.3"
+# gem "capybara", "~> 0.4"
+# gem "capybara", "1.0.0.beta1"
+
+group :development do
+ gem 'gherkin', '2.4.5'
+ gem "rcov", "0.9.9"
+ gem "relish", "~> 0.5.0"
+ gem "guard-rspec", "0.1.9"
+
+ if RUBY_PLATFORM =~ /darwin/
+ gem "growl", "1.0.3"
+ gem "autotest-fsevent", "~> 0.2.4"
+ gem "autotest-growl", "~> 0.2.9"
+ end
+
+ platforms :mri_18 do
+ gem 'ruby-debug'
+ end
+
+ platforms :mri_19 do
+ if RUBY_VERSION == '1.9.2'
+ gem 'linecache19', '~> 0.5.12'
+ gem 'ruby-debug19', '~> 0.11.6'
+ gem 'ruby-debug-base19', '~> 0.11.25'
+ end
+ end
+
+ platforms :ruby_18, :ruby_19 do
+ gem "rb-fsevent", "~> 0.3.9"
+ gem "ruby-prof", "~> 0.9.2"
+ end
+end
+
+case version = File.read(".rails-version").chomp
+when /master/
+ gem "rails", :git => "git://github.com/rails/rails.git"
+ gem "journey", :git => "git://github.com/rails/journey.git"
+when /3-0-stable/
+ gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-0-stable"
+ gem "arel", :git => "git://github.com/rails/arel.git", :branch => "2-0-stable"
+when /3-1-stable/
+ gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-1-stable"
+else
+ gem "rails", version
+end
View
52 README_DEV.md
@@ -10,39 +10,37 @@ our own.
## The short version
gem install thor bundler
- thor gemfile:use 3.0.9
+ thor version:use 3.1.1
rake
## The long version
-### thor gemfile:use
+### thor version:use
The `thor gemfile:use` task accepts any released version of rails, or either the
3-0-stable or master branches.
- thor gemfile:use master
- thor gemfile:use 3-0-stable
- thor gemfile:use 3.1.0
- thor gemfile:use 3.0.9
- thor gemfile:use 3.0.8
- thor gemfile:use 3.0.7
- thor gemfile:use 3.0.6
- thor gemfile:use 3.0.5
- thor gemfile:use 3.0.4
- thor gemfile:use 3.0.3
- thor gemfile:use 3.0.2
- thor gemfile:use 3.0.1
- thor gemfile:use 3.0.0
-
-It then does several things:
-
-* generates a .gemfile file with the version listed. This is used internally by
- assorted rake tasks.
-* installs the bundle using the appropriate file in the gemfiles directory
-** this includes binstubs, which are stored in ./gemfiles/bin
-* symlinks the gemfiles/bin directory to ./bin (in the project root) to support
- running bin/rspec from the project root
-
-At any time, if you want to change rails versions, run `thor gemfile:use` with a
-new version number. To play it safe, you probably want to also run `rake
+ thor version:use master
+ thor version:use 3-0-stable
+ thor version:use 3.1.0
+ thor version:use 3.0.9
+ thor version:use 3.0.8
+ thor version:use 3.0.7
+ thor version:use 3.0.6
+ thor version:use 3.0.5
+ thor version:use 3.0.4
+ thor version:use 3.0.3
+ thor version:use 3.0.2
+ thor version:use 3.0.1
+ thor version:use 3.0.0
+
+It then does a few things:
+
+* generates a .rails-version file with the version listed. This is used
+ internally by assorted rake tasks.
+* installs the bundle
+ * this includes binstubs, which are stored in ./bin
+
+At any time, if you want to change rails versions, run `thor version:use` with
+a new version number. To play it safe, you probably want to also run `rake
clobber` to delete all the code generated by the previous rails version.
View
11 Rakefile
@@ -1,14 +1,3 @@
-require 'pathname'
-ENV["BUNDLE_GEMFILE"] ||= begin
- version = if File.exist?("./.gemfile")
- File.read("./.gemfile").chomp
- else
- "rails-3.1.0"
- end
- File.expand_path("../gemfiles/#{version}", __FILE__)
- end
-puts "Using gemfile: #{ENV["BUNDLE_GEMFILE"].gsub(Pathname.new(__FILE__).dirname.to_s,'').sub(/^\//,'')}"
-
require "bundler"
begin
Bundler.setup
View
51 Thorfile
@@ -1,53 +1,16 @@
-class Gemfile < Thor
- desc "use VERSION", "installs the bundle using gemfiles/rails-VERSION"
+class Version < Thor
+ desc "use VERSION", "installs the bundle the rails-VERSION"
def use(version)
- "rm #{lockfile(version)}".tap do |m|
+ `rm Gemfile.lock`
+ `echo #{version} > ./.rails-version`
+ "bundle install --binstubs".tap do |m|
say m
system m
end
- with(version, %w[bundle install --binstubs])
- say `ln -s gemfiles/bin` unless File.exist?('bin')
- `echo rails-#{version} > ./.gemfile`
end
- desc "with VERSION COMMAND", "executes COMMAND with the gemfile for VERSION"
- def with(version, *command)
- gemfile(version).tap do |gemfile|
- ENV["BUNDLE_GEMFILE"] = File.expand_path(gemfile)
- say "BUNDLE_GEMFILE=#{gemfile}"
- end
- command.join(' ').tap do |m|
- say m
- system m
- end
- end
-
- desc "which", "print out the configured gemfile"
+ desc "which", "print out the configured rails version"
def which
- say `cat ./.gemfile`
- end
-
- desc "list", "list the available options for 'thor gemfile:use'"
- def list
- all = `ls gemfiles`.chomp.split.grep(/^rails/).reject {|i| i =~ /lock$/}
-
- versions = all.grep(/^rails-\d\.\d/)
- branches = all - versions
-
- puts "releases:"
- versions.sort.reverse.each {|i| puts i}
- puts
- puts "branches:"
- branches.sort.reverse.each {|i| puts i}
- end
-
-private
-
- def gemfile(version)
- "gemfiles/rails-#{version}"
- end
-
- def lockfile(version)
- gemfile(version) + ".lock"
+ say `cat ./.rails-version`
end
end
View
2 gemfiles/.bundle/config
@@ -1,2 +0,0 @@
----
-BUNDLE_BIN: bin
View
64 gemfiles/base.rb
@@ -1,64 +0,0 @@
-module GemfileBase
- def self.extended(host)
- host.instance_eval do
- source "http://rubygems.org"
-
- %w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
- library_path = File.expand_path("../../../#{lib}", __FILE__)
- if File.exist?(library_path)
- gem lib, :path => library_path
- elsif ENV["CI"] || ENV["USE_GIT_REPOS"]
- gem lib, :git => "git://github.com/rspec/#{lib}.git"
- else
- gem lib
- end
- end
-
- gem 'rake', '0.9.2'
- gem 'rdoc'
- gem 'sqlite3-ruby', :require => 'sqlite3'
- gem "cucumber", "1.0.0"
- gem "aruba", "0.4.2"
- gem "ZenTest", "~> 4.4.2"
- gem 'ammeter', '~> 0.1'
-
- platforms :jruby do
- gem "jruby-openssl"
- end
-
- # gem "webrat", "0.7.3"
- # gem "capybara", "~> 0.4"
- # gem "capybara", "1.0.0.beta1"
-
- group :development do
- gem 'gherkin', '2.4.5'
- gem "rcov", "0.9.9"
- gem "relish", "~> 0.5.0"
- gem "guard-rspec", "0.1.9"
-
- if RUBY_PLATFORM =~ /darwin/
- gem "growl", "1.0.3"
- gem "autotest-fsevent", "~> 0.2.4"
- gem "autotest-growl", "~> 0.2.9"
- end
-
- platforms :mri_18 do
- gem 'ruby-debug'
- end
-
- platforms :mri_19 do
- if RUBY_VERSION == '1.9.2'
- gem 'linecache19', '~> 0.5.12'
- gem 'ruby-debug19', '~> 0.11.6'
- gem 'ruby-debug-base19', '~> 0.11.25'
- end
- end
-
- platforms :ruby_18, :ruby_19 do
- gem "rb-fsevent", "~> 0.3.9"
- gem "ruby-prof", "~> 0.9.2"
- end
- end
- end
- end
-end
View
6 gemfiles/rails-3-0-stable
@@ -1,6 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-0-stable"
-gem "arel", :git => "git://github.com/rails/arel.git", :branch => "2-0-stable"
View
5 gemfiles/rails-3-1-stable
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-1-stable"
View
5 gemfiles/rails-3.0.0
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.0"
View
5 gemfiles/rails-3.0.1
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.1"
View
5 gemfiles/rails-3.0.10
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.10"
View
5 gemfiles/rails-3.0.2
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.2"
View
5 gemfiles/rails-3.0.3
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.3"
View
5 gemfiles/rails-3.0.4
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.4"
View
5 gemfiles/rails-3.0.5
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.5"
View
5 gemfiles/rails-3.0.6
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.6"
View
5 gemfiles/rails-3.0.7
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.7"
View
5 gemfiles/rails-3.0.8
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.8"
View
5 gemfiles/rails-3.0.9
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.0.9"
View
5 gemfiles/rails-3.1.0
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.1.0"
View
5 gemfiles/rails-3.1.1
@@ -1,5 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", "3.1.1"
View
6 gemfiles/rails-master
@@ -1,6 +0,0 @@
-require File.expand_path("../base.rb", __FILE__)
-
-extend GemfileBase
-
-gem "rails", :git => "git://github.com/rails/rails.git"
-gem "journey", :git => "git://github.com/rails/journey.git"

0 comments on commit 5687b8d

Please sign in to comment.