From c1fe1ef9193b1923c6e2c8f438fb6440e71eb9ad Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 8 Nov 2012 13:59:14 -0800 Subject: rakefile: better language for install, added uninstall. --- Rakefile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 3ba9103..b41e16b 100644 --- a/Rakefile +++ b/Rakefile @@ -43,7 +43,7 @@ task 'build' do say "#{$spec.name} #{$spec.version} built to pkg/#{file_name}" end -desc "Build and install #{$spec.name}-#{$spec.version}.gem into either system-wide or user gems" +desc "Install #{$spec.name}-#{$spec.version}.gem into either system-wide or user gems" task 'install' do if !File.exists?($gem_path) say("Could not file #{$gem_path}. Try running 'rake build'") @@ -51,14 +51,26 @@ task 'install' do if ENV["USER"] == "root" run "gem install '#{$gem_path}'" else - say("A system-wide install requires that you run 'rake install' as root, which you are not.") - if agree("Do you want to continue installing to #{Gem.path.grep /home/}? ") + home_gem_path = Gem.path.grep(/home/).first + say("You are installing as an unprivileged user, which will result in the installation being placed in '#{home_gem_path}'.") + if agree("Do you want to continue installing to #{home_gem_path}? ") run "gem install '#{$gem_path}' --user-install" end end end end +desc "Uninstall #{$spec.name}-#{$spec.version}.gem from either system-wide or user gems" +task 'uninstall' do + if ENV["USER"] == "root" + say("Removing #{$spec.name}-#{$spec.version}.gem from system-wide gems") + run "gem uninstall '#{$spec.name}' --version #{$spec.version} --verbose -x -I" + else + say("Removing #{$spec.name}-#{$spec.version}.gem from user's gems") + run "gem uninstall '#{$spec.name}' --version #{$spec.version} --verbose --user-install -x -I" + end +end + ## ## TESTING ## -- cgit v1.2.3