class Bombard::Runner

Attributes

conf[R]

Public Class Methods

new(opts) click to toggle source
# File lib/bombard/runner.rb, line 7
def initialize(opts)
  @global_opts = Config.for opts
  @conf        = @global_opts.bombard

  load_requirements
  publish
end

Public Instance Methods

build() click to toggle source
# File lib/bombard/runner.rb, line 33
def build
  puts "Building using:\n\t#{builder}"
  builder.with_opts(@conf.builder_opts)
end
builder() click to toggle source
# File lib/bombard/runner.rb, line 28
def builder
  # TODO: Need a sane default or simply fail if not specified.
  @builder ||= @conf.builder ? class_for(@conf.builder, Bombard::Builder) : Bombard::Builder::Test
end
load_requirements() click to toggle source
# File lib/bombard/runner.rb, line 38
def load_requirements
  require_all @conf.require if @conf.require
end
publish() click to toggle source
# File lib/bombard/runner.rb, line 23
def publish
  puts "Publishing using:\n\t#{publisher}"
  publisher.for(results).with_opts(@conf.publisher_opts).publish
end
publisher() click to toggle source
# File lib/bombard/runner.rb, line 19
def publisher
  @publisher ||= @conf.publisher ? class_for(@conf.publisher, Bombard::Publisher) : Bombard::Publisher::Console
end
results() click to toggle source
# File lib/bombard/runner.rb, line 15
def results
  @results ||= Siege.new(build.urls, @global_opts.siege).results
end

Private Instance Methods

class_for(child, parent = Object) click to toggle source
# File lib/bombard/runner.rb, line 44
def class_for(child, parent = Object)
  child.split('::').reduce(parent) do |mod, class_name|
    mod.const_get(class_name)
  end
rescue NameError
  abort "Can't find #{parent}::#{child}. You can load the contents of any directory using the --require switch."
end