vanity 1.8.4 → 1.9.0.beta

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.
Files changed (53) hide show
  1. data/.travis.yml +3 -2
  2. data/CHANGELOG +12 -0
  3. data/Gemfile +6 -3
  4. data/Gemfile.lock +12 -10
  5. data/README.rdoc +45 -16
  6. data/Rakefile +14 -9
  7. data/doc/_layouts/page.html +4 -6
  8. data/doc/ab_testing.textile +1 -1
  9. data/doc/configuring.textile +2 -4
  10. data/doc/email.textile +1 -3
  11. data/doc/index.textile +3 -63
  12. data/doc/rails.textile +34 -8
  13. data/gemfiles/rails3.gemfile +12 -3
  14. data/gemfiles/rails3.gemfile.lock +37 -11
  15. data/gemfiles/rails31.gemfile +12 -3
  16. data/gemfiles/rails31.gemfile.lock +37 -11
  17. data/gemfiles/rails32.gemfile +12 -3
  18. data/gemfiles/rails32.gemfile.lock +37 -11
  19. data/gemfiles/rails4.gemfile +12 -3
  20. data/gemfiles/rails4.gemfile.lock +37 -11
  21. data/lib/vanity/adapters/abstract_adapter.rb +4 -0
  22. data/lib/vanity/adapters/active_record_adapter.rb +18 -10
  23. data/lib/vanity/adapters/mock_adapter.rb +8 -4
  24. data/lib/vanity/adapters/mongodb_adapter.rb +11 -7
  25. data/lib/vanity/adapters/redis_adapter.rb +88 -37
  26. data/lib/vanity/commands/report.rb +9 -9
  27. data/lib/vanity/experiment/ab_test.rb +120 -101
  28. data/lib/vanity/experiment/alternative.rb +21 -21
  29. data/lib/vanity/experiment/base.rb +5 -5
  30. data/lib/vanity/experiment/bayesian_bandit_score.rb +51 -51
  31. data/lib/vanity/experiment/definition.rb +10 -10
  32. data/lib/vanity/frameworks/rails.rb +39 -36
  33. data/lib/vanity/helpers.rb +6 -4
  34. data/lib/vanity/metric/active_record.rb +1 -1
  35. data/lib/vanity/metric/base.rb +23 -24
  36. data/lib/vanity/metric/google_analytics.rb +5 -5
  37. data/lib/vanity/playground.rb +118 -24
  38. data/lib/vanity/templates/_report.erb +20 -6
  39. data/lib/vanity/templates/vanity.css +2 -0
  40. data/lib/vanity/version.rb +1 -1
  41. data/test/adapters/redis_adapter_test.rb +106 -1
  42. data/test/dummy/config/database.yml +21 -4
  43. data/test/dummy/config/routes.rb +1 -1
  44. data/test/experiment/ab_test.rb +93 -13
  45. data/test/metric/active_record_test.rb +9 -4
  46. data/test/passenger_test.rb +43 -42
  47. data/test/playground_test.rb +50 -1
  48. data/test/rails_dashboard_test.rb +38 -1
  49. data/test/rails_helper_test.rb +5 -0
  50. data/test/rails_test.rb +66 -15
  51. data/test/test_helper.rb +24 -2
  52. data/vanity.gemspec +0 -2
  53. metadata +45 -57
data/doc/rails.textile CHANGED
@@ -4,30 +4,52 @@ title: Using with Rails
4
4
  ---
5
5
 
6
6
  <div id="toc">
7
+ # "Installing Vanity":#install
7
8
  # "Configuring Vanity":#config
8
9
  # "Test Environment":#test
9
10
  # "Dashboard":#dashboard
10
11
  # "Unicorn and Forking Servers":#fork
11
12
  </div>
12
13
 
