开发者

How do I use RVM to create a gemset of three gems?

I want to play around with three similar Ruby gems called 'yahoofinance' 'yahoo-finance' and 'yahoo_stock'. I'm interested in how each gem works with Yahoo Finance. So I start with creating an rvm gemset,

[sandbox]$ rvm gemset create finance
'finance' gemset created (/Users/milktrader/.rvm/gems/ruby-1.9.2-p0@finance).

Then I use it,

[sandbox]$ rvm gemset use finance
Now using gemset 'finance'

Then I attached it to a ruby,

[sandbox]$ rvm 1.9.2-head@finance

Then I installed the three gems above,

[sandbox]$ gem install yahoo-finance yahoofinance yahoo_stock
Successfully installed yahoo-finance-0.0.2
Successfully installed yahoofinance-1.2.2
Successfully installed yahoo_stock-1.0.2
3 gems开发者_C百科 installed
.
.
.
Installing RDoc documentation for yahoo_stock-1.0.2...

Now I'm incorrectly assuming I can require all three gems in an irb sesssion. Only one of them returns true.

ruby-1.9.2-head > require 'yahoofinance'
=> true 

While the other two throw errors.

ruby-1.9.2-head > require 'yahoo-finance'
LoadError: no such file to load -- yahoo-finance

ruby-1.9.2-head > require 'yahoo_stock'  
SyntaxError: ...

Is there a problem with the gems or my installation?

NOTE: I am foggy about the rvm gemset use command, and it's probably not being used correctly above.

[sandbox]$ gem list

*** LOCAL GEMS ***

bundler (1.0.7)
rake (0.8.7)
yahoo-finance (0.0.2)
yahoo_stock (1.0.2) 
yahoofinance (1.2.2)


I initially hit the same errors you did, so it's not environment.

The issue with yahoo-finance is that it must be required as yahoo_finance.

The issue with yahoo_stock is a syntax error, indicating that the file is being loaded, but not interpreted correctly. Upon inspecting the Github project's changelog, we see that this syntax error in history.rb for Ruby 1.9.1 was fixed in version 1.0.5, but the version in the central gem repository is 1.0.2. Turns out that the gem's owner now calls the gem nas-yahoo_stock, so running gem install nas-yahoo_stock should resolve that issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