我想尝试一下三个类似的Ruby gem,分别是'yahoofinance‘、'yahoo-finance’和'yahoo_stock‘。我对每个gem如何与雅虎财经合作感兴趣。所以我从创建一个rvm gemset开始,
[sandbox]$ rvm gemset create finance
'finance' gemset created (/Users/milktrader/.rvm/gems/ruby-1.9.2-p0@finance).然后我使用它,
[sandbox]$ rvm gemset use finance
Now using gemset 'finance'然后我把它绑在红宝石上
[sandbox]$ rvm 1.9.2-head@finance然后我安装了上面的三个gem,
[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 installed
.
.
.
Installing RDoc documentation for yahoo_stock-1.0.2...现在我错误地假设我可以在irb会话中需要所有三个gem。其中只有一个返回true。
ruby-1.9.2-head > require 'yahoofinance'
=> true 而另外两个抛出错误。
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: ...gems或我的安装有问题吗?
注意:我对rvm gemset use命令不太了解,上面可能没有正确使用它。
[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)发布于 2010-12-22 07:30:30
我最初犯了和你一样的错误,所以这不是环境造成的。
yahoo-finance的问题是必须将其作为yahoo_finance。
yahoo_stock的问题是一个语法错误,表明文件正在加载,但没有正确解释。通过检查Github project's changelog,我们看到Ruby1.9.1的history.rb中的这个语法错误在1.0.5版本中得到了修复,但在the central gem repository中的版本是1.0.2。原来gem的所有者现在调用gem的nas-yahoo_stock,所以运行gem install nas-yahoo_stock应该可以解决这个问题。
https://stackoverflow.com/questions/4504735
复制相似问题