Class: RssNotifier::Config

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/rss_notifier/config.rb

Constant Summary collapse

DEFAULTS =
{
  adapters: {
    email: {
      sendgrid_api_key: '<Get it from sendgrid.com>',
      from: 'RSS Notifier <[email protected]>',
    }
  },
  notify: [
    { email: '[email protected]', adapter: 'email', enabled: false },
    { name: 'mini me', access_token: '<Get it from pushbullet.com>', adapter: 'pushbullet', enabled: false },
  ],
  rss_urls: [
    { name: 'Some News', url: 'http://some-site.com/rss' }
  ],
  period_in_minutes: 20
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultObject



29
30
31
# File 'lib/rss_notifier/config.rb', line 29

def self.default
  RssNotifier::Config.new(DEFAULTS)
end

.load(filename) ⇒ Object



24
25
26
27
# File 'lib/rss_notifier/config.rb', line 24

def self.load(filename)
  c = YAML.load(File.read(filename))
  RssNotifier::Config.new(DEFAULTS.dup.merge(c['rss_notifier'] || c[:rss_notifier]))
end

Instance Method Details

#save_to(filename) ⇒ Object



33
34
35
36
37
# File 'lib/rss_notifier/config.rb', line 33

def save_to(filename)
  File.open(filename, 'w') do |f|
    f.write(YAML.dump({ rss_notifier: self.to_h }))
  end
end