lib/almanack/configuration.rb in almanack-1.0.5 vs lib/almanack/configuration.rb in almanack-1.1.0.beta1
- old
+ new
@@ -2,13 +2,19 @@
class Configuration
class ThemeNotFound < StandardError; end
DEFAULT_THEME = "legacy"
DEFAULT_DAYS_LOOKAHEAD = 30
+ DEFAULT_FEED_LOOKAHEAD = 365
attr_reader :event_sources
- attr_accessor :title, :theme, :theme_paths, :theme_root, :days_lookahead
+ attr_accessor :title,
+ :theme,
+ :theme_paths,
+ :theme_root,
+ :days_lookahead,
+ :feed_lookahead
def initialize
reset!
end
@@ -17,10 +23,11 @@
end
def reset!
@theme = DEFAULT_THEME
@days_lookahead = DEFAULT_DAYS_LOOKAHEAD
+ @feed_lookahead = DEFAULT_FEED_LOOKAHEAD
@event_sources = []
@theme_paths = [
Pathname.pwd.join('themes'),
Pathname(__dir__).join('themes')
@@ -31,18 +38,22 @@
paths = theme_paths.map { |path| path.join(theme) }
root = paths.find { |path| path.exist? }
root || raise(ThemeNotFound, "Could not find theme #{theme} in #{paths}")
end
+ def add_event_source(source)
+ @event_sources << source
+ end
+
def add_ical_feed(url)
- @event_sources << EventSource::IcalFeed.new(url, connection: connection)
+ add_event_source EventSource::IcalFeed.new(url, connection: connection)
end
def add_events(events)
- @event_sources << EventSource::Static.new(events)
+ add_event_source EventSource::Static.new(events)
end
def add_meetup_group(options)
- @event_sources << EventSource::MeetupGroup.new(options.merge(connection: connection))
+ add_event_source EventSource::MeetupGroup.new(options.merge(connection: connection))
end
end
end