我正在尝试使用他们的应用程序接口为我的网站获取一些chartbeat.com统计数据。使用Python chartbeat egg可以很好地工作,但是使用Ruby我很难通过第一阶段。最终,我的目标是拉出chartbeat quickstats数组(当前用户、每秒速率等)把它送到石墨公司,然后把整件事变成守护进程。
我对编程方法、理论和实践有很好的理解,我只是对Ruby语法非常陌生,并尝试阅读符号、方法(私有/公共),但似乎无法让Ruby对我的大脑产生好感。我认为这很可能是我的问题所在。
据我所知,我不需要做puts或类似的事情。在c上调用quickstats方法应该会打印通过GEM从chartbeat API返回的任何内容。
chartbeat gem来自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 => '/'发布于 2013-01-13 11:22:38
我不确定,但您正在使用的gem实际上可能不能正常工作。创业板似乎已经两年没有更新了。
查看一下fork,我发现了更新它以使用新URI的qhduong/chartbeat,或者执行相同操作但存在差异的DramaFever/chartbeat。我不知道它们是否会影响它的运行方式。
https://stackoverflow.com/questions/14300185
复制相似问题