Class: ImapFeederConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/imap-feeder/imapfeederconfig.rb

Class Method Summary collapse

Class Method Details

.check(configuration) ⇒ Object



29
30
31
32
33
34
# File 'lib/imap-feeder/imapfeederconfig.rb', line 29

def self.check(configuration)
  YAML.load(configuration).each do |conf_item|
    check_url_connection(conf_item['feed']['url'])
    check_path_name(conf_item['feed']['path'])
  end
end

.create(opml_file, root_folder) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/imap-feeder/imapfeederconfig.rb', line 9

def self.create(opml_file, root_folder)

  root_folder = root_folder ? "INBOX.#{root_folder}" : "INBOX"

  if opml_file
    items = process(OpmlReader.get(File.open(opml_file)), "#{root_folder}").flatten
  else
    items = [
      {"feed" => {"url" => "http://rubyforge.org/export/rss_sfnews.php",    "path" => "#{root_folder}.rubyforge"}},
      {"feed" => {"url" => "http://feeds.feedburner.com/DilbertDailyStrip", "path" => "#{root_folder}.dilbert"}}
    ]
  end

  File.open("#{Dir.pwd}/feeds.yml", "w+") do |file|
    YAML.dump(items, file)
  end

  File.copy "#{File.dirname(__FILE__)}/../../settings.rb.example", "#{Dir.pwd}/settings.rb"
end