ruby-on-railsrubyparsingxml-parsingfeedjira

Feedjira: Can you parse multiple URLs?


EDIT** From this post Jon mentions that he wants to move away from concurrency in 2.0, and instead a single url be passed and concurrency dealt with in the application, workers being the likely approach.

I'm trying to parse multiple URLs with FeedJira (uses farday gem), but receiving an argument error. Has anyone had success parsing more than a single URL in the past? The source for FeedJira::Feed states that it will return a single feed URL, or an array of feed URLs.

.fetch_and_parse(urls, options = {}) ⇒ Object

script

feed_urls = ["https://jobs.startupnorth.ca/jobs.rss", "https://jobs.startupnorth.ca/jobs.rss"]
feed = Feedjira::Feed.fetch_and_parse(feed_urls)

error

ArgumentError: bad argument (expected URI object or URI string)
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday/utils.rb:277:in `URI'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday/connection.rb:315:in `url_prefix='
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday/connection.rb:80:in `initialize'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday.rb:70:in `new'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday.rb:70:in `new'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/feedjira-2.1.4/lib/feedjira/feed.rb:82:in `connection'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/feedjira-2.1.4/lib/feedjira/feed.rb:68:in `fetch_and_parse'
    from (irb):144
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/console.rb:65:in `start'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/console_helper.rb:9:in `start'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:78:in `console'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands.rb:18:in `<top (required)>'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:293:in `require'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:293:in `block in require'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:293:in `require'
    from /Users/taylorcooney/code/startupjobstoronto/bin/rails:9:in `<top (required)>'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in `load'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in `block in load'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in `load'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

Solution

  • This method was changed in version 2.0.0. Make sure that you are using version < 2.