vanity 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -2
  3. data/Appraisals +6 -6
  4. data/CHANGELOG +9 -3
  5. data/Gemfile.lock +1 -1
  6. data/README.md +299 -0
  7. data/doc/configuring.textile +8 -1
  8. data/doc/identity.textile +2 -0
  9. data/doc/metrics.textile +10 -0
  10. data/gemfiles/rails32.gemfile.lock +1 -1
  11. data/gemfiles/rails41.gemfile.lock +1 -1
  12. data/gemfiles/rails42.gemfile.lock +1 -1
  13. data/gemfiles/{rails4.gemfile → rails42_protected_attributes.gemfile} +2 -2
  14. data/gemfiles/rails42_protected_attributes.gemfile.lock +209 -0
  15. data/lib/generators/templates/vanity_migration.rb +1 -0
  16. data/lib/vanity/adapters/abstract_adapter.rb +11 -0
  17. data/lib/vanity/adapters/active_record_adapter.rb +15 -1
  18. data/lib/vanity/adapters/mock_adapter.rb +14 -0
  19. data/lib/vanity/adapters/mongodb_adapter.rb +14 -0
  20. data/lib/vanity/adapters/redis_adapter.rb +15 -0
  21. data/lib/vanity/configuration.rb +43 -11
  22. data/lib/vanity/experiment/ab_test.rb +145 -15
  23. data/lib/vanity/experiment/alternative.rb +4 -0
  24. data/lib/vanity/frameworks/rails.rb +69 -31
  25. data/lib/vanity/locales/vanity.en.yml +9 -0
  26. data/lib/vanity/locales/vanity.pt-BR.yml +4 -0
  27. data/lib/vanity/metric/active_record.rb +9 -1
  28. data/lib/vanity/templates/_ab_test.erb +9 -2
  29. data/lib/vanity/templates/_experiment.erb +21 -1
  30. data/lib/vanity/templates/vanity.css +11 -3
  31. data/lib/vanity/templates/vanity.js +35 -6
  32. data/lib/vanity/version.rb +1 -1
  33. data/test/commands/report_test.rb +1 -0
  34. data/test/dummy/config/application.rb +1 -0
  35. data/test/experiment/ab_test.rb +414 -0
  36. data/test/experiment/base_test.rb +16 -10
  37. data/test/frameworks/rails/action_controller_test.rb +14 -6
  38. data/test/frameworks/rails/action_mailer_test.rb +8 -6
  39. data/test/frameworks/rails/action_view_test.rb +1 -0
  40. data/test/helper_test.rb +2 -0
  41. data/test/metric/active_record_test.rb +56 -0
  42. data/test/playground_test.rb +3 -0
  43. data/test/test_helper.rb +28 -2
  44. data/test/web/rails/dashboard_test.rb +2 -0
  45. data/vanity.gemspec +2 -2
  46. metadata +8 -8
  47. data/README.rdoc +0 -231
  48. data/gemfiles/rails4.gemfile.lock +0 -179
