From 5740548a517ef1574d2f121bcdbfc90d3c1d60af Mon Sep 17 00:00:00 2001 From: Thibaud Guillaume-Gentil Date: Fri, 6 May 2011 21:51:50 +0200 Subject: [PATCH] Kept support of Rubygems < 1.8.0 (for now!) --- lib/guard.rb | 6 +++++- spec/guard_spec.rb | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/guard.rb b/lib/guard.rb index 23ffd8a..2e1f869 100644 --- a/lib/guard.rb +++ b/lib/guard.rb @@ -93,7 +93,11 @@ module Guard end def locate_guard(name) - Gem::Specification.find_by_name("guard-#{name}").full_gem_path + if Gem::Version.create(Gem::VERSION) >= Gem::Version.create('1.8.0') + Gem::Specification.find_by_name("guard-#{name}").full_gem_path + else + Gem.source_index.find_name("guard-#{name}").last.full_gem_path + end rescue UI.error "Could not find 'guard-#{name}' gem path." end diff --git a/spec/guard_spec.rb b/spec/guard_spec.rb index c776314..f635a4f 100644 --- a/spec/guard_spec.rb +++ b/spec/guard_spec.rb @@ -111,7 +111,13 @@ describe Guard do describe ".locate_guard" do it "returns the path of the guard gem" do - Guard.locate_guard('rspec').should == Gem::Specification.find_by_name("guard-rspec").full_gem_path + if Gem::Version.create(Gem::VERSION) >= Gem::Version.create('1.8.0') + gem_location = Gem::Specification.find_by_name("guard-rspec").full_gem_path + else + gem_location = Gem.source_index.find_name("guard-rspec").last.full_gem_path + end + + Guard.locate_guard('rspec').should == gem_location end end end