Sha256: 364ba90baee7fed5f2dbf049100195856f80d6ef86a1d8a6f0639c911e575698
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
module Marvin class Loader cattr_accessor :setup_block cattr_accessor :start_hooks, :stop_hooks self.stop_hooks, self.start_hooks = [], [] def self.before_connecting(&blk) self.setup_block = blk end def setup_defaults Marvin::Logger.setup end def self.before_run(&blk) self.start_hooks << blk unless blk.blank? end def self.after_stop(&blk) self.stop_hooks << blk unless blk.blank? end def load_handlers handlers = Dir[Marvin::Settings.root / "handlers/**/*.rb"].map { |h| h[0..-4] } handlers.each do |handler| require handler end end def load_settings Marvin::Settings.setup Marvin::Settings.default_client.configuration = Marvin::Settings.to_hash Marvin::Settings.default_client.setup end def pre_connect_setup Marvin::DataStore.load! require(Marvin::Settings.root / "config/setup") self.setup_block.call unless self.setup_block.blank? end def run! self.setup_defaults self.load_settings self.load_handlers self.pre_connect_setup self.start_hooks.each { |h| h.call } Marvin::Settings.default_client.run end def stop! Marvin::Settings.default_client.stop self.stop_hooks.each { |h| h.call } Marvin::DataStore.dump! end def self.run! self.new.run! end def self.stop! self.new.stop! end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
Sutto-marvin-0.1.0.20081016 | lib/marvin/loader.rb |
Sutto-marvin-0.1.20081115 | lib/marvin/loader.rb |
jeffrafter-marvin-0.1.20081115 | lib/marvin/loader.rb |