vanity 1.9.3 → 2.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/.travis.yml +2 -53
- data/Appraisals +3 -12
- data/CHANGELOG +1 -5
- data/Gemfile +0 -10
- data/Gemfile.lock +3 -38
- data/README.rdoc +2 -13
- data/Rakefile +7 -13
- data/bin/vanity +0 -1
- data/doc/rails.textile +0 -12
- data/gemfiles/rails32.gemfile +2 -4
- data/gemfiles/rails32.gemfile.lock +6 -14
- data/gemfiles/rails4.gemfile +1 -4
- data/gemfiles/rails4.gemfile.lock +5 -15
- data/lib/vanity/adapters/active_record_adapter.rb +14 -10
- data/lib/vanity/experiment/ab_test.rb +1 -1
- data/lib/vanity/frameworks/rails.rb +11 -17
- data/lib/vanity/frameworks.rb +3 -10
- data/lib/vanity/metric/active_record.rb +20 -19
- data/lib/vanity/playground.rb +1 -3
- data/lib/vanity/version.rb +1 -1
- data/test/adapters/redis_adapter_test.rb +26 -27
- data/test/autoconnect_test.rb +19 -17
- data/test/cli_test.rb +19 -26
- data/test/experiment/ab_test.rb +2 -15
- data/test/experiment/base_test.rb +18 -22
- data/test/frameworks/rails/action_controller_test.rb +184 -0
- data/test/frameworks/rails/action_mailer_test.rb +65 -0
- data/test/{rails_helper_test.rb → frameworks/rails/action_view_test.rb} +1 -1
- data/test/frameworks/rails/rails_test.rb +285 -0
- data/test/helper_test.rb +13 -10
- data/test/metric/active_record_test.rb +50 -66
- data/test/metric/base_test.rb +39 -41
- data/test/metric/google_analytics_test.rb +13 -16
- data/test/metric/remote_test.rb +18 -19
- data/test/playground_test.rb +1 -1
- data/test/test_helper.rb +25 -43
- data/test/{rails_dashboard_test.rb → web/rails/dashboard_test.rb} +2 -1
- data/vanity.gemspec +3 -2
- metadata +33 -33
- data/gemfiles/rails3.gemfile +0 -32
- data/gemfiles/rails3.gemfile.lock +0 -172
- data/gemfiles/rails31.gemfile +0 -32
- data/gemfiles/rails31.gemfile.lock +0 -181
- data/generators/templates/vanity_migration.rb +0 -54
- data/generators/vanity_generator.rb +0 -8
- data/test/myapp/app/controllers/application_controller.rb +0 -2
- data/test/myapp/app/controllers/main_controller.rb +0 -7
- data/test/myapp/config/boot.rb +0 -110
- data/test/myapp/config/environment.rb +0 -10
- data/test/myapp/config/environments/production.rb +0 -0
- data/test/myapp/config/routes.rb +0 -3
- data/test/passenger_test.rb +0 -52
- data/test/rails_test.rb +0 -554
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -5,71 +5,20 @@ services:
|
|
5
5
|
- mongodb
|
6
6
|
- redis-server
|
7
7
|
rvm:
|
8
|
-
- 1.8.7
|
9
8
|
- 1.9.3
|
10
9
|
- 2.0.0
|
10
|
+
- 2.1.0
|
11
|
+
- ruby-head
|
11
12
|
env:
|
12
13
|
- DB=mongodb
|
13
14
|
- DB=redis
|
14
15
|
- DB=active_record
|
15
16
|
gemfile:
|
16
|
-
- Gemfile
|
17
|
-
- gemfiles/rails3.gemfile
|
18
|
-
- gemfiles/rails31.gemfile
|
19
17
|
- gemfiles/rails32.gemfile
|
20
18
|
- gemfiles/rails4.gemfile
|
21
19
|
before_script:
|
22
20
|
- 'echo ''gem: --no-ri --no-rdoc'' > ~/.gemrc' # skip installing docs for gems
|
23
|
-
- if [[ "`basename $BUNDLE_GEMFILE`" == "Gemfile" ]]; then rvm rubygems 1.8.25; fi # Rubygems 2.0.x fails with Rails 2.3
|
24
21
|
matrix:
|
25
22
|
exclude:
|
26
|
-
# Rails 2 is not officially supported on Ruby 1.9.3
|
27
|
-
- rvm: 1.9.3
|
28
|
-
env: DB=mongodb
|
29
|
-
gemfile: Gemfile
|
30
|
-
- rvm: 1.9.3
|
31
|
-
env: DB=redis
|
32
|
-
gemfile: Gemfile
|
33
|
-
- rvm: 1.9.3
|
34
|
-
env: DB=active_record
|
35
|
-
gemfile: Gemfile
|
36
|
-
# Rails <= 3.2 is not officially supported on Ruby 2.0.0
|
37
|
-
- rvm: 2.0.0
|
38
|
-
env: DB=mongodb
|
39
|
-
gemfile: Gemfile
|
40
|
-
- rvm: 2.0.0
|
41
|
-
env: DB=redis
|
42
|
-
gemfile: Gemfile
|
43
|
-
- rvm: 2.0.0
|
44
|
-
env: DB=active_record
|
45
|
-
gemfile: Gemfile
|
46
|
-
- rvm: 2.0.0
|
47
|
-
env: DB=mongodb
|
48
|
-
gemfile: gemfiles/rails3.gemfile
|
49
|
-
- rvm: 2.0.0
|
50
|
-
env: DB=redis
|
51
|
-
gemfile: gemfiles/rails3.gemfile
|
52
|
-
- rvm: 2.0.0
|
53
|
-
env: DB=active_record
|
54
|
-
gemfile: gemfiles/rails3.gemfile
|
55
|
-
# Rails >=4 officially supports >= Ruby 1.9.3
|
56
|
-
- rvm: 1.8.7
|
57
|
-
env: DB=mongodb
|
58
|
-
gemfile: gemfiles/rails4.gemfile
|
59
|
-
- rvm: 1.8.7
|
60
|
-
env: DB=redis
|
61
|
-
gemfile: gemfiles/rails4.gemfile
|
62
|
-
- rvm: 1.8.7
|
63
|
-
env: DB=active_record
|
64
|
-
gemfile: gemfiles/rails4.gemfile
|
65
23
|
allow_failures:
|
66
24
|
- rvm: ruby-head
|
67
|
-
- rvm: 2.0.0
|
68
|
-
env: DB=mongodb
|
69
|
-
gemfile: gemfiles/rails31.gemfile
|
70
|
-
- rvm: 2.0.0
|
71
|
-
env: DB=redis
|
72
|
-
gemfile: gemfiles/rails31.gemfile
|
73
|
-
- rvm: 2.0.0
|
74
|
-
env: DB=active_record
|
75
|
-
gemfile: gemfiles/rails31.gemfile
|
data/Appraisals
CHANGED
@@ -1,22 +1,13 @@
|
|
1
|
-
appraise "rails3" do
|
2
|
-
gem "rails", "3.0.11"
|
3
|
-
gem "fastthread", :git => "git://github.com/zoltankiss/fastthread.git", :platforms => :mri_20
|
4
|
-
gem "passenger", "~>3.0"
|
5
|
-
end
|
6
|
-
|
7
|
-
appraise "rails31" do
|
8
|
-
gem "rails", "3.1.3"
|
9
|
-
gem "fastthread", :git => "git://github.com/zoltankiss/fastthread.git", :platforms => :mri_20
|
10
|
-
gem "passenger", "~>3.0"
|
11
|
-
end
|
12
|
-
|
13
1
|
appraise "rails32" do
|
2
|
+
gem "mocha", "~> 0.12.8", :require=>false
|
3
|
+
gem "minitest", "~>4.2.0"
|
14
4
|
gem "rails", "3.2.1"
|
15
5
|
gem "fastthread", :git => "git://github.com/zoltankiss/fastthread.git", :platforms => :mri_20
|
16
6
|
gem "passenger", "~>3.0"
|
17
7
|
end
|
18
8
|
|
19
9
|
appraise "rails4" do
|
10
|
+
gem "mocha", "~> 1.0", :require=>false
|
20
11
|
gem "rails", "4.0.0"
|
21
12
|
gem "fastthread", :git => "git://github.com/zoltankiss/fastthread.git", :platforms => :mri_20
|
22
13
|
gem "passenger", "~>3.0"
|
data/CHANGELOG
CHANGED
data/Gemfile
CHANGED
@@ -3,10 +3,6 @@ gemspec
|
|
3
3
|
|
4
4
|
# Frameworks
|
5
5
|
gem "rack"
|
6
|
-
gem "rails", "~>2.3.8"
|
7
|
-
|
8
|
-
# Servers
|
9
|
-
gem "passenger", "~>2.0"
|
10
6
|
|
11
7
|
# Persistence
|
12
8
|
gem "redis", ">= 2.1"
|
@@ -16,19 +12,13 @@ gem "mongo"
|
|
16
12
|
gem "sqlite3"
|
17
13
|
|
18
14
|
# Math libraries
|
19
|
-
gem "backports", :platforms => :mri_18
|
20
15
|
gem "integration"
|
21
16
|
gem "rubystats"
|
22
17
|
|
23
18
|
# APIs
|
24
19
|
gem "garb"
|
25
20
|
|
26
|
-
# Compatibility
|
27
|
-
gem "SystemTimer", "1.2.3", :platforms => :mri_18
|
28
|
-
|
29
21
|
# Testing
|
30
|
-
gem "mocha", :require=>false
|
31
|
-
gem "shoulda", :require=>false # Requires test/unit
|
32
22
|
gem "timecop", :require=>false
|
33
23
|
gem "webmock", :require=>false
|
34
24
|
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
vanity (
|
4
|
+
vanity (2.0.0.beta)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
RedCloth (4.2.9)
|
10
|
-
SystemTimer (1.2.3)
|
11
|
-
actionmailer (2.3.14)
|
12
|
-
actionpack (= 2.3.14)
|
13
|
-
actionpack (2.3.14)
|
14
|
-
activesupport (= 2.3.14)
|
15
|
-
rack (~> 1.1.0)
|
16
|
-
activerecord (2.3.14)
|
17
|
-
activesupport (= 2.3.14)
|
18
|
-
activeresource (2.3.14)
|
19
|
-
activesupport (= 2.3.14)
|
20
10
|
activesupport (2.3.14)
|
21
11
|
addressable (2.2.7)
|
22
12
|
albino (1.3.3)
|
@@ -25,7 +15,6 @@ GEM
|
|
25
15
|
bundler
|
26
16
|
rake
|
27
17
|
thor (>= 0.14.0)
|
28
|
-
backports (3.3.5)
|
29
18
|
bson (1.6.0)
|
30
19
|
bson_ext (1.6.0)
|
31
20
|
bson (= 1.6.0)
|
@@ -34,7 +23,6 @@ GEM
|
|
34
23
|
crack (0.3.1)
|
35
24
|
directory_watcher (1.4.1)
|
36
25
|
fast-stemmer (1.0.0)
|
37
|
-
fastthread (1.0.7)
|
38
26
|
garb (0.9.1)
|
39
27
|
activesupport (>= 2.2.0)
|
40
28
|
crack (>= 0.1.6)
|
@@ -50,34 +38,16 @@ GEM
|
|
50
38
|
liquid (2.3.0)
|
51
39
|
maruku (0.6.0)
|
52
40
|
syntax (>= 1.0.0)
|
53
|
-
|
54
|
-
mocha (0.10.5)
|
55
|
-
metaclass (~> 0.0.1)
|
41
|
+
minitest (4.7.5)
|
56
42
|
mongo (1.6.0)
|
57
43
|
bson (= 1.6.0)
|
58
|
-
passenger (2.2.15)
|
59
|
-
fastthread (>= 1.0.1)
|
60
|
-
rack
|
61
|
-
rake (>= 0.8.1)
|
62
44
|
posix-spawn (0.3.6)
|
63
45
|
rack (1.1.3)
|
64
|
-
rails (2.3.14)
|
65
|
-
actionmailer (= 2.3.14)
|
66
|
-
actionpack (= 2.3.14)
|
67
|
-
activerecord (= 2.3.14)
|
68
|
-
activeresource (= 2.3.14)
|
69
|
-
activesupport (= 2.3.14)
|
70
|
-
rake (>= 0.8.3)
|
71
46
|
rake (10.1.0)
|
72
47
|
redis (3.0.6)
|
73
48
|
redis-namespace (1.3.2)
|
74
49
|
redis (~> 3.0.4)
|
75
50
|
rubystats (0.2.3)
|
76
|
-
shoulda (3.0.1)
|
77
|
-
shoulda-context (~> 1.0.0)
|
78
|
-
shoulda-matchers (~> 1.0.0)
|
79
|
-
shoulda-context (1.0.0)
|
80
|
-
shoulda-matchers (1.0.0)
|
81
51
|
sqlite3 (1.3.8)
|
82
52
|
syntax (1.0.0)
|
83
53
|
thor (0.18.1)
|
@@ -92,24 +62,19 @@ PLATFORMS
|
|
92
62
|
|
93
63
|
DEPENDENCIES
|
94
64
|
RedCloth
|
95
|
-
SystemTimer (= 1.2.3)
|
96
65
|
appraisal (>= 1.0.0.beta2)
|
97
|
-
backports
|
98
66
|
bson_ext
|
99
67
|
bundler (>= 1.0.0)
|
100
68
|
garb
|
101
69
|
integration
|
102
70
|
jekyll
|
103
|
-
|
71
|
+
minitest (>= 4.2)
|
104
72
|
mongo
|
105
|
-
passenger (~> 2.0)
|
106
73
|
rack
|
107
|
-
rails (~> 2.3.8)
|
108
74
|
rake
|
109
75
|
redis (>= 2.1)
|
110
76
|
redis-namespace (>= 1.1.0)
|
111
77
|
rubystats
|
112
|
-
shoulda
|
113
78
|
sqlite3
|
114
79
|
timecop
|
115
80
|
vanity!
|
data/README.rdoc
CHANGED
@@ -21,15 +21,7 @@ Add to your Gemfile:
|
|
21
21
|
|
22
22
|
gem "vanity"
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
Rails::Initializer.run do |config|
|
27
|
-
gem.config "vanity"
|
28
|
-
|
29
|
-
config.after_initialize do
|
30
|
-
require "vanity"
|
31
|
-
end
|
32
|
-
end
|
24
|
+
(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].)
|
33
25
|
|
34
26
|
==== Step 1.2
|
35
27
|
|
@@ -168,12 +160,9 @@ To set this up simply do the following:
|
|
168
160
|
|
169
161
|
Here's what's tested and known to work:
|
170
162
|
|
171
|
-
Ruby 1.8.7
|
172
|
-
Persistence: Redis, Mongo, ActiveRecord
|
173
|
-
Rails: 2.3, 3, 3.1, 3.2
|
174
163
|
Ruby 1.9.3
|
175
164
|
Persistence: Redis, Mongo, ActiveRecord
|
176
|
-
Rails: 3
|
165
|
+
Rails: 3.2, 4.0
|
177
166
|
Ruby 2.0
|
178
167
|
Persistence: Redis, Mongo, ActiveRecord
|
179
168
|
Rails: 3.2, 4.0
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ desc "Test everything"
|
|
8
8
|
task "test:all"=>"test:adapters"
|
9
9
|
|
10
10
|
# Ruby versions we're testing with.
|
11
|
-
RUBIES = %w{1.
|
11
|
+
RUBIES = %w{1.9.3 2.0.0}
|
12
12
|
|
13
13
|
# Use rake test:rubies to run all combination of tests (see test:adapters) using
|
14
14
|
# all the versions of Ruby specified in RUBIES. Or to test a specific version of
|
@@ -64,21 +64,15 @@ task "test:adapters", :adapter do |t, args|
|
|
64
64
|
end
|
65
65
|
|
66
66
|
# Run the test suit.
|
67
|
+
Rake::TestTask.new(:test) do |task|
|
68
|
+
task.libs << "lib"
|
69
|
+
task.libs << "test"
|
70
|
+
task.pattern = "test/**/*_test.rb"
|
71
|
+
task.verbose = false
|
72
|
+
end
|
67
73
|
|
68
74
|
task :default=>:test
|
69
75
|
desc "Run all tests"
|
70
|
-
Rake::TestTask.new do |task|
|
71
|
-
task.test_files = FileList['test/**/*_test.rb']
|
72
|
-
if Rake.application.options.trace
|
73
|
-
#task.warning = true
|
74
|
-
task.verbose = true
|
75
|
-
elsif Rake.application.options.silent
|
76
|
-
task.ruby_opts << "-W0"
|
77
|
-
else
|
78
|
-
task.verbose = true
|
79
|
-
end
|
80
|
-
task.ruby_opts << "-I."
|
81
|
-
end
|
82
76
|
|
83
77
|
task(:clobber) { rm_rf "tmp" }
|
84
78
|
|
data/bin/vanity
CHANGED
data/doc/rails.textile
CHANGED
@@ -20,18 +20,6 @@ Add Vanity to your Gemfile:
|
|
20
20
|
gem "vanity"
|
21
21
|
</pre>
|
22
22
|
|
23
|
-
<em>Rails 2.x:</em>
|
24
|
-
|
25
|
-
<pre>
|
26
|
-
Rails::Initializer.run do |config|
|
27
|
-
gem.config "vanity"
|
28
|
-
|
29
|
-
config.after_initialize do
|
30
|
-
require "vanity"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
</pre>
|
34
|
-
|
35
23
|
h3(#config). Configuring Vanity
|
36
24
|
|
37
25
|
h4. Configuring identity
|
data/gemfiles/rails32.gemfile
CHANGED
@@ -8,15 +8,13 @@ gem "redis-namespace", ">= 1.1.0"
|
|
8
8
|
gem "bson_ext"
|
9
9
|
gem "mongo"
|
10
10
|
gem "sqlite3"
|
11
|
-
gem "backports", :platforms=>:mri_18
|
12
11
|
gem "integration"
|
13
12
|
gem "rubystats"
|
14
13
|
gem "garb"
|
15
|
-
gem "SystemTimer", "1.2.3", :platforms=>:mri_18
|
16
|
-
gem "mocha", :require=>false
|
17
|
-
gem "shoulda", :require=>false
|
18
14
|
gem "timecop", :require=>false
|
19
15
|
gem "webmock", :require=>false
|
16
|
+
gem "mocha", "~> 0.12.8", :require=>false
|
17
|
+
gem "minitest", "~>4.2.0"
|
20
18
|
gem "rails", "3.2.1"
|
21
19
|
gem "fastthread", :git=>"git://github.com/zoltankiss/fastthread.git", :platforms=>:mri_20
|
22
20
|
gem "passenger", "~>3.0"
|
@@ -7,13 +7,12 @@ GIT
|
|
7
7
|
PATH
|
8
8
|
remote: ..
|
9
9
|
specs:
|
10
|
-
vanity (
|
10
|
+
vanity (2.0.0.beta)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
15
|
RedCloth (4.2.9)
|
16
|
-
SystemTimer (1.2.3)
|
17
16
|
actionmailer (3.2.1)
|
18
17
|
actionpack (= 3.2.1)
|
19
18
|
mail (~> 2.4.0)
|
@@ -49,7 +48,6 @@ GEM
|
|
49
48
|
rake
|
50
49
|
thor (>= 0.14.0)
|
51
50
|
arel (3.0.2)
|
52
|
-
backports (3.3.5)
|
53
51
|
bson (1.6.0)
|
54
52
|
bson_ext (1.6.0)
|
55
53
|
bson (= 1.6.0)
|
@@ -84,9 +82,10 @@ GEM
|
|
84
82
|
treetop (~> 1.4.8)
|
85
83
|
maruku (0.6.0)
|
86
84
|
syntax (>= 1.0.0)
|
87
|
-
metaclass (0.0.
|
85
|
+
metaclass (0.0.4)
|
88
86
|
mime-types (1.17.2)
|
89
|
-
|
87
|
+
minitest (4.2.0)
|
88
|
+
mocha (0.12.10)
|
90
89
|
metaclass (~> 0.0.1)
|
91
90
|
mongo (1.6.0)
|
92
91
|
bson (= 1.6.0)
|
@@ -127,11 +126,6 @@ GEM
|
|
127
126
|
redis-namespace (1.3.2)
|
128
127
|
redis (~> 3.0.4)
|
129
128
|
rubystats (0.2.3)
|
130
|
-
shoulda (3.0.1)
|
131
|
-
shoulda-context (~> 1.0.0)
|
132
|
-
shoulda-matchers (~> 1.0.0)
|
133
|
-
shoulda-context (1.0.0)
|
134
|
-
shoulda-matchers (1.0.0)
|
135
129
|
sprockets (2.1.2)
|
136
130
|
hike (~> 1.2)
|
137
131
|
rack (~> 1.0)
|
@@ -155,16 +149,15 @@ PLATFORMS
|
|
155
149
|
|
156
150
|
DEPENDENCIES
|
157
151
|
RedCloth
|
158
|
-
SystemTimer (= 1.2.3)
|
159
152
|
appraisal (>= 1.0.0.beta2)
|
160
|
-
backports
|
161
153
|
bson_ext
|
162
154
|
bundler (>= 1.0.0)
|
163
155
|
fastthread!
|
164
156
|
garb
|
165
157
|
integration
|
166
158
|
jekyll
|
167
|
-
|
159
|
+
minitest (~> 4.2.0)
|
160
|
+
mocha (~> 0.12.8)
|
168
161
|
mongo
|
169
162
|
passenger (~> 3.0)
|
170
163
|
rack
|
@@ -173,7 +166,6 @@ DEPENDENCIES
|
|
173
166
|
redis (>= 2.1)
|
174
167
|
redis-namespace (>= 1.1.0)
|
175
168
|
rubystats
|
176
|
-
shoulda
|
177
169
|
sqlite3
|
178
170
|
timecop
|
179
171
|
vanity!
|
data/gemfiles/rails4.gemfile
CHANGED
@@ -8,15 +8,12 @@ gem "redis-namespace", ">= 1.1.0"
|
|
8
8
|
gem "bson_ext"
|
9
9
|
gem "mongo"
|
10
10
|
gem "sqlite3"
|
11
|
-
gem "backports", :platforms=>:mri_18
|
12
11
|
gem "integration"
|
13
12
|
gem "rubystats"
|
14
13
|
gem "garb"
|
15
|
-
gem "SystemTimer", "1.2.3", :platforms=>:mri_18
|
16
|
-
gem "mocha", :require=>false
|
17
|
-
gem "shoulda", :require=>false
|
18
14
|
gem "timecop", :require=>false
|
19
15
|
gem "webmock", :require=>false
|
16
|
+
gem "mocha", "~> 1.0", :require=>false
|
20
17
|
gem "rails", "4.0.0"
|
21
18
|
gem "fastthread", :git=>"git://github.com/zoltankiss/fastthread.git", :platforms=>:mri_20
|
22
19
|
gem "passenger", "~>3.0"
|
@@ -7,13 +7,12 @@ GIT
|
|
7
7
|
PATH
|
8
8
|
remote: ..
|
9
9
|
specs:
|
10
|
-
vanity (
|
10
|
+
vanity (2.0.0.beta)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
15
|
RedCloth (4.2.9)
|
16
|
-
SystemTimer (1.2.3)
|
17
16
|
actionmailer (4.0.0)
|
18
17
|
actionpack (= 4.0.0)
|
19
18
|
mail (~> 2.5.3)
|
@@ -47,7 +46,6 @@ GEM
|
|
47
46
|
thor (>= 0.14.0)
|
48
47
|
arel (4.0.1)
|
49
48
|
atomic (1.1.14)
|
50
|
-
backports (3.3.5)
|
51
49
|
bson (1.9.2)
|
52
50
|
bson_ext (1.9.2)
|
53
51
|
bson (~> 1.9.2)
|
@@ -80,10 +78,10 @@ GEM
|
|
80
78
|
treetop (~> 1.4.8)
|
81
79
|
maruku (0.6.0)
|
82
80
|
syntax (>= 1.0.0)
|
83
|
-
metaclass (0.0.
|
81
|
+
metaclass (0.0.4)
|
84
82
|
mime-types (1.25)
|
85
83
|
minitest (4.7.5)
|
86
|
-
mocha (0.
|
84
|
+
mocha (1.0.0)
|
87
85
|
metaclass (~> 0.0.1)
|
88
86
|
mongo (1.9.2)
|
89
87
|
bson (~> 1.9.2)
|
@@ -117,12 +115,6 @@ GEM
|
|
117
115
|
redis (~> 3.0.4)
|
118
116
|
rubystats (0.2.3)
|
119
117
|
safe_yaml (0.9.7)
|
120
|
-
shoulda (3.5.0)
|
121
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
122
|
-
shoulda-matchers (>= 1.4.1, < 3.0)
|
123
|
-
shoulda-context (1.1.6)
|
124
|
-
shoulda-matchers (2.4.0)
|
125
|
-
activesupport (>= 3.0.0)
|
126
118
|
sprockets (2.10.0)
|
127
119
|
hike (~> 1.2)
|
128
120
|
multi_json (~> 1.0)
|
@@ -153,16 +145,15 @@ PLATFORMS
|
|
153
145
|
|
154
146
|
DEPENDENCIES
|
155
147
|
RedCloth
|
156
|
-
SystemTimer (= 1.2.3)
|
157
148
|
appraisal (>= 1.0.0.beta2)
|
158
|
-
backports
|
159
149
|
bson_ext
|
160
150
|
bundler (>= 1.0.0)
|
161
151
|
fastthread!
|
162
152
|
garb
|
163
153
|
integration
|
164
154
|
jekyll
|
165
|
-
|
155
|
+
minitest (>= 4.2)
|
156
|
+
mocha (~> 1.0)
|
166
157
|
mongo
|
167
158
|
passenger (~> 3.0)
|
168
159
|
rack
|
@@ -171,7 +162,6 @@ DEPENDENCIES
|
|
171
162
|
redis (>= 2.1)
|
172
163
|
redis-namespace (>= 1.1.0)
|
173
164
|
rubystats
|
174
|
-
shoulda
|
175
165
|
sqlite3
|
176
166
|
timecop
|
177
167
|
vanity!
|
@@ -15,7 +15,7 @@ module Vanity
|
|
15
15
|
self.abstract_class = true
|
16
16
|
|
17
17
|
def self.needs_attr_accessible?
|
18
|
-
respond_to?(:attr_accessible) && !defined?(ActionController::StrongParameters)
|
18
|
+
respond_to?(:attr_accessible) && (!defined?(ActionController::StrongParameters) || defined?(ProtectedAttributes))
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.rails_agnostic_find_or_create_by(method, value)
|
@@ -25,6 +25,14 @@ module Vanity
|
|
25
25
|
send :"find_or_create_by_#{method}", value
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
def self.rails_agnostic_find_first(conditions)
|
30
|
+
if respond_to? :where
|
31
|
+
where(conditions).first
|
32
|
+
else
|
33
|
+
find(:first, :conditions => conditions)
|
34
|
+
end
|
35
|
+
end
|
28
36
|
end
|
29
37
|
|
30
38
|
# Schema model
|
@@ -36,8 +44,7 @@ module Vanity
|
|
36
44
|
class VanityMetric < VanityRecord
|
37
45
|
UPDATED_AT_GRACE_PERIOD = 1.minute
|
38
46
|
self.table_name = :vanity_metrics
|
39
|
-
has_many :vanity_metric_values
|
40
|
-
:class_name => 'Vanity::Adapters::ActiveRecordAdapter::VanityMetricValue'
|
47
|
+
has_many :vanity_metric_values
|
41
48
|
|
42
49
|
def self.retrieve(metric)
|
43
50
|
rails_agnostic_find_or_create_by(:metric_id, metric.to_s)
|
@@ -60,15 +67,13 @@ module Vanity
|
|
60
67
|
attr_accessible :date, :index, :value if needs_attr_accessible?
|
61
68
|
|
62
69
|
self.table_name = :vanity_metric_values
|
63
|
-
belongs_to :vanity_metric
|
64
|
-
:class_name => 'Vanity::Adapters::ActiveRecordAdapter::VanityMetric'
|
70
|
+
belongs_to :vanity_metric
|
65
71
|
end
|
66
72
|
|
67
73
|
# Experiment model
|
68
74
|
class VanityExperiment < VanityRecord
|
69
75
|
self.table_name = :vanity_experiments
|
70
|
-
has_many :vanity_conversions, :dependent => :destroy
|
71
|
-
:class_name => 'Vanity::Adapters::ActiveRecordAdapter::VanityConversion'
|
76
|
+
has_many :vanity_conversions, :dependent => :destroy
|
72
77
|
attr_accessible :experiment_id if needs_attr_accessible?
|
73
78
|
|
74
79
|
# Finds or creates the experiment
|
@@ -85,8 +90,7 @@ module Vanity
|
|
85
90
|
# Conversion model
|
86
91
|
class VanityConversion < VanityRecord
|
87
92
|
self.table_name = :vanity_conversions
|
88
|
-
belongs_to :vanity_experiment
|
89
|
-
:class_name => 'Vanity::Adapters::ActiveRecordAdapter::VanityExperiment'
|
93
|
+
belongs_to :vanity_experiment
|
90
94
|
end
|
91
95
|
|
92
96
|
# Participant model
|
@@ -99,7 +103,7 @@ module Vanity
|
|
99
103
|
# passed then this will be passed to create if creating, or will be
|
100
104
|
# used to update the found participant.
|
101
105
|
def self.retrieve(experiment, identity, create = true, update_with = nil)
|
102
|
-
if record = VanityParticipant.
|
106
|
+
if record = VanityParticipant.rails_agnostic_find_first(:experiment_id=>experiment.to_s, :identity=>identity.to_s)
|
103
107
|
record.update_attributes(update_with) if update_with
|
104
108
|
elsif create
|
105
109
|
record = VanityParticipant.create({ :experiment_id=>experiment.to_s, :identity=>identity.to_s }.merge(update_with || {}))
|
@@ -302,7 +302,7 @@ module Vanity
|
|
302
302
|
|
303
303
|
# Use the result of #score or #bayes_bandit_score to derive a conclusion. Returns an
|
304
304
|
# array of claims.
|
305
|
-
def conclusion(score = score
|
305
|
+
def conclusion(score = score)
|
306
306
|
claims = []
|
307
307
|
participants = score.alts.inject(0) { |t,alt| t + alt.participants }
|
308
308
|
claims << case participants
|
@@ -59,13 +59,10 @@ module Vanity
|
|
59
59
|
elsif symbol && object = send(symbol)
|
60
60
|
@vanity_identity = object.id
|
61
61
|
elsif response # everyday use
|
62
|
-
|
63
|
-
secure_random = defined?(SecureRandom) ? SecureRandom : ActiveSupport::SecureRandom
|
64
|
-
@vanity_identity = cookies["vanity_id"] || secure_random.hex(16)
|
62
|
+
@vanity_identity = cookies["vanity_id"] || SecureRandom.hex(16)
|
65
63
|
cookie = { :value=>@vanity_identity, :expires=>1.month.from_now }
|
66
64
|
# Useful if application and admin console are on separate domains.
|
67
|
-
|
68
|
-
cookie[:domain] ||= ::Rails.application.config.session_options[:domain] if ::Rails.respond_to?(:application)
|
65
|
+
cookie[:domain] ||= ::Rails.application.config.session_options[:domain]
|
69
66
|
cookies["vanity_id"] = cookie
|
70
67
|
@vanity_identity
|
71
68
|
else # during functional testing
|
@@ -95,8 +92,7 @@ module Vanity
|
|
95
92
|
else
|
96
93
|
class << self
|
97
94
|
define_method :vanity_identity do
|
98
|
-
|
99
|
-
@vanity_identity = @vanity_identity || secure_random.hex(16)
|
95
|
+
@vanity_identity = @vanity_identity || SecureRandom.hex(16)
|
100
96
|
end
|
101
97
|
end
|
102
98
|
end
|
@@ -104,7 +100,6 @@ module Vanity
|
|
104
100
|
protected :use_vanity_mailer
|
105
101
|
end
|
106
102
|
|
107
|
-
|
108
103
|
# Vanity needs these filters. They are includes in ActionController and
|
109
104
|
# automatically added when you use #use_vanity in your controller.
|
110
105
|
module Filters
|
@@ -221,7 +216,7 @@ module Vanity
|
|
221
216
|
def vanity_js
|
222
217
|
return if @_vanity_experiments.nil? || @_vanity_experiments.empty?
|
223
218
|
javascript_tag do
|
224
|
-
render :file => Vanity.template("_vanity
|
219
|
+
render :file => Vanity.template("_vanity"), :formats => [:js]
|
225
220
|
end
|
226
221
|
end
|
227
222
|
|
@@ -346,7 +341,7 @@ end
|
|
346
341
|
|
347
342
|
|
348
343
|
# Enhance ActionController with use_vanity, filters and helper methods.
|
349
|
-
|
344
|
+
ActiveSupport.on_load(:action_controller) do
|
350
345
|
# Include in controller, add view helper methods.
|
351
346
|
ActionController::Base.class_eval do
|
352
347
|
extend Vanity::Rails::UseVanity
|
@@ -355,13 +350,12 @@ if defined?(ActionController)
|
|
355
350
|
end
|
356
351
|
end
|
357
352
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
end
|
353
|
+
|
354
|
+
# Include in mailer, add view helper methods.
|
355
|
+
ActiveSupport.on_load(:action_mailer) do
|
356
|
+
include Vanity::Rails::UseVanityMailer
|
357
|
+
include Vanity::Rails::Filters
|
358
|
+
helper Vanity::Rails::Helpers
|
365
359
|
end
|
366
360
|
|
367
361
|
# Reconnect whenever we fork under Passenger.
|