vanity 2.0.0.beta2 → 2.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vanity (2.0.0.beta2)
4
+ vanity (2.0.0.beta3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- http://farm3.static.flickr.com/2540/4099665871_497f274f68_o.jpg
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 Vanity
136
+ rails generate controller Vanity --helper=false
138
137
 
139
138
  In <code>config/routes.rb</code>, add:
140
139
 
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: ..
9
9
  specs:
10
- vanity (2.0.0.beta2)
10
+ vanity (2.0.0.beta3)
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: ..
9
9
  specs:
10
- vanity (2.0.0.beta2)
10
+ vanity (2.0.0.beta3)
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
@@ -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.all(
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.count(:conditions => {:experiment_id => experiment.to_s, :seen => alternative})
227
- converted = VanityParticipant.count(:conditions => {:experiment_id => experiment.to_s, :converted => alternative})
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 vanity_h(Vanity::Metric.description(metric).to_s), :class=>"description" %>
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(){Vanity.metric("#{vanity_h id.to_s}").plot([{label:"#{vanity_h metric.name}", data: [#{js}]}])})
11
- </script>})
12
- rescue Exception=>ex
13
- %{<div class="error">#{vanity_h ex.message}</div>}
14
- end %>
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
+ %>
@@ -1,5 +1,5 @@
1
1
  module Vanity
2
- VERSION = "2.0.0.beta2"
2
+ VERSION = "2.0.0.beta3"
3
3
 
4
4
  module Version
5
5
  version = VERSION.to_s.split(".").map { |i| i.to_i }
@@ -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.beta2
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-07-10 00:00:00.000000000 Z
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.beta2
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