class Almanack::Configuration

Constants

CACHE_DIR
DEFAULT_CACHE_EXPIRY
DEFAULT_CACHE_RESPONSES
DEFAULT_DAYS_LOOKAHEAD
DEFAULT_FEED_LOOKAHEAD
DEFAULT_THEME

Attributes

cache_expiry[RW]
cache_responses[RW]
days_lookahead[RW]
event_sources[R]
feed_lookahead[RW]
theme[RW]
theme_paths[RW]
theme_root[RW]
title[RW]

Public Class Methods

new() click to toggle source
# File lib/almanack/configuration.rb, line 22
def initialize
  reset!
end

Public Instance Methods

add_event_source(source) click to toggle source
# File lib/almanack/configuration.rb, line 53
def add_event_source(source)
  @event_sources << source
end
add_events(events) click to toggle source
# File lib/almanack/configuration.rb, line 65
def add_events(events)
  add_event_source EventSource::Static.new(events)
end
add_ical(io) click to toggle source
# File lib/almanack/configuration.rb, line 61
def add_ical(io)
  add_event_source EventSource::Ical.from(io)
end
add_ical_feed(url) click to toggle source
# File lib/almanack/configuration.rb, line 57
def add_ical_feed(url)
  add_event_source EventSource::IcalFeed.new(url, connection: connection)
end
add_meetup_group(options) click to toggle source
# File lib/almanack/configuration.rb, line 69
def add_meetup_group(options)
  fail "Unfortunately, due to Meetup's changes to their API, this integration is no longer supported. See https://github.com/Aupajo/almanack/issues/36 for more information."
end
cache_store() click to toggle source
# File lib/almanack/configuration.rb, line 73
def cache_store
  @cache_store ||= ActiveSupport::Cache::FileStore.new(cache_dir, expires_in: cache_expiry)
end
connection() click to toggle source
# File lib/almanack/configuration.rb, line 26
def connection
  @connection ||= Faraday.new do |conn|
    conn.response(:caching) { cache_store } if cache_responses
    conn.adapter Faraday.default_adapter
  end
end
reset!() click to toggle source
# File lib/almanack/configuration.rb, line 33
def reset!
  @theme           = DEFAULT_THEME
  @days_lookahead  = DEFAULT_DAYS_LOOKAHEAD
  @feed_lookahead  = DEFAULT_FEED_LOOKAHEAD
  @event_sources   = []
  @cache_responses = DEFAULT_CACHE_RESPONSES
  @cache_expiry    = DEFAULT_CACHE_EXPIRY

  @theme_paths = [
    Pathname.pwd.join('themes'),
    Pathname(__dir__).join('themes')
  ]
end

Private Instance Methods

cache_dir() click to toggle source
# File lib/almanack/configuration.rb, line 79
def cache_dir
  Pathname.pwd.join(CACHE_DIR)
end