vanity 2.0.0.beta2 → 2.0.0.beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/README.rdoc +2 -3
- data/gemfiles/rails32.gemfile.lock +1 -1
- data/gemfiles/rails4.gemfile.lock +1 -1
- data/lib/vanity/adapters/active_record_adapter.rb +3 -8
- data/lib/vanity/commands/report.rb +1 -1
- data/lib/vanity/templates/_metric.erb +12 -12
- data/lib/vanity/version.rb +1 -1
- data/test/commands/report_test.rb +30 -0
- metadata +5 -3
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -6,8 +6,7 @@ Vanity is an A/B testing framework for Rails that is datastore agnostic.
|
|
6
6
|
* All about Vanity: http://vanity.labnotes.org
|
7
7
|
* On Github: http://github.com/assaf/vanity
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
{<img src="https://raw.githubusercontent.com/assaf/vanity/bugfix/readme/doc/images/sidebar_test.png" alt="Dashbarod" />}[http://github.com/assaf/vanity]
|
11
10
|
|
12
11
|
== A/B Testing With Rails
|
13
12
|
|
@@ -134,7 +133,7 @@ Conversions are created via the <code>track!</code> method. For example:
|
|
134
133
|
|
135
134
|
To view metrics and experiment results with the dashboard in Rails 3 & Rails 4:
|
136
135
|
|
137
|
-
rails generate controller --helper=false
|
136
|
+
rails generate controller Vanity --helper=false
|
138
137
|
|
139
138
|
In <code>config/routes.rb</code>, add:
|
140
139
|
|
@@ -166,12 +166,7 @@ module Vanity
|
|
166
166
|
select = "sum(#{connection.quote_column_name('value')}) AS value, #{connection.quote_column_name('date')}"
|
167
167
|
group_by = "#{connection.quote_column_name('date')}"
|
168
168
|
|
169
|
-
values = record.vanity_metric_values.
|
170
|
-
:select => select,
|
171
|
-
:conditions => conditions,
|
172
|
-
:order => order,
|
173
|
-
:group => group_by
|
174
|
-
)
|
169
|
+
values = record.vanity_metric_values.select(select).where(conditions).group(group_by)
|
175
170
|
|
176
171
|
dates.map do |date|
|
177
172
|
value = values.detect{|v| v.date == date }
|
@@ -223,8 +218,8 @@ module Vanity
|
|
223
218
|
# :conversions.
|
224
219
|
def ab_counts(experiment, alternative)
|
225
220
|
record = VanityExperiment.retrieve(experiment)
|
226
|
-
participants = VanityParticipant.
|
227
|
-
converted = VanityParticipant.
|
221
|
+
participants = VanityParticipant.where(:experiment_id => experiment.to_s, :seen => alternative).count
|
222
|
+
converted = VanityParticipant.where(:experiment_id => experiment.to_s, :converted => alternative).count
|
228
223
|
conversions = record.vanity_conversions.sum(:conversions, :conditions => {:alternative => alternative})
|
229
224
|
|
230
225
|
{
|
@@ -47,7 +47,7 @@ module Vanity
|
|
47
47
|
locals = struct.new(*locals.values_at(*keys))
|
48
48
|
dir, base = File.split(path)
|
49
49
|
path = File.join(dir, partialize(base))
|
50
|
-
erb = ERB.new(File.read(path), nil, '<>')
|
50
|
+
erb = ERB.new(File.read("#{path}.erb"), nil, '<>')
|
51
51
|
erb.filename = path
|
52
52
|
erb.result(locals.instance_eval { binding })
|
53
53
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
<h3><%=vanity_h metric.name %></h3>
|
2
|
-
<%= vanity_simple_format
|
3
|
-
<%=
|
4
|
-
begin
|
5
|
-
data = Vanity::Metric.data(metric)
|
6
|
-
min, max = data.map(&:last).minmax
|
7
|
-
js = data.map { |date,value| "['#{date.to_time.httpdate}',#{value}]" }.join(",")
|
8
|
-
vanity_html_safe(%{<div class="chart"></div>
|
2
|
+
<%= vanity_simple_format(vanity_h(metric.description), :class=>"description") %>
|
3
|
+
<%= vanity_html_safe(%Q{<div class="chart"></div>
|
9
4
|
<script type="text/javascript">
|
10
|
-
$(function()
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
$(function() {
|
6
|
+
Vanity.metric("#{vanity_h(id)}")
|
7
|
+
.plot([{
|
8
|
+
label:"#{vanity_h(metric.name)}",
|
9
|
+
data: [#{Vanity::Metric.data(metric).map { |date,value| "['#{date.to_time.httpdate}',#{value}]" }.join(",")}]
|
10
|
+
}])
|
11
|
+
})
|
12
|
+
</script>}
|
13
|
+
)
|
14
|
+
%>
|
data/lib/vanity/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "vanity/commands/report"
|
3
|
+
|
4
|
+
describe Vanity::Commands do
|
5
|
+
before do
|
6
|
+
metric "Coolness"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".report" do
|
10
|
+
describe "given file" do
|
11
|
+
let(:file) { "tmp/config/redis.yml" }
|
12
|
+
|
13
|
+
it "writes to that file" do
|
14
|
+
new_ab_test :foobar do
|
15
|
+
alternatives "foo", "bar"
|
16
|
+
identify { "me" }
|
17
|
+
metrics :coolness
|
18
|
+
end
|
19
|
+
experiment(:foobar).choose
|
20
|
+
|
21
|
+
FileUtils.mkpath "tmp/config"
|
22
|
+
Vanity::Commands.report(file)
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
File.unlink(File.open(file, "w"))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vanity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- test/adapters/redis_adapter_test.rb
|
136
136
|
- test/autoconnect_test.rb
|
137
137
|
- test/cli_test.rb
|
138
|
+
- test/commands/report_test.rb
|
138
139
|
- test/dummy/Rakefile
|
139
140
|
- test/dummy/app/controllers/application_controller.rb
|
140
141
|
- test/dummy/app/helpers/application_helper.rb
|
@@ -186,7 +187,7 @@ licenses:
|
|
186
187
|
post_install_message: To get started run vanity --help
|
187
188
|
rdoc_options:
|
188
189
|
- --title
|
189
|
-
- Vanity 2.0.0.
|
190
|
+
- Vanity 2.0.0.beta3
|
190
191
|
- --main
|
191
192
|
- README.rdoc
|
192
193
|
- --webcvs
|
@@ -215,6 +216,7 @@ test_files:
|
|
215
216
|
- test/adapters/redis_adapter_test.rb
|
216
217
|
- test/autoconnect_test.rb
|
217
218
|
- test/cli_test.rb
|
219
|
+
- test/commands/report_test.rb
|
218
220
|
- test/dummy/Rakefile
|
219
221
|
- test/dummy/app/controllers/application_controller.rb
|
220
222
|
- test/dummy/app/helpers/application_helper.rb
|