Dashing.io小部件uninitilized恒定BbcNews :: Nokogiri

时间:2015-03-27 10:56:23

标签: ruby-on-rails ruby dashing

我正在尝试从https://gist.github.com/iainjmitchell/5271830获取一个小部件来工作。开始划线时我收到以下错误。

调度程序捕获异常:

uninitialized constant BbcNews::Nokogiri'
C:/dashboard/jobs/news.rb:8:in `latest_headlines'
C:/dashboard/jobs/news.rb:30:in `block in <top <required>>

我已经尝试过将'nokogori'添加到news.rb文件顶部的建议,但无法加载'nokogiri / nokogiri'

news.rb

class BbcNews
  def initialize()
    @http = Net::HTTP.new('feeds.bbci.co.uk')
  end

  def latest_headlines()
    response = @http.request(Net::HTTP::Get.new("/news/rss.xml"))
    doc = Nokogiri::XML(response.body)
    news_headlines = [];
    doc.xpath('//channel/item').each do |news_item|
      news_headline = NewsHeadlineBuilder.BuildFrom(news_item)
      news_headlines.push(news_headline)
    end
    news_headlines
  end
end

class NewsHeadlineBuilder
  def self.BuildFrom(news_item)
    {
      title: news_item.xpath('title').text, 
      description: news_item.xpath('description').text, 
    }
  end
end

@BBC_News = BbcNews.new()

SCHEDULER.every '1m', :first_in => 0 do |job|
  headlines = @BBC_News.latest_headlines
  send_event('news', { :headlines => headlines})
end

如果我在news.rb的顶部添加require'nokogiri',那么我会收到以下错误:

C:\dashboard>dashing start
C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-  3.6.4/lib/backports/std_lib.rb:9:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require_with_backports'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32/lib/nokogiri.rb:29:in `rescue in <top (required)>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32/lib/nokogiri.rb:25:in `<top (required)>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require_with_backports'
from C:/dashboard/jobs/news.rb:2:in `<top (required)>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/st d_lib.rb:9:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require_with_backports'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing/app.rb:157:in `block in require_glob'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing/app.rb:156:in `each'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing/app.rb:156:in `require_glob'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing/app.rb:167:in `<top (required)>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing.rb:3:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing.rb:3:in `<top (required)>'
from config.ru:1:in `require'
from config.ru:1:in `block in <main>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `eval'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `load'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:182:in `load_rackup_config'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:72:in `start'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/runner.rb:200:in `run_command'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/runner.rb:156:in `run!'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/bin/thin:6:in `<top (required)>'
from C:/Ruby22/bin/thin:23:in `load'
from C:/Ruby22/bin/thin:23:in `<main>'

0 个答案:

没有答案