Skip to content

Commit

Permalink
dev: much simpler management of multiple gemfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Nov 21, 2011
1 parent 130c94f commit 5687b8d
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 234 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Expand Up @@ -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
71 changes: 71 additions & 0 deletions 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
52 changes: 25 additions & 27 deletions README_DEV.md
Expand Up @@ -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.
11 changes: 0 additions & 11 deletions 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
Expand Down
51 changes: 7 additions & 44 deletions 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
2 changes: 0 additions & 2 deletions gemfiles/.bundle/config

This file was deleted.

64 changes: 0 additions & 64 deletions gemfiles/base.rb

This file was deleted.

6 changes: 0 additions & 6 deletions gemfiles/rails-3-0-stable

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3-1-stable

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.0

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.1

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.10

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.2

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.3

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.4

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.5

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.6

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.7

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.8

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.0.9

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.1.0

This file was deleted.

5 changes: 0 additions & 5 deletions gemfiles/rails-3.1.1

This file was deleted.

6 changes: 0 additions & 6 deletions gemfiles/rails-master

This file was deleted.

0 comments on commit 5687b8d

Please sign in to comment.