class Rounders::Rounder
Constants
- DEFAULT_ENV
- DEFAULT_INTERVAL
Attributes
options[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/rounders/rounder.rb, line 8 def initialize(options = {}) @options = options end
Public Instance Methods
start()
click to toggle source
# File lib/rounders/rounder.rb, line 12 def start setup polling end
store()
click to toggle source
# File lib/rounders/rounder.rb, line 17 def store @store ||= Rounders.stores[Rounders::Application.config.store].new end
Private Instance Methods
bundle()
click to toggle source
# File lib/rounders/rounder.rb, line 23 def bundle ::Bundler.require(:default, env) rescue ::Bundler::GemfileNotFound => e Rounders.logger.error e exit end
daemon()
click to toggle source
# File lib/rounders/rounder.rb, line 30 def daemon Process.daemon(true, false) if options[:daemon] end
dotenv()
click to toggle source
# File lib/rounders/rounder.rb, line 34 def dotenv Dotenv.load if options[:dotenv] end
env()
click to toggle source
# File lib/rounders/rounder.rb, line 38 def env ENV['ROUNDERS_ENV'] || DEFAULT_ENV end
handle(mails)
click to toggle source
# File lib/rounders/rounder.rb, line 42 def handle(mails) Rounders.handlers.map { |handler| handler.dispatch(self, mails) } end
interval()
click to toggle source
# File lib/rounders/rounder.rb, line 86 def interval DEFAULT_INTERVAL end
load_config()
click to toggle source
# File lib/rounders/rounder.rb, line 46 def load_config Rounders::Application.config.load_path.each do |path| Pathname.glob(File.join(Dir.pwd, path)).each do |config| require_relative config end end end
pid()
click to toggle source
# File lib/rounders/rounder.rb, line 61 def pid path = options[:pid] return if path.nil? File.open(path, 'w') { |f| f.write(Process.pid) } at_exit { File.unlink(path) } end
polling()
click to toggle source
# File lib/rounders/rounder.rb, line 54 def polling loop do round sleep interval end end
receive_mail()
click to toggle source
# File lib/rounders/rounder.rb, line 72 def receive_mail Rounders::Receivers::Receiver.receive end
round()
click to toggle source
# File lib/rounders/rounder.rb, line 68 def round handle receive_mail end
setup()
click to toggle source
# File lib/rounders/rounder.rb, line 76 def setup Topping.build daemon dotenv pid bundle load_config Rounders::Plugins::PluginLoader.load_plugins end