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 format("experiment :%-.20s (%-.40s)", id, experiment.name) next unless experiment.respond_to?(:alternatives) experiment.alternatives.each do |alt| hash = experiment.fingerprint(alt) puts format(" %s: %-40.40s (%s)", alt.name, alt.value, hash) end end Vanity.playground.metrics.each do |id, metric| puts format("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.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/vanity/commands/report.rb', line 81 def report(output = nil) html = render(Vanity.template("_report.erb"), experiments: Vanity.playground.experiments, experiments_persisted: Vanity.playground.experiments_persisted?, metrics: Vanity.playground.metrics) if output File.write(output, html) puts "New report available in #{output}" else $stdout.write html end end |