Permalink
Browse files

Dev: enhance thor tasks

  • Loading branch information...
1 parent a7c68a3 commit d756e02bc20d6b6c0ea8ea7cdafba56402405317 @dchelimsky dchelimsky committed May 7, 2011
Showing with 21 additions and 2 deletions.
  1. +1 −1 Rakefile
  2. +20 −1 Thorfile
View
@@ -16,7 +16,7 @@ rescue
sh "bundle install"
Bundler.setup
else
- raise "You need to install a bundle first. Try 'thor rails:use 3.0.7'"
+ raise "You need to install a bundle first. Try 'thor gemfile:use 3.0.7'"
end
end
Bundler::GemHelper.install_tasks
View
@@ -1,4 +1,4 @@
-class Rails < Thor
+class Gemfile < Thor
desc "use VERSION", "installs the bundle using gemfiles/rails-VERSION"
def use(version)
gemfile = "--gemfile gemfiles/rails-#{version}"
@@ -7,4 +7,23 @@ class Rails < Thor
say `ln -s gemfiles/bin` unless File.exist?('bin')
`echo rails-#{version} > ./.gemfile`
end
+
+ desc "which", "print out the configured gemfile"
+ 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
end

0 comments on commit d756e02

Please sign in to comment.