lib/calendarium-romanum/remote/calendar.rb in calendarium-romanum-remote-0.1.0 vs lib/calendarium-romanum/remote/calendar.rb in calendarium-romanum-remote-0.2.0
- old
+ new
@@ -6,22 +6,20 @@
# from a remote calendar API
# https://github.com/igneus/church-calendar-api
class Calendar
extend Forwardable
- def initialize(year, calendar_uri, api_version: :v0, driver: :net_http)
+ def initialize(year, calendar_uri, driver: nil)
@year = year
@calendar_uri = calendar_uri
+
@driver =
- if driver.is_a? Symbol
- # built-in driver specified by a Symbol
- Drivers.get(api_version, driver)
- else
- # driver instance
- driver
- end
- @deserializer = V0::Deserializer.new
+ driver ||
+ Driver.new(
+ V0::UriScheme.new(calendar_uri),
+ V0::Denormalizer.new
+ )
# only for most fundamental computations made locally
@temporale = Temporale.new(year)
# only for API compatibility
@sanctorale = nil
@@ -45,12 +43,11 @@
else
date = CalendariumRomanum::Calendar.mk_date *args
#range_check date
end
- serialized = @driver.get date, @calendar_uri
- @deserializer.call serialized
+ @driver.day date
end
def lectionary
year_spec['lectionary'].to_sym
end
@@ -66,10 +63,10 @@
end
private
def year_spec
- @year_spec ||= JSON.parse(@driver.year(@year, @calendar_uri))
+ @year_spec ||= @driver.year(@year)
end
end
end
end