Class: F2IConfig
- Inherits:
-
Object
- Object
- F2IConfig
- Defined in:
- lib/feed2imap/config.rb
Overview
Feed2imap configuration
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#default_email ⇒ Object
readonly
Returns the value of attribute default_email.
-
#dumpdir ⇒ Object
readonly
Returns the value of attribute dumpdir.
-
#feeds ⇒ Object
readonly
Returns the value of attribute feeds.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#imap_accounts ⇒ Object
readonly
Returns the value of attribute imap_accounts.
-
#include_images ⇒ Object
readonly
Returns the value of attribute include_images.
-
#max_failures ⇒ Object
readonly
Returns the value of attribute max_failures.
-
#parts ⇒ Object
readonly
Returns the value of attribute parts.
-
#reupload_if_updated ⇒ Object
readonly
Returns the value of attribute reupload_if_updated.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#updateddebug ⇒ Object
readonly
Returns the value of attribute updateddebug.
Instance Method Summary collapse
-
#initialize(io) ⇒ F2IConfig
constructor
Load the configuration from the IO stream TODO should do some sanity check on the data read.
- #to_s ⇒ Object
Constructor Details
#initialize(io) ⇒ F2IConfig
Load the configuration from the IO stream TODO should do some sanity check on the data read.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/feed2imap/config.rb', line 42 def initialize(io) @conf = YAML::safe_load(io, aliases: true) @cache = @conf['cache'] || DEFCACHE @dumpdir = @conf['dumpdir'] || nil @conf['feeds'] ||= [] @feeds = [] @max_failures = (@conf['max-failures'] || 10).to_i @updateddebug = false @updateddebug = @conf['debug-updated'] if @conf.has_key?('debug-updated') @parts = %w(text html) @parts = Array(@conf['parts']) if @conf.has_key?('parts') && !@conf['parts'].empty? @parts = Set.new(@parts) @include_images = true @include_images = @conf['include-images'] if @conf.has_key?('include-images') @parts << 'html' if @include_images && ! @parts.include?('html') @reupload_if_updated = true @reupload_if_updated = @conf['reupload-if-updated'] if @conf.has_key?('reupload-if-updated') @timeout = if @conf['timeout'] == nil then 30 else @conf['timeout'].to_i end @default_email = (@conf['default-email'] || "#{LOGNAME}@#{HOSTNAME}") ImapAccount.no_ssl_verify = (@conf.has_key?('disable-ssl-verification') and @conf['disable-ssl-verification'] == true) @hostname = HOSTNAME # FIXME: should this be configurable as well? @imap_accounts = ImapAccounts::new maildir_account = MaildirAccount::new @conf['feeds'].each do |f| f['name'] = f['name'].to_s if f['disable'].nil? uri = URI::parse(Array(f['target']).join('')) path = CGI::unescape(uri.path) if uri.scheme == 'maildir' @feeds.push(ConfigFeed::new(f, maildir_account, path, self)) else # remove leading slash from IMAP mailbox names path = path[1..-1] if path[0,1] == '/' @feeds.push(ConfigFeed::new(f, @imap_accounts.add_account(uri), path, self)) end end end end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def cache @cache end |
#default_email ⇒ Object (readonly)
Returns the value of attribute default_email.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def default_email @default_email end |
#dumpdir ⇒ Object (readonly)
Returns the value of attribute dumpdir.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def dumpdir @dumpdir end |
#feeds ⇒ Object (readonly)
Returns the value of attribute feeds.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def feeds @feeds end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def hostname @hostname end |
#imap_accounts ⇒ Object (readonly)
Returns the value of attribute imap_accounts.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def imap_accounts @imap_accounts end |
#include_images ⇒ Object (readonly)
Returns the value of attribute include_images.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def include_images @include_images end |
#max_failures ⇒ Object (readonly)
Returns the value of attribute max_failures.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def max_failures @max_failures end |
#parts ⇒ Object (readonly)
Returns the value of attribute parts.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def parts @parts end |
#reupload_if_updated ⇒ Object (readonly)
Returns the value of attribute reupload_if_updated.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def reupload_if_updated @reupload_if_updated end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def timeout @timeout end |
#updateddebug ⇒ Object (readonly)
Returns the value of attribute updateddebug.
38 39 40 |
# File 'lib/feed2imap/config.rb', line 38 def updateddebug @updateddebug end |
Instance Method Details
#to_s ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/feed2imap/config.rb', line 87 def to_s s = "Your Feed2Imap config :\n" s += "=======================\n" s += "Cache file: #{@cache}\n\n" s += "Imap accounts I'll have to connect to :\n" s += "---------------------------------------\n" @imap_accounts.each_value { |i| s += i.to_s + "\n" } s += "\nFeeds :\n" s += "-------\n" i = 1 @feeds.each do |f| s += "#{i}. #{f.name}\n" s += " URL: #{f.url}\n" s += " IMAP Account: #{f.imapaccount}\n" s += " Folder: #{f.folder}\n" if not f.wrapto s += " Not wrapped.\n" end s += "\n" i += 1 end s end |