Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
Using open-uri instead of Net::HTTP.get_response to avoid end of file…
Browse files Browse the repository at this point in the history
… reached RuntimeError
  • Loading branch information
jxpx777 committed Mar 3, 2014
1 parent 1fee3b1 commit 42988eb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins_disabled/stravalogger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
- strava_units determine what units to display data in: "metric" or "imperial"
=end

require 'open-uri'
require 'json'

config = {
'description' => ['strava_access_token is an oauth access token for your account. You can obtain one at https://www.strava.com/settings/api',
Expand Down Expand Up @@ -62,15 +64,15 @@ def parse_feed(rss_feed)
tags = "\n\n#{tags}\n" unless tags == ''

begin
res = Net::HTTP.get_response(URI.parse(rss_feed))
res = URI.parse(rss_feed).read
rescue Exception => e
raise "ERROR retrieving Strava activity list url: #{rss_feed} - #{e}"
end

return false if res.nil?

begin
JSON.parse(res.body).each {|activity|
JSON.parse(res).each {|activity|
@log.info("Examining activity #{activity['id']}: #{activity['name']}")

date = Time.parse(activity['start_date_local'])
Expand Down

0 comments on commit 42988eb

Please sign in to comment.