StefanoMartin / FinnhubRB

Gem for Finnhub
MIT License
9 stars 2 forks source link

Can't import gem #1

Closed mruegenberg closed 4 years ago

mruegenberg commented 4 years ago

Hello, I wanted to try this gem and after installing, it is not found:

require 'finnhubrb'

. . .
        3: from (irb):4
        2: from (irb):5:in `rescue in irb_binding'
        1: from (irb):5:in `require'
LoadError (cannot load such file -- finnhubrb)

This is in Ruby 2.7.0.

The reason seems to be that there is no top-level file defining the module, but instead all the files are directly in lib:

ls ...finnhubrb-1.1.0/lib
Analysis.rb  Calendar.rb  Client.rb  Country.rb  Crypto.rb  Economic.rb  Error.rb  finnhub.rb  Forex.rb  Stock.rb  Tick.rb  Timeseries.rb  Transcript.rb  Websocket.rb

Whereas other modules such as hashie have a different structure:

ls ... hashie-4.1.0/lib
hashie  hashie.rb

I then tried to load the files directly, which in itself works, but doesn't find the rest of the Gem:

require 'Client'

...
       6: from (irb):5
        5: from (irb):6:in `rescue in irb_binding'
        4: from (irb):6:in `require'
        3: from [path-to-gems]/finnhubrb-1.1.0/lib/Client.rb:1:in `<top (required)>'
        2: from [path-to-gems]/finnhubrb-1.1.0/lib/Client.rb:2:in `<module:Finnhub>'
        1: from [path-to-gems]/finnhubrb-1.1.0/lib/Client.rb:3:in `<class:Client>'
NameError (uninitialized constant Finnhub::Client::Calendar)
mruegenberg commented 4 years ago

Found the solution: It's require 'finnhub' instead of `require 'finnhubrb' as stated in the readme.

StefanoMartin commented 4 years ago

My bad. I fixed the documentation. Thank you for your feedback.