Sha256: 63f7beb4eec2ae2cd6a5f09b174887c3aa9ed74607499aace6243f65b8613f79

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

module Ryespy
  class Config
    
    attr_accessor :log_level
    attr_accessor :listener
    attr_accessor :polling_interval
    attr_accessor :redis_url
    attr_accessor :redis_ns_ryespy
    attr_accessor :notifiers
    
    attr_accessor :imap_host
    attr_accessor :imap_port
    attr_accessor :imap_ssl
    attr_accessor :imap_username
    attr_accessor :imap_password
    attr_accessor :imap_mailboxes
    
    attr_accessor :ftp_host
    attr_accessor :ftp_passive
    attr_accessor :ftp_username
    attr_accessor :ftp_password
    attr_accessor :ftp_dirs
    
    def initialize
      @log_level        = 'INFO'
      @polling_interval = 60
      @redis_ns_ryespy  = 'ryespy:'
      @notifiers        = {
        :sidekiq => [],
      }
      
      @imap_port      = 993
      @imap_ssl       = true
      @imap_mailboxes = ['INBOX']
      
      @ftp_passive    = false
      @ftp_dirs       = ['/']
    end
    
    def to_s
      params = [
        :log_level,
        :listener,
        :polling_interval,
        :redis_url,
        :redis_ns_ryespy,
        :notifiers,
      ]
      
      params.concat case @listener
      when :imap
        [
          :imap_host,
          :imap_port,
          :imap_ssl,
          :imap_username,
          :imap_password,
        ]
      when :ftp
        [
          :ftp_host,
          :ftp_passive,
          :ftp_username,
          :ftp_dirs,
        ]
      else
        []
      end
      
      params.collect! { |s| [s, instance_variable_get("@#{s}")] }
      
      Hash[params].to_s
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ryespy-0.6.1 lib/ryespy/config.rb
ryespy-0.6.0 lib/ryespy/config.rb