class Mooset::Application
Attributes
config_filename[RW]
interactive[RW]
logfile[RW]
Public Class Methods
run(argv)
click to toggle source
# File lib/mooset/application.rb, line 51 def self.run(argv) s = self.new OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options]" opts.on("-f", "--logfile FILE", "Logfile", s.method(:logfile=)) opts.on("-v", "--verbose", "Verbose") do |x| s.logger.level = ::Logger::DEBUG end opts.on("-c", "--config FILE", "Config file", s.method(:config_filename=)) opts.on("-i", "--interactive", "Run in interactive mode", s.method(:interactive=)) opts.parse!(argv) end LSpace[:logger] = s.logger if s.config_filename s.read_config s.run! unless s.interactive end s.start_irb if s.interactive end
Public Instance Methods
configure() { |self| ... }
click to toggle source
# File lib/mooset/application.rb, line 47 def configure(&block) yield self end
define(endpoint_name, factory, opts = {})
click to toggle source
# File lib/mooset/application.rb, line 9 def define(endpoint_name, factory, opts = {}) opts[:endpoint_name] = endpoint_name endpoints[endpoint_name] = Mooset::Endpoints::Endpoint.create(factory, opts) end
endpoints()
click to toggle source
# File lib/mooset/application.rb, line 15 def endpoints @endpoints ||= {} end
instances()
click to toggle source
# File lib/mooset/application.rb, line 19 def instances @instances ||= {} end
logger()
click to toggle source
# File lib/mooset/application.rb, line 76 def logger @logger ||= ::Logger.new(logfile || STDOUT).tap do |l| l.level = ::Logger::INFO end end
operations()
click to toggle source
# File lib/mooset/application.rb, line 27 def operations @operations ||= [] end
read_config()
click to toggle source
# File lib/mooset/application.rb, line 43 def read_config instance_eval File.read(config_filename), config_filename end
run!()
click to toggle source
# File lib/mooset/application.rb, line 31 def run! operations.each do |operation| operation.call end end
start_irb()
click to toggle source
# File lib/mooset/application.rb, line 37 def start_irb $app = self IRB.start end
synchronize_group(from:, to:, **opts)
click to toggle source
# File lib/mooset/application.rb, line 23 def synchronize_group(from:, to:, **opts) operations << Mooset::SynchronizeGroup.new(endpoints[from], endpoints[to], opts) end