class Thyme::Console
Exposes application to the CLI in bin/thyme
Attributes
config[RW]
Public Class Methods
new()
click to toggle source
# File lib/thyme/console.rb, line 6 def initialize @config = Config.new end
Public Instance Methods
break!()
click to toggle source
# File lib/thyme/console.rb, line 10 def break! @config.break = true end
daemonize!()
click to toggle source
# File lib/thyme/console.rb, line 14 def daemonize! @config.daemon = true Process.daemon if !ENV['THYME_TEST'] end
load(optparse, &block)
click to toggle source
Loads the thymerc configuration file. Requires optparse b/c users can extend CLI via thymerc
# File lib/thyme/console.rb, line 32 def load(optparse, &block) return if block.nil? && !File.exists?(Config::CONFIG_FILE) config = @config config.optparse = optparse environment = Class.new do define_method(:set) { |opt,val| config.set(opt,val) } define_method(:use) { |plugin,*args,&b| config.use(plugin,*args,&b) } define_method(:before) { |*args,&block| config.before(*args,&block) } define_method(:after) { |*args,&block| config.after(*args,&block) } define_method(:tick) { |&block| config.tick(&block) } define_method(:option) { |sh,lo,desc,&b| config.option(sh,lo,desc,&b) } end.new if block # for test environment environment.instance_eval(&block) else environment.instance_eval(File.read(Config::CONFIG_FILE), Config::CONFIG_FILE) end end
repeat!(count = 0)
click to toggle source
# File lib/thyme/console.rb, line 19 def repeat!(count = 0) @config.repeat = count.to_i end
run()
click to toggle source
# File lib/thyme/console.rb, line 27 def run timer.run end
stop()
click to toggle source
# File lib/thyme/console.rb, line 23 def stop timer.stop end
Private Instance Methods
timer()
click to toggle source
# File lib/thyme/console.rb, line 54 def timer Timer.new(@config) end