From cb5843aa47ab61ef5008c3fb84028ec693d52259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 2 Jun 2011 00:40:37 +0200 Subject: [PATCH] In Ruby < 1.9, Symbol#downcase doesn't exist! --- CHANGELOG.md | 4 ++++ lib/guard.rb | 6 +++--- spec/guard_spec.rb | 13 +++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6fc3f7..8ba0a26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Master +### Bugs fixes: + +- In Ruby < 1.9, Symbol#downcase doesn't exist! ([@rymai](https://github.com/rymai)) + ### New features: - Pull request [#73](https://github.com/guard/guard/pull/73): Allow DSL's `group` method to accept a Symbol as group name. ([@johnbintz](https://github.com/johnbintz)) diff --git a/lib/guard.rb b/lib/guard.rb index f65e808..0118bc3 100644 --- a/lib/guard.rb +++ b/lib/guard.rb @@ -81,14 +81,14 @@ module Guard end def get_guard_class(name) - try_to_load_gem name - self.const_get(self.constants.find{ |klass_name| klass_name.to_s.downcase == name.to_s.downcase.gsub('-', '') }) + try_to_load_gem(name) + self.const_get(self.constants.find { |klass_name| klass_name.to_s.downcase == name.to_s.downcase.gsub('-', '') }) rescue TypeError UI.error "Could not find load find gem 'guard-#{name}' or find class Guard::#{name}" end def try_to_load_gem(name) - require "guard/#{name.downcase}" + require "guard/#{name.to_s.downcase}" rescue LoadError end diff --git a/spec/guard_spec.rb b/spec/guard_spec.rb index 3e93862..3671a33 100644 --- a/spec/guard_spec.rb +++ b/spec/guard_spec.rb @@ -88,6 +88,19 @@ describe Guard do end end end + + describe ".try_to_load_gem" do + class Guard::Classname + end + + it "reports an error if the class is not found" do + Guard.get_guard_class('classname').should be_true + end + + it "reports an error if the class is not found" do + Guard.get_guard_class(:classname).should be_true + end + end describe ".locate_guard" do it "returns the path of a Guard gem" do