Permalink
Browse files

dev: make the rails version setup more generic

  • Loading branch information...
1 parent 66fb819 commit 15edeb4f5c4392e1bb440fb1681168c5a028ab6c @dchelimsky dchelimsky committed Feb 18, 2011
Showing with 11 additions and 30 deletions.
  1. +0 −3 Gemfile-3.0.0
  2. +0 −3 Gemfile-3.0.3
  3. +1 −4 Rakefile
  4. +10 −20 Thorfile
View
3 Gemfile-3.0.0
@@ -1,3 +0,0 @@
-instance_eval(File.read("./Gemfile-base"))
-
-gem "rails", "3.0.0"
View
3 Gemfile-3.0.3
@@ -1,3 +0,0 @@
-instance_eval(File.read("./Gemfile-base"))
-
-gem "rails", "3.0.3"
View
5 Rakefile
@@ -3,10 +3,7 @@ unless File.exist?('./Gemfile')
Could not find a Gemfile. Please run any of:
thor rails:use 3-0-stable
thor rails:use master
- thor rails:use 3.0.0
- thor rails:use 3.0.3
-
-And then run 'bundle install'
+ thor rails:use VERSION (where VERSION is any released version)
MESSAGE
end
require "bundler"
View
30 Thorfile
@@ -1,25 +1,15 @@
class Rails < Thor
- desc "checkout VERSION", "checks it out"
- def checkout(version)
- puts "***** checking out rails at #{version} ..."
- Dir.chdir("vendor/rails") do
- `git checkout #{version}`
- `rm Gemfile.lock` if File.exist?('Gemfile.lock')
- puts `bundle show`
- end
- end
-
- desc "fetch", "update vendor/rails"
- def fetch
- Dir.chdir("vendor/rails") do
- `git fetch`
- end
- end
-
- desc "use VERSION", "copies the appropriate Gemfile to Gemfile"
+ desc "use VERSION", "configures the Gemfile and runs 'bundle install'"
def use(version)
- `cp ./Gemfile-#{version} ./Gemfile`
- `rm ./Gemfile.lock`
+ `rm Gemfile.lock` if File.exist?('./Gemfile.lock')
+ `rm Gemfile` if File.exist?('./Gemfile')
+ case version
+ when /^\d\.\d/
+ `echo 'instance_eval(File.read("./Gemfile-base"))' >> Gemfile`
+ `echo 'gem "rails", "#{version}"' >> Gemfile`
+ else
+ `cp Gemfile-#{version} Gemfile`
+ end
system "bundle install"
end
end

0 comments on commit 15edeb4

Please sign in to comment.