1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Fix requiring of rubygems

The Rubygem documentation here http://guides.rubygems.org/name-your-gem/
suggests the naming of rubygems. If the name contains dashes (-) the
require statements should include forward slashes that replace the dashes.

For example, the 'net-ssh' rubygem should have the require statement of
```ruby
require 'net/ssh'
```

This simple fix tries to address this problem and falls back to the
original require statement if there is a `LoadError`. This will handle
cases where some gem author didn't follow the naming convention
suggested in the documentation.
This commit is contained in:
Kannan Manickam 2014-03-31 11:44:43 -07:00 committed by Ryan Fitzgerald
parent 41ecfbcba8
commit a00bb7e51c

View file

@ -21,6 +21,9 @@ class Pry
def process(gem)
Rubygem.install(gem)
output.puts "Gem `#{ text.green(gem) }` installed."
require_path = gem.split('-').join('/')
require require_path
rescue LoadError
require gem
end
end