Виджет Dashing.io неинициализированная константа BbcNews::Nokogiri
Я пытаюсь получить виджет от 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
если я добавлю require 'nokogiri' в начало файла news.rb, я получу следующие ошибки:
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>'