data/README.rdoc DELETED
@@ -1,231 +0,0 @@
1
- = Vanity
2
- {<img src="https://travis-ci.org/assaf/vanity.png?branch=master" alt="Build Status" />}[https://travis-ci.org/assaf/vanity]
3
-
4
- Vanity is an A/B testing framework for Rails that is datastore agnostic.
5
-
6
- * All about Vanity: http://vanity.labnotes.org
7
- * On Github: http://github.com/assaf/vanity
8
-
9
- {<img src="https://raw.githubusercontent.com/assaf/vanity/master/doc/images/sidebar_test.png" alt="Dashbarod" />}[http://github.com/assaf/vanity]
10
-
11
- == A/B Testing With Rails
12
-
13
- === <b>Step 1:</b> Start using Vanity in your Rails application
14
-
15
- ==== Step 1.1
16
-
17
- ===== Rails 3 & Rails 4 installation
18
-
19
- Add to your Gemfile:
20
-
21
- gem "vanity"
22
-
23
- (For support for older versions of Rails and Ruby 1.8, please see the {1.9.x branch}[https://github.com/assaf/vanity/tree/1-9-stable].)
24
-
25
- ==== Step 1.2
26
-
27
- Choose a datastore that best fits your needs and preferences for storing experiment results. Choose one of: Redis, MongoDB or an SQL database. While Redis is usually faster, it may add additional complexity to your stack. Datastores should be configured using a <code>config/vanity.yml</code>.
28
-
29
- ===== Redis Setup
30
-
31
- Add to your Gemfile:
32
-
33
- gem "redis", ">= 2.1"
34
- gem "redis-namespace", ">= 1.1.0"
35
-
36
- By default Vanity is configured to use Redis on localhost port 6379 with database 0.
37
-
38
- A sample <code>config/vanity.yml</code> might look like:
39
-
40
- test:
41
- collecting: false
42
- production:
43
- adapter: redis
44
- url: redis://<%= ENV["REDIS_USER"] %>:<%= ENV["REDIS_PASSWORD"] %>@<%= ENV["REDIS_HOST"] %>:<%= ENV["REDIS_PORT"] %>/0
45
-
46
- If you want to use your test environment with RSpec you will need to add an adapter to test:
47
-
48
- test:
49
- adapter: redis
50
- collecting: false
51
-
52
- ===== MongoDB Setup
53
-
54
- Add to your Gemfile:
55
-
56
- gem "bson_ext"
57
- gem "mongo"
58
-
59
- A sample <code>config/vanity.yml</code> might look like:
60
-
61
- development:
62
- adapter: mongodb
63
- database: analytics
64
- test:
65
- collecting: false
66
- production:
67
- adapter: mongodb
68
- database: analytics
69
-
70
-
71
- ===== SQL Database Setup
72
-
73
- Vanity supports multiple SQL stores (like MySQL, MariaDB, Postgres, Sqlite, etc.) using ActiveRecord, which is built into Rails. If you're using DataMapper, Sequel or another persistence framework, add to your Gemfile:
74
-
75
- gem "active_record"
76
-
77
- A sample <code>config/vanity.yml</code> might look like:
78
-
79
- development:
80
- adapter: active_record
81
- active_record_adapter: sqlite3
82
- database: db/development.sqlite3
83
- test:
84
- collecting: false
85
- production:
86
- adapter: active_record
87
- active_record_adapter: default
88
-
89
- If you're going to store data in the database, run the generator and migrations to create the database schema:
90
-
91
- $ rails generate vanity
92
- $ rake db:migrate
93
-
94
- ==== Step 1.3
95
-
96
- Turn Vanity on, and pass a reference to a method that identifies a user. For example:
97
-
98
- class ApplicationController < ActionController::Base
99
- use_vanity :current_user
100
- end
101
-
102
- For more information, please see the {identity documentation}[http://vanity.labnotes.org/identity.html].
103
-
104
- === <b>Step 2:</b> Define your first A/B test
105
-
106
- This experiment goes in the file <code>experiments/price_options.rb</code>:
107
-
108
- ab_test "Price options" do
109
- description "Mirror, mirror on the wall, who's the better price of all?"
110
- alternatives 19, 25, 29
111
- metrics :signups
112
- end
113
-
114
- If the experiment uses a metric as above ("signups"), there needs to be a corresponding ruby file for that metric, <code>experiments/metrics/signups.rb</code>.
115
-
116
- metric "Signup (Activation)" do
117
- description "Measures how many people signed up for our awesome service."
118
- end
119
-
120
- === <b>Step 3:</b> Present the different options to your users
121
-
122
- <h2>Get started for only $<%= ab_test :price_options %> a month!</h2>
123
-
124
- === <b>Step 4:</b> Measure conversion
125
-
126
- Conversions are created via the <code>Vanity.track!</code> method. For example:
127
-
128
- class SignupController < ApplicationController
129
- def signup
130
- @account = Account.new(params[:account])
131
- if @account.save
132
- Vanity.track!(:signups)
133
- redirect_to @acccount
134
- else
135
- render action: :offer
136
- end
137
- end
138
- end
139
-
140
- === <b>Step 5:</b> Check the report:
141
-
142
- vanity report --output vanity.html
143
-
144
- To view metrics and experiment results with the dashboard in Rails 3 & Rails 4:
145
-
146
- rails generate controller Vanity --helper=false
147
-
148
- In <code>config/routes.rb</code>, add:
149
-
150
- get '/vanity' =>'vanity#index'
151
- get '/vanity/participant/:id' => 'vanity#participant'
152
- post '/vanity/complete'
153
- post '/vanity/chooses'
154
- post '/vanity/reset'
155
- post '/vanity/add_participant'
156
- get '/vanity/image'
157
-
158
- The controller should look like:
159
-
160
- class VanityController < ApplicationController
161
- include Vanity::Rails::Dashboard
162
- layout false # exclude this if you want to use your application layout
163
- end
164
-
165
- == Registering participants with Javascript
166
-
167
- If robots or spiders make up a significant portion of your sites traffic they can affect your conversion rate. Vanity can optionally add participants to the experiments using asynchronous javascript callbacks, which will keep many robots out. For those robots that do execute Javascript and are well-behaved (like Googlebot), Vanity filters out requests based on their user-agent string.
168
-
169
- In Rails, add the following to <code>application.rb</code>:
170
-
171
- Vanity.configure do |config|
172
- config.use_js = true
173
-
174
- # Optionally configure the add_participant route that is added with Vanity::Rails::Dashboard,
175
- # make sure that this action does not require authentication
176
- # config.add_participant_route = '/vanity/add_participant'
177
- end
178
-
179
- Then add <code><%= vanity_js %></code> to any page that calls an A/B test <b>after calling <code>ab_test</code></b>. <code>vanity_js</code> needs to be included after your call to ab_test so that it knows which version of the experiment the participant is a member of. The helper will render nothing if the there are no ab_tests running on the current page, so adding <code>vanity_js</code> to the bottom of your layouts is a good option. Keep in mind that if you set <code>use_js</code> and don't include <code>vanity_js</code> in your view no participants will be recorded.
180
-
181
- == Compatibility
182
-
183
- Here's what's tested and known to work:
184
-
185
- Ruby 1.9.3
186
- Persistence: Redis, Mongo, ActiveRecord
187
- Rails: 3.2, 4.x
188
- Ruby 2.0
189
- Persistence: Redis, Mongo, ActiveRecord
190
- Rails: 3.2, 4.x
191
- Ruby 2.1
192
- Persistence: Redis, Mongo, ActiveRecord
193
- Rails: 3.2, 4.x
194
- Ruby 2.2
195
- Persistence: Redis, Mongo, ActiveRecord
196
- Rails: 3.2, 4.x
197
-
198
- == Testing
199
-
200
- For view tests/specs or integration testing, it's handy to set the outcome of an experiment. This may be done using the <code>chooses</code> method. For example:
201
-
202
- Vanity.playground.experiment(:price_options).chooses(19)
203
-
204
- == Updating documentation
205
-
206
- Documenation is written in the textile format in the [docs](docs/) directory, and is hosted on Github Pages. To update the docs commit changes to the master branch in this repository, then:
207
-
208
- bundle exec rake docs # output HTML files into html/
209
- git checkout gh-pages
210
- mv html/* . # Move generated html to the top of the repo
211
- git commit # Add, commit and push any changes!
212
-
213
- Go ahead and target a pull request against the `gh-pages` branch.
214
-
215
- == Contributing
216
-
217
- * Fork the project
218
- * Please use a feature branch to make your changes, it's easier to test them that way
219
- * To set up the test suite run `bundle`, then run `appraisal install` to prepare the test suite to run against multiple versions of Rails
220
- * Fix, patch, enhance, document, improve, sprinkle pixie dust
221
- * Tests. Please. Run `appraisal rake test`, of if you can, `rake test:all`. (This project uses Travis CI where the test suite is run against multiple versions of ruby, rails and backends.)
222
- * Send a pull request on GitHub
223
-
224
-
225
- == Credits/License
226
-
227
- Original code, copyright of Assaf Arkin, released under the MIT license.
228
-
229
- Documentation available under the Creative Commons Attribution license.
230
-
231
- For full list of credits and licenses: http://vanity.labnotes.org/credits.html.
@@ -1,179 +0,0 @@
1
- GIT
2
- remote: git://github.com/zoltankiss/fastthread.git
3
- revision: 56e6ce7c1780797a354d5befe9a9a9869bbc7e3e
4
- specs:
5
- fastthread (1.0.7)
6
-
7
- PATH
8
- remote: ..
9
- specs:
10
- vanity (2.0.1)
11
- i18n
12
-
13
- GEM
14
- remote: https://rubygems.org/
15
- specs:
16
- RedCloth (4.2.9)
17
- RedCloth (4.2.9-java)
18
- actionmailer (4.0.13)
19
- actionpack (= 4.0.13)
20
- mail (~> 2.5, >= 2.5.4)
21
- actionpack (4.0.13)
22
- activesupport (= 4.0.13)
23
- builder (~> 3.1.0)
24
- erubis (~> 2.7.0)
25
- rack (~> 1.5.2)
26
- rack-test (~> 0.6.2)
27
- activemodel (4.0.13)
28
- activesupport (= 4.0.13)
29
- builder (~> 3.1.0)
30
- activerecord (4.0.13)
31
- activemodel (= 4.0.13)
32
- activerecord-deprecated_finders (~> 1.0.2)
33
- activesupport (= 4.0.13)
34
- arel (~> 4.0.0)
35
- activerecord-deprecated_finders (1.0.3)
36
- activerecord-jdbc-adapter (1.3.15)
37
- activerecord (>= 2.2)
38
- activesupport (4.0.13)
39
- i18n (~> 0.6, >= 0.6.9)
40
- minitest (~> 4.2)
41
- multi_json (~> 1.3)
42
- thread_safe (~> 0.1)
43
- tzinfo (~> 0.3.37)
44
- addressable (2.3.5)
45
- albino (1.3.3)
46
- posix-spawn (>= 0.3.6)
47
- appraisal (1.0.3)
48
- bundler
49
- rake
50
- thor (>= 0.14.0)
51
- arel (4.0.2)
52
- bson (1.9.2)
53
- bson (1.9.2-java)
54
- bson_ext (1.9.2)
55
- bson (~> 1.9.2)
56
- builder (3.1.4)
57
- classifier (1.3.4)
58
- fast-stemmer (>= 1.0.0)
59
- crack (0.4.1)
60
- safe_yaml (~> 0.9.0)
61
- daemon_controller (1.1.7)
62
- directory_watcher (1.4.1)
63
- erubis (2.7.0)
64
- fakefs (0.6.7)
65
- fast-stemmer (1.0.2)
66
- garb (0.9.1)
67
- activesupport (>= 2.2.0)
68
- crack (>= 0.1.6)
69
- hike (1.2.3)
70
- i18n (0.7.0)
71
- integration (0.1.0)
72
- jdbc-sqlite3 (3.8.7)
73
- jekyll (0.11.2)
74
- albino (~> 1.3)
75
- classifier (~> 1.3)
76
- directory_watcher (~> 1.1)
77
- kramdown (~> 0.13)
78
- liquid (~> 2.3)
79
- maruku (~> 0.5)
80
- kramdown (0.13.5)
81
- liquid (2.6.2)
82
- mail (2.6.3)
83
- mime-types (>= 1.16, < 3)
84
- maruku (0.7.0)
85
- metaclass (0.0.4)
86
- mime-types (2.4.3)
87
- minitest (4.7.5)
88
- mocha (1.0.0)
89
- metaclass (~> 0.0.1)
90
- mongo (1.9.2)
91
- bson (~> 1.9.2)
92
- multi_json (1.10.1)
93
- passenger (3.0.21)
94
- daemon_controller (>= 1.0.0)
95
- fastthread (>= 1.0.1)
96
- rack
97
- rake (>= 0.8.1)
98
- posix-spawn (0.3.11)
99
- power_assert (0.2.2)
100
- rack (1.5.2)
101
- rack-test (0.6.3)
102
- rack (>= 1.0)
103
- rails (4.0.13)
104
- actionmailer (= 4.0.13)
105
- actionpack (= 4.0.13)
106
- activerecord (= 4.0.13)
107
- activesupport (= 4.0.13)
108
- bundler (>= 1.3.0, < 2.0)
109
- railties (= 4.0.13)
110
- sprockets-rails (~> 2.0)
111
- railties (4.0.13)
112
- actionpack (= 4.0.13)
113
- activesupport (= 4.0.13)
114
- rake (>= 0.8.7)
115
- thor (>= 0.18.1, < 2.0)
116
- rake (10.4.2)
117
- redis (3.0.6)
118
- redis-namespace (1.3.2)
119
- redis (~> 3.0.4)
120
- rubystats (0.2.3)
121
- safe_yaml (0.9.7)
122
- sprockets (2.12.3)
123
- hike (~> 1.2)
124
- multi_json (~> 1.0)
125
- rack (~> 1.0)
126
- tilt (~> 1.1, != 1.3.0)
127
- sprockets-rails (2.2.4)
128
- actionpack (>= 3.0)
129
- activesupport (>= 3.0)
130
- sprockets (>= 2.8, < 4.0)
131
- sqlite3 (1.3.10)
132
- test-unit (3.0.9)
133
- power_assert
134
- thor (0.19.1)
135
- thread_safe (0.3.4)
136
- thread_safe (0.3.4-java)
137
- tilt (1.4.1)
138
- timecop (0.6.3)
139
- tzinfo (0.3.43)
140
- webmock (1.15.2)
141
- addressable (>= 2.2.7)
142
- crack (>= 0.3.2)
143
- yard (0.7.5)
144
-
145
- PLATFORMS
146
- java
147
- ruby
148
-
149
- DEPENDENCIES
150
- RedCloth
151
- activerecord-jdbc-adapter
152
- appraisal (~> 1.0.2)
153
- bson_ext
154
- bundler (>= 1.0.0)
155
- fakefs
156
- fastthread!
157
- garb (< 0.9.2)
158
- integration (<= 0.1.0)
159
- jdbc-sqlite3
160
- jekyll
161
- minitest (>= 4.2)
162
- mocha (~> 1.0)
163
- mongo
164
- passenger (~> 3.0)
165
- rack
166
- rails (= 4.0.13)
167
- rake
168
- redis (>= 2.1)
169
- redis-namespace (>= 1.1.0)
170
- rubystats
171
- sqlite3 (~> 1.3.10)
172
- test-unit
173
- timecop
174
- vanity!
175
- webmock
176
- yard
177
-
178
- BUNDLED WITH
179
- 1.11.2