beatrichartz / exchange

Easy Currency Operations directly available on your numbers - maintenance discontinued
http://beatrichartz.github.com/exchange
MIT License
42 stars 22 forks source link

The gem does not work if installed in a directory containing "lib" somewhere in its path #2

Closed severin closed 12 years ago

severin commented 12 years ago

When the gem is installed in a directory containing lib in its name (e.g. _/var/lib/jenkins/workspace/rightclearing_next-spec/vendor/bundlergems/ruby/1.9.1/gems/exchange-0.5.0) it does not work correctly:

No such file or directory - /var/jenkins/workspace/rightclearing_next-spec/vendor/bundler_gems/ruby/1.9.1/gems/exchange-0.5.0/lib/iso4217.yml

The problem lies in the following line:

EXCHANGE_GEM_ROOT_PATH = File.dirname(__FILE__).sub(/\/lib/, '') if __FILE__.is_a?(String)

The regexp in the sub call will replace the first occurrence of /lib in the path and not the last one. The following should do the trick:

EXCHANGE_GEM_ROOT_PATH = File.dirname(__FILE__).sub(/\/lib$/, '') if __FILE__.is_a?(String)
beatrichartz commented 12 years ago

Fixed in 0.5.1, thanks!