Module: Vanity::Commands
- Extended by:
- Render
- Defined in:
- lib/vanity/commands/report.rb,
lib/vanity/commands/list.rb
Overview
Commands available when running Vanity from the command line (see bin/vanity).
Class Method Summary collapse
-
.list ⇒ Object
Lists all experiments and metrics.
-
.report(output = nil) ⇒ Object
Generate an HTML report.
Methods included from Render
method_missing, render, vanity_h, vanity_html_safe, vanity_simple_format
Class Method Details
.list ⇒ Object
Lists all experiments and metrics.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 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) ⇒ Object
Generate an HTML report. Outputs to the named file, or stdout with no arguments.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# 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 |