Sha256: 1910aff8b368d412799042c886ff63c2231050d39153f12a6c734a6cdad7ecd9
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
module Almanack 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, :feed_lookahead def initialize reset! end def connection @connection ||= Faraday.new 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') ] end def theme_root 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) add_event_source EventSource::IcalFeed.new(url, connection: connection) end def add_events(events) add_event_source EventSource::Static.new(events) end def add_meetup_group(options) add_event_source EventSource::MeetupGroup.new(options.merge(connection: connection)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
almanack-1.1.0.beta1 | lib/almanack/configuration.rb |