2013-01-13 16 views
0

我想爲我的網站使用他們的API獲取一些chartbeat.com統計信息。使用Python chartbeat egg很好,但對於Ruby來說,我很難過第一階段。最終,我的目標是拉動chartbeat quickstats數組(當前用戶,每秒速率等)並將其發送給石墨,並將整個過程守護進程。我對編程方法,理論和實踐有一個體面的理解,我只是用Ruby語法很綠,並且嘗試閱讀符號,方法(私有/公共),並且似乎無法讓Ruby和我的大腦玩好。我認爲這很可能是我的問題所在。嘗試使用gem調用方法時獲取符號轉換錯誤?

從我的理解,我不必做puts或類似的東西。在c上調用quickstats方法應打印通過GEM從chartbeat API返回的任何內容。

圖表珠寶從https://github.com/ashaw/chartbeat。我的紅寶石是Ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin12]

我得到這個,當我運行我的腳本:

/opt/local/lib/ruby1.9/gems/1.9.1/gems/chartbeat-0.2.2/lib/chartbeat.rb:31:in `[]': can't convert Symbol into Integer (TypeError) 
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/chartbeat-0.2.2/lib/chartbeat.rb:31:in `block in method_missing' 
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/chartbeat-0.2.2/lib/chartbeat.rb:30:in `each' 
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/chartbeat-0.2.2/lib/chartbeat.rb:30:in `method_missing' 
from /Users/jed/Documents/workspace/chartbeat2graphite/c2b.rb:8:in `<main>' 

的代碼是:

require 'chartbeat' 
require 'graphite' 
require 'daemonize' 

c = Chartbeat.new(:apikey => "sadfklj09238402938" , :host => "lipsum.com") 

c.quickstats :path => '/' 

回答

1

我不知道,但你實際上是用寶石可恰當地不靈。看起來寶石已經兩年沒有更新了。

看着叉子,我發現qhduong/chartbeat更新它使用一個新的URI或DramaFever/chartbeat做了相同但有差異。我不知道他們是否會影響它的運行方式。

+0

伊斯梅爾,謝謝你的幫助。如你所說,這是問題所在。 – jed

相關問題