13
- This guide is written for Rails 2.3.5. If you have any tips for Rails 3.0, please share.
14
+ h3(#install). Installing Vanity
14
15
 
16
+ <em>Rails 3.x and 4.x:</em>
15
17
 
16
- h3(#config). Configuring Vanity
18
+ Add Vanity to your Gemfile:
17
19
 
18
- Start by telling Rails to use the Vanity gem, either using @config.gem "vanity"@ or by adding @gem "vanity"@ to your Gemfile.
20
+ <pre>
21
+ gem "vanity"
22
+ </pre>
19
23
 
20
- You will most likely need to @require "vanity"@ from within @after_initialize@ in order to use it everywhere in your app:
24
+ <em>Rails 2.x:</em>
21
25
 
22
26
  <pre>
23
27
  Rails::Initializer.run do |config|
24
- . . .
28
+ gem.config "vanity"
29
+
25
30
  config.after_initialize do
26
31
  require "vanity"
27
32
  end
28
33
  end
29
34
  </pre>
30
35
 
36
+ h3(#config). Configuring Vanity
37
+
38
+ h4. Configuring identity
39
+
40
+ Once the gem is setup, enable Vanity in your ActionController:
41
+
42
+ <pre>
43
+ class ApplicationController < ActionController::Base
44
+ use_vanity :current_user
45
+ end
46
+ </pre>
47
+
48
+ This example assumes you have a @current_user@ controller method which will return a consistent value for each user.
49
+ There are other ways to identify people as well, you can read more about the options in Managing Identity.
50
+
51
+ h4. Configuring datastore
52
+
31
53
  If you have a @config/vanity.yml@ file, Vanity will read the configuration for the current environment. For example:
32
54
 
33
55
  <pre>
@@ -40,7 +62,9 @@ production:
40
62
  database: vanity
41
63
  </pre>
42
64
 
43
- If you want to use Google Analytics, you must also tell Rails to include the @garb@ gem, and login for a new session. You'll want to do that for production, not for development if you like developing offline:
65
+ h4. Using metrics from Google Analytics
66
+
67
+ If you want to use Vanity with metrics from Google Analytics, you must also tell Rails to include the @garb@ gem, and login for a new session. You'll want to do that for production, not for development if you like developing offline:
44
68
 
45
69
  <pre>
46
70
  config.after_initialize do
@@ -49,7 +73,9 @@ config.after_initialize do
49
73
  end
50
74
  </pre>
51
75
 
52
- There's generally no need to collect metric and experiment data outside production environment. Under Rails, Vanity turns collection on only if the environment name is "production". You can control this from @config/environments@ by setting @Vanity.playground.collecting@ to true/false. When collection is off, Vanity doesn't connect to the database server, so there's no need to set a database configuration for these environments.
76
+ h4. Enabling/disable collection
77
+
78
+ When collection is off, Vanity doesn't connect to the database server, so there's no need to set a database configuration for these environments.
53
79
 
54
80
 
55
81
  h3(#dashboard). Dashboard
@@ -64,7 +90,7 @@ Create a new controller for Vanity:
64
90
 
65
91
  <pre>
66
92
  class VanityController < ApplicationController
67
- include Vanity::Rails::Dashboard
93
+ include Vanity::Rails::Dashboard
68
94
  end
69
95
  </pre>
70
96
 
@@ -3,16 +3,17 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rack"
6
+ gem "redis", ">= 2.1"
7
+ gem "redis-namespace", ">= 1.1.0"
6
8
  gem "bson_ext"
7
9
  gem "mongo"
8
10
  gem "mysql"
9
- gem "pg"
11
+ gem "sqlite3"
10
12
  gem "backports", :platforms=>:mri_18
11
13
  gem "integration"
12
14
  gem "rubystats"
13
15
  gem "garb"
14
16
  gem "SystemTimer", "1.2.3", :platforms=>:mri_18
15
- gem "appraisal"
16
17
  gem "mocha", :require=>false
17
18
  gem "shoulda", :require=>false
18
19
  gem "timecop", :require=>false
@@ -21,4 +22,12 @@ gem "rails", "3.0.11"
21
22
  gem "fastthread", :git=>"git://github.com/zoltankiss/fastthread.git", :platforms=>:mri_20
22
23
  gem "passenger", "~>3.0"
23
24
 
24
- gemspec :path=>"../"
25
+ group :development do
26
+ gem "appraisal", ">= 1.0.0.beta2"
27
+ gem "jekyll"
28
+ gem "rake"
29
+ gem "RedCloth"
30
+ gem "yard"
31
+ end
32
+
33
+ gemspec :path=>".././"
@@ -5,15 +5,14 @@ GIT
5
5
  fastthread (1.0.7)
6
6
 
7
7
  PATH
8
- remote: /Users/phill/Development/ruby/vanity
8
+ remote: ..
9
9
  specs:
10
- vanity (1.8.4)
11
- redis (>= 2.1)
12
- redis-namespace (>= 1.1.0)
10
+ vanity (1.8.3)
13
11
 
14
12
  GEM
15
13
  remote: https://rubygems.org/
16
14
  specs:
15
+ RedCloth (4.2.9)
17
16
  SystemTimer (1.2.3)
18
17
  abstract (1.0.0)
19
18
  actionmailer (3.0.11)
@@ -43,30 +42,48 @@ GEM
43
42
  activesupport (= 3.0.11)
44
43
  activesupport (3.0.11)
45
44
  addressable (2.2.7)
46
- appraisal (0.4.1)
45
+ albino (1.3.3)
46
+ posix-spawn (>= 0.3.6)
47
+ appraisal (1.0.0.beta2)
47
48
  bundler
48
49
  rake
50
+ thor (>= 0.14.0)
49
51
  arel (2.0.10)
50
52
  backports (3.3.5)
51
53
  bson (1.6.0)
52
54
  bson_ext (1.6.0)
53
55
  bson (= 1.6.0)
54
56
  builder (2.1.2)
57
+ classifier (1.3.3)
58
+ fast-stemmer (>= 1.0.0)
55
59
  crack (0.3.1)
56
60
  daemon_controller (1.0.0)
61
+ directory_watcher (1.4.1)
57
62
  erubis (2.6.6)
58
63
  abstract (>= 1.0.0)
64
+ fast-stemmer (1.0.0)
59
65
  garb (0.9.1)
60
66
  activesupport (>= 2.2.0)
61
67
  crack (>= 0.1.6)
62
68
  i18n (0.5.0)
63
69
  integration (0.1.0)
70
+ jekyll (0.11.2)
71
+ albino (~> 1.3)
72
+ classifier (~> 1.3)
73
+ directory_watcher (~> 1.1)
74
+ kramdown (~> 0.13)
75
+ liquid (~> 2.3)
76
+ maruku (~> 0.5)
64
77
  json (1.6.5)
78
+ kramdown (0.13.5)
79
+ liquid (2.3.0)
65
80
  mail (2.2.19)
66
81
  activesupport (>= 2.3.6)
67
82
  i18n (>= 0.4.0)
68
83
  mime-types (~> 1.16)
69
84
  treetop (~> 1.4.8)
85
+ maruku (0.6.0)
86
+ syntax (>= 1.0.0)
70
87
  metaclass (0.0.1)
71
88
  mime-types (1.17.2)
72
89
  mocha (0.10.5)
@@ -79,8 +96,8 @@ GEM
79
96
  fastthread (>= 1.0.1)
80
97
  rack
81
98
  rake (>= 0.8.1)
82
- pg (0.13.2)
83
99
  polyglot (0.3.3)
100
+ posix-spawn (0.3.6)
84
101
  rack (1.2.5)
85
102
  rack-mount (0.6.14)
86
103
  rack (>= 1.0.0)
@@ -103,15 +120,17 @@ GEM
103
120
  rake (0.9.2.2)
104
121
  rdoc (3.12)
105
122
  json (~> 1.4)
106
- redis (3.2.0)
107
- redis-namespace (1.5.1)
108
- redis (~> 3.0, >= 3.0.4)
123
+ redis (3.0.6)
124
+ redis-namespace (1.3.2)
125
+ redis (~> 3.0.4)
109
126
  rubystats (0.2.3)
110
127
  shoulda (3.0.1)
111
128
  shoulda-context (~> 1.0.0)
112
129
  shoulda-matchers (~> 1.0.0)
113
130
  shoulda-context (1.0.0)
114
131
  shoulda-matchers (1.0.0)
132
+ sqlite3 (1.3.8)
133
+ syntax (1.0.0)
115
134
  thor (0.14.6)
116
135
  timecop (0.3.5)
117
136
  treetop (1.4.10)
@@ -121,27 +140,34 @@ GEM
121
140
  webmock (1.8.0)
122
141
  addressable (>= 2.2.7)
123
142
  crack (>= 0.1.7)
143
+ yard (0.7.5)
124
144
 
125
145
  PLATFORMS
126
146
  ruby
127
147
 
128
148
  DEPENDENCIES
149
+ RedCloth
129
150
  SystemTimer (= 1.2.3)
130
- appraisal
151
+ appraisal (>= 1.0.0.beta2)
131
152
  backports
132
153
  bson_ext
133
154
  fastthread!
134
155
  garb
135
156
  integration
157
+ jekyll
136
158
  mocha
137
159
  mongo
138
160
  mysql
139
161
  passenger (~> 3.0)
140
- pg
141
162
  rack
142
163
  rails (= 3.0.11)
164
+ rake
165
+ redis (>= 2.1)
166
+ redis-namespace (>= 1.1.0)
143
167
  rubystats
144
168
  shoulda
169
+ sqlite3
145
170
  timecop
146
171
  vanity!
147
172
  webmock
173
+ yard
@@ -3,16 +3,17 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rack"
6
+ gem "redis", ">= 2.1"
7
+ gem "redis-namespace", ">= 1.1.0"
6
8
  gem "bson_ext"
7
9
  gem "mongo"
8
10
  gem "mysql"
9
- gem "pg"
11
+ gem "sqlite3"
10
12
  gem "backports", :platforms=>:mri_18
11
13
  gem "integration"
12
14
  gem "rubystats"
13
15
  gem "garb"
14
16
  gem "SystemTimer", "1.2.3", :platforms=>:mri_18
15
- gem "appraisal"
16
17
  gem "mocha", :require=>false
17
18
  gem "shoulda", :require=>false
18
19
  gem "timecop", :require=>false
@@ -21,4 +22,12 @@ gem "rails", "3.1.3"
21
22
  gem "fastthread", :git=>"git://github.com/zoltankiss/fastthread.git", :platforms=>:mri_20
22
23
  gem "passenger", "~>3.0"
23
24
 
24
- gemspec :path=>"../"
25
+ group :development do
26
+ gem "appraisal", ">= 1.0.0.beta2"
27
+ gem "jekyll"
28
+ gem "rake"
29
+ gem "RedCloth"
30
+ gem "yard"
31
+ end
32
+
33
+ gemspec :path=>".././"
@@ -5,15 +5,14 @@ GIT
5
5
  fastthread (1.0.7)
6
6
 
7
7
  PATH
8
- remote: /Users/phill/Development/ruby/vanity
8
+ remote: ..
9
9
  specs:
10
- vanity (1.8.4)
11
- redis (>= 2.1)
12
- redis-namespace (>= 1.1.0)
10
+ vanity (1.8.3)
13
11
 
14
12
  GEM
15
13
  remote: https://rubygems.org/
16
14
  specs:
15
+ RedCloth (4.2.9)
17
16
  SystemTimer (1.2.3)
18
17
  actionmailer (3.1.3)
19
18
  actionpack (= 3.1.3)
@@ -44,28 +43,46 @@ GEM
44
43
  activesupport (3.1.3)
45
44
  multi_json (~> 1.0)
46
45
  addressable (2.2.7)
47
- appraisal (0.4.1)
46
+ albino (1.3.3)
47
+ posix-spawn (>= 0.3.6)
48
+ appraisal (1.0.0.beta2)
48
49
  bundler
49
50
  rake
51
+ thor (>= 0.14.0)
50
52
  arel (2.2.3)
51
53
  backports (3.3.5)
52
54
  bson (1.6.0)
53
55
  bson_ext (1.6.0)
54
56
  bson (= 1.6.0)
55
57
  builder (3.0.0)
58
+ classifier (1.3.3)
59
+ fast-stemmer (>= 1.0.0)
56
60
  crack (0.3.1)
57
61
  daemon_controller (1.0.0)
62
+ directory_watcher (1.4.1)
58
63
  erubis (2.7.0)
64
+ fast-stemmer (1.0.0)
59
65
  garb (0.9.1)
60
66
  activesupport (>= 2.2.0)
61
67
  crack (>= 0.1.6)
62
68
  i18n (0.6.0)
63
69
  integration (0.1.0)
70
+ jekyll (0.11.2)
71
+ albino (~> 1.3)
72
+ classifier (~> 1.3)
73
+ directory_watcher (~> 1.1)
74
+ kramdown (~> 0.13)
75
+ liquid (~> 2.3)
76
+ maruku (~> 0.5)
64
77
  json (1.6.5)
78
+ kramdown (0.13.5)
79
+ liquid (2.3.0)
65
80
  mail (2.3.0)
66
81
  i18n (>= 0.4.0)
67
82
  mime-types (~> 1.16)
68
83
  treetop (~> 1.4.8)
84
+ maruku (0.6.0)
85
+ syntax (>= 1.0.0)
69
86
  metaclass (0.0.1)
70
87
  mime-types (1.17.2)
71
88
  mocha (0.10.5)
@@ -79,8 +96,8 @@ GEM
79
96
  fastthread (>= 1.0.1)
80
97
  rack
81
98
  rake (>= 0.8.1)
82
- pg (0.13.2)
83
99
  polyglot (0.3.3)
100
+ posix-spawn (0.3.6)
84
101
  rack (1.3.6)
85
102
  rack-cache (1.1)
86
103
  rack (>= 0.4)
@@ -108,9 +125,9 @@ GEM
108
125
  rake (0.9.2.2)
109
126
  rdoc (3.12)
110
127
  json (~> 1.4)
111
- redis (3.2.0)
112
- redis-namespace (1.5.1)
113
- redis (~> 3.0, >= 3.0.4)
128
+ redis (3.0.6)
129
+ redis-namespace (1.3.2)
130
+ redis (~> 3.0.4)
114
131
  rubystats (0.2.3)
115
132
  shoulda (3.0.1)
116
133
  shoulda-context (~> 1.0.0)
@@ -120,6 +137,8 @@ GEM
120
137
  sprockets (2.0.3)
121
138
  rack (~> 1.0)
122
139
  tilt (~> 1.1, != 1.3.0)
140
+ sqlite3 (1.3.8)
141
+ syntax (1.0.0)
123
142
  thor (0.14.6)
124
143
  tilt (1.3.3)
125
144
  timecop (0.3.5)
@@ -130,27 +149,34 @@ GEM
130
149
  webmock (1.8.0)
131
150
  addressable (>= 2.2.7)
132
151
  crack (>= 0.1.7)
152
+ yard (0.7.5)
133
153
 
134
154
  PLATFORMS
135
155
  ruby
136
156
 
137
157
  DEPENDENCIES
158
+ RedCloth
138
159
  SystemTimer (= 1.2.3)
139
- appraisal
160
+ appraisal (>= 1.0.0.beta2)
140
161
  backports
141
162
  bson_ext
142
163
  fastthread!
143
164
  garb
144
165
  integration
166
+ jekyll
145
167
  mocha
146
168
  mongo
147
169
  mysql
148
170
  passenger (~> 3.0)
149
- pg
150
171
  rack
151
172
  rails (= 3.1.3)
173
+ rake
174
+ redis (>= 2.1)
175
+ redis-namespace (>= 1.1.0)
152
176
  rubystats
153
177
  shoulda
178
+ sqlite3
154
179
  timecop
155
180
  vanity!
156
181
  webmock
182
+ yard
@@ -3,16 +3,17 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rack"
6
+ gem "redis", ">= 2.1"
7
+ gem "redis-namespace", ">= 1.1.0"
6
8
  gem "bson_ext"
7
9
  gem "mongo"
8
10
  gem "mysql"
9
- gem "pg"
11
+ gem "sqlite3"
10
12
  gem "backports", :platforms=>:mri_18
11
13
  gem "integration"
12
14
  gem "rubystats"
13
15
  gem "garb"
14
16
  gem "SystemTimer", "1.2.3", :platforms=>:mri_18
15
- gem "appraisal"
16
17
  gem "mocha", :require=>false
17
18
  gem "shoulda", :require=>false
18
19
  gem "timecop", :require=>false
@@ -21,4 +22,12 @@ gem "rails", "3.2.1"
21
22
  gem "fastthread", :git=>"git://github.com/zoltankiss/fastthread.git", :platforms=>:mri_20
22
23
  gem "passenger", "~>3.0"
23
24
 
24
- gemspec :path=>"../"
25
+ group :development do
26
+ gem "appraisal", ">= 1.0.0.beta2"
27
+ gem "jekyll"
28
+ gem "rake"
29
+ gem "RedCloth"
30
+ gem "yard"
31
+ end
32
+
33
+ gemspec :path=>".././"