class MailReceiverBase
Attributes
env[R]
Public Class Methods
logger()
click to toggle source
# File lib/mail_receiver/mail_receiver_base.rb, line 23 def self.logger @logger ||= Syslog.open(File.basename($0), Syslog::LOG_PID, Syslog::LOG_MAIL) end
new(env_file)
click to toggle source
# File lib/mail_receiver/mail_receiver_base.rb, line 7 def initialize(env_file) unless File.exists?(env_file) fatal "Config file %s does not exist. Aborting.", env_file end @env = JSON.parse(File.read(env_file)) %w{DISCOURSE_API_KEY DISCOURSE_API_USERNAME}.each do |kw| fatal "env var %s is required", kw unless @env[kw] end if @env['DISCOURSE_MAIL_ENDPOINT'].nil? && @env['DISCOURSE_BASE_URL'].nil? fatal "DISCOURSE_MAIL_ENDPOINT and DISCOURSE_BASE_URL env var missing" end end
Public Instance Methods
fatal(*args)
click to toggle source
# File lib/mail_receiver/mail_receiver_base.rb, line 39 def fatal(*args) logger.crit(*args) raise ReceiverException.new(sprintf(*args)) end
key()
click to toggle source
# File lib/mail_receiver/mail_receiver_base.rb, line 31 def key @env['DISCOURSE_API_KEY'] end
logger()
click to toggle source
# File lib/mail_receiver/mail_receiver_base.rb, line 27 def logger MailReceiverBase.logger end
username()
click to toggle source
# File lib/mail_receiver/mail_receiver_base.rb, line 35 def username @env['DISCOURSE_API_USERNAME'] end