module Vanity::Commands

Commands available when running Vanity from the command line (see bin/vanity).

Public Class Methods

list() click to toggle source

Lists all experiments and metrics.

# File lib/vanity/commands/list.rb, line 5
def list
  Vanity.playground.experiments.each do |id, experiment|
    puts "experiment :%-.20s (%-.40s)" % [id, experiment.name]
    if experiment.respond_to?(:alternatives)
      experiment.alternatives.each do |alt|
        hash = experiment.fingerprint(alt)
        puts "  %s: %-40.40s  (%s)" % [alt.name, alt.value, hash]
      end
    end
  end
  Vanity.playground.metrics.each do |id, metric|
    puts "metric :%-.20s (%-.40s)" % [id, metric.name]
  end
end
report(output = nil) click to toggle source

Generate an HTML report. Outputs to the named file, or stdout with no arguments.

# File lib/vanity/commands/report.rb, line 80
def report(output = nil)
  html = render(Vanity.template("report"),
    :experiments=>Vanity.playground.experiments,
    :experiments_persisted=>Vanity.playground.experiments_persisted?,
    :metrics=>Vanity.playground.metrics
  )
  if output
    File.open output, 'w' do |file|
      file.write html
    end
    puts "New report available in #{output}"
  else
    $stdout.write html
  end
end