From 1fee3b1a4272de22ac872d48ffd9f4f845a492de Mon Sep 17 00:00:00 2001 From: Jamie Phelps Date: Mon, 3 Mar 2014 15:03:12 -0600 Subject: [PATCH 1/2] Using open-uri instead of Net::HTTP to fetch the feed's contents. --- plugins_disabled/stravalogger.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins_disabled/stravalogger.rb b/plugins_disabled/stravalogger.rb index f0b6fa2..75328c3 100644 --- a/plugins_disabled/stravalogger.rb +++ b/plugins_disabled/stravalogger.rb @@ -12,7 +12,6 @@ - strava_units determine what units to display data in: "metric" or "imperial" =end -require 'rexml/document'; config = { 'description' => ['strava_access_token is an oauth access token for your account. You can obtain one at https://www.strava.com/settings/api', From 42988eb52fc184d58ca00ce512bba2535b1e9ee5 Mon Sep 17 00:00:00 2001 From: Jamie Phelps Date: Mon, 3 Mar 2014 15:31:49 -0600 Subject: [PATCH 2/2] Using open-uri instead of Net::HTTP.get_response to avoid end of file reached RuntimeError --- plugins_disabled/stravalogger.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins_disabled/stravalogger.rb b/plugins_disabled/stravalogger.rb index 75328c3..99839d3 100644 --- a/plugins_disabled/stravalogger.rb +++ b/plugins_disabled/stravalogger.rb @@ -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', @@ -62,7 +64,7 @@ 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 @@ -70,7 +72,7 @@ def parse_feed(rss_feed) 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'])