class Outliers::Run
Attributes
account[RW]
results[RW]
thread_count[RW]
threaded[RW]
threads[RW]
Public Class Methods
new(options={})
click to toggle source
# File lib/outliers/run.rb, line 5 def initialize(options={}) @results = [] @threads = [] @threaded = false @thread_count = 1 Thread.abort_on_exception = true end
Public Instance Methods
evaluate(name=nil, &block)
click to toggle source
# File lib/outliers/run.rb, line 24 def evaluate(name=nil, &block) while Thread.list.count > thread_count logger.info "Maximum concurrent threads running, sleeping." sleep 2 end evaluation = Proc.new { Evaluation.new(:name => name, :run => self).instance_eval &block } if name logger.info "Loading evaluation '#{name}'." else logger.info "Loading unnamed evaluation." end threaded ? threads << Thread.new { evaluation.call } : evaluation.call end
process_evaluations_in_dir()
click to toggle source
# File lib/outliers/run.rb, line 13 def process_evaluations_in_dir files.each do |file| next if File.directory? file next if File.extname(file) != '.rb' logger.info "Processing '#{file}'." self.instance_eval File.read(file) end threads.each {|t| t.join} end
Private Instance Methods
files()
click to toggle source
# File lib/outliers/run.rb, line 43 def files evaluations_path = File.join Outliers.config_path files = Dir.glob File.join(evaluations_path, '**', '*') end
logger()
click to toggle source
# File lib/outliers/run.rb, line 48 def logger @logger ||= Outliers.logger end