lib/almanack/event_source/ical_feed.rb in almanack-1.0.3 vs lib/almanack/event_source/ical_feed.rb in almanack-1.0.4
- old
+ new
@@ -1,14 +1,11 @@
-require 'net/http'
-require 'uri'
-require 'ri_cal'
-
module Almanack
module EventSource
class IcalFeed
- def initialize(url)
+ def initialize(url, options = {})
@url = url
+ @options = options
end
def events_between(date_range)
occurrences_between(date_range).map do |occurrence|
event_from(occurrence)
@@ -47,15 +44,19 @@
location: occurrence.location
)
end
def entities
- RiCal.parse_string(body)
+ RiCal.parse_string(response.body)
end
- def body
- uri = URI(@url)
- Net::HTTP.get(uri)
+ def connection
+ @options[:connection]
+ end
+
+ def response
+ uri = Addressable::URI.parse(@url)
+ connection.get(uri)
end
end
end
end