Skip to content

Commit

Permalink
Dev: enhance thor tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed May 7, 2011
1 parent a7c68a3 commit d756e02
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion Thorfile
@@ -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}"
Expand All @@ -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.