Skip to content

Commit

Permalink
Added: Command line "vanity list" catalogs all ongoing experiments, t…
Browse files Browse the repository at this point in the history
…heir alternatives (and fingerprints) and all metrics.
  • Loading branch information
assaf committed Dec 24, 2009
1 parent 3ba085a commit 5e5dc6e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
== 1.3.0
* Added: Vanity query parameter that you can use to choose a particular alternative, e.g. to tie an advertisement banner with content of the site.
* Added: Command line "vanity list" catalogs all ongoing experiments, their alternatives (and fingerprints) and all metrics.
* Changed: Rails integration now separates use_vanity method, filters and helpers.
* Changed: Explicit vanity_context_filter and vanity_reload_filter so you can skip them, or order filters relative to them.
* Fixed: if metric cannot be loaded (e.g. offline, no db access) show error message for that metric but don't break dashboard.
Expand Down
7 changes: 4 additions & 3 deletions bin/vanity
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ options = Struct.new(:output).new
opts = OptionParser.new("", 24, " ") do |opts|
opts.banner = "Usage: #{File.basename($0)} [options] command\n"
opts.banner << "Commands:\n"
opts.banner << " report Report on all running experiments"
opts.banner << " report Report on all running experiments/metrics"
opts.banner << " list List all experiments and metrics"

opts.separator ""
opts.separator "General options:"
Expand Down Expand Up @@ -45,8 +46,8 @@ end

ARGV.each do |cmd|
case cmd
when "report"
Vanity::Commands.report options.output
when "report"; Vanity::Commands.report options.output
when "list"; Vanity::Commands.list
else fail "No such command: #{cmd}"
end
end
1 change: 1 addition & 0 deletions lib/vanity/commands.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require "vanity/commands/report"
require "vanity/commands/list"
21 changes: 21 additions & 0 deletions lib/vanity/commands/list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Vanity
module Commands
class << self
# Lists all experiments and metrics.
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
end
end
end

0 comments on commit 5e5dc6e

Please sign in to comment.