vanity 1.8.3.beta → 1.8.3.beta2

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/.travis.yml CHANGED
@@ -17,6 +17,7 @@ gemfile:
17
17
  - gemfiles/rails3.gemfile
18
18
  - gemfiles/rails31.gemfile
19
19
  - gemfiles/rails32.gemfile
20
+ - gemfiles/rails4.gemfile
20
21
  before_script:
21
22
  - if [[ "`basename $BUNDLE_GEMFILE`" == "Gemfile" ]]; then rvm rubygems 1.8.25; fi # Rubygems 2.0.x fails with Rails 2.3
22
23
  - "mysql -e 'create database vanity_test;' >/dev/null"
@@ -52,6 +53,16 @@ matrix:
52
53
  - rvm: 2.0.0
53
54
  env: DB=mysql
54
55
  gemfile: gemfiles/rails3.gemfile
56
+ # Rails >=4 officially supports >= Ruby 1.9.3
57
+ - rvm: 1.8.7
58
+ env: DB=mongodb
59
+ gemfile: gemfiles/rails4.gemfile
60
+ - rvm: 1.8.7
61
+ env: DB=redis
62
+ gemfile: gemfiles/rails4.gemfile
63
+ - rvm: 1.8.7
64
+ env: DB=mysql
65
+ gemfile: gemfiles/rails4.gemfile
55
66
  allow_failures:
56
67
  - rvm: ruby-head
57
68
  - rvm: 2.0.0
data/Appraisals CHANGED
@@ -15,3 +15,9 @@ appraise "rails32" do
15
15
  gem "fastthread", :git => "git://github.com/zoltankiss/fastthread.git", :platforms => :mri_20
16
16
  gem "passenger", "~>3.0"
17
17
  end
18
+
19
+ appraise "rails4" do
20
+ gem "rails", "4.0.0"
21
+ gem "fastthread", :git => "git://github.com/zoltankiss/fastthread.git", :platforms => :mri_20
22
+ gem "passenger", "~>3.0"
23
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vanity (1.8.3.beta)
4
+ vanity (1.8.3.beta2)
5
5
  redis (>= 2.1)
6
6
  redis-namespace (>= 1.1.0)
7
7
 
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: /Users/phill/Development/ruby/vanity
9
9
  specs:
10
- vanity (1.8.2)
10
+ vanity (1.8.3.beta2)
11
11
  redis (>= 2.1)
12
12
  redis-namespace (>= 1.1.0)
13
13
 
@@ -103,9 +103,9 @@ GEM
103
103
  rake (0.9.2.2)
104
104
  rdoc (3.12)
105
105
  json (~> 1.4)
106
- redis (3.0.5)
107
- redis-namespace (1.3.1)
108
- redis (~> 3.0.0)
106
+ redis (3.0.6)
107
+ redis-namespace (1.3.2)
108
+ redis (~> 3.0.4)
109
109
  rubystats (0.2.3)
110
110
  shoulda (3.0.1)
111
111
  shoulda-context (~> 1.0.0)
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: /Users/phill/Development/ruby/vanity
9
9
  specs:
10
- vanity (1.8.2)
10
+ vanity (1.8.3.beta2)
11
11
  redis (>= 2.1)
12
12
  redis-namespace (>= 1.1.0)
13
13
 
@@ -59,7 +59,6 @@ GEM
59
59
  garb (0.9.1)
60
60
  activesupport (>= 2.2.0)
61
61
  crack (>= 0.1.6)
62
- hike (1.2.1)
63
62
  i18n (0.6.0)
64
63
  integration (0.1.0)
65
64
  json (1.6.5)
@@ -109,9 +108,9 @@ GEM
109
108
  rake (0.9.2.2)
110
109
  rdoc (3.12)
111
110
  json (~> 1.4)
112
- redis (3.0.5)
113
- redis-namespace (1.3.1)
114
- redis (~> 3.0.0)
111
+ redis (3.0.6)
112
+ redis-namespace (1.3.2)
113
+ redis (~> 3.0.4)
115
114
  rubystats (0.2.3)
116
115
  shoulda (3.0.1)
117
116
  shoulda-context (~> 1.0.0)
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: /Users/phill/Development/ruby/vanity
9
9
  specs:
10
- vanity (1.8.2)
10
+ vanity (1.8.3.beta2)
11
11
  redis (>= 2.1)
12
12
  redis-namespace (>= 1.1.0)
13
13
 
@@ -107,9 +107,9 @@ GEM
107
107
  rake (0.9.2.2)
108
108
  rdoc (3.12)
109
109
  json (~> 1.4)
110
- redis (3.0.5)
111
- redis-namespace (1.3.1)
112
- redis (~> 3.0.0)
110
+ redis (3.0.6)
111
+ redis-namespace (1.3.2)
112
+ redis (~> 3.0.4)
113
113
  rubystats (0.2.3)
114
114
  shoulda (3.0.1)
115
115
  shoulda-context (~> 1.0.0)
@@ -0,0 +1,24 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack"
6
+ gem "bson_ext"
7
+ gem "mongo"
8
+ gem "mysql"
9
+ gem "pg"
10
+ gem "backports", :platforms=>:mri_18
11
+ gem "integration"
12
+ gem "rubystats"
13
+ gem "garb"
14
+ gem "SystemTimer", "1.2.3", :platforms=>:mri_18
15
+ gem "appraisal"
16
+ gem "mocha", :require=>false
17
+ gem "shoulda", :require=>false
18
+ gem "timecop", :require=>false
19
+ gem "webmock", :require=>false
20
+ gem "rails", "4.0.0"
21
+ gem "fastthread", :git=>"git://github.com/zoltankiss/fastthread.git", :platforms=>:mri_20
22
+ gem "passenger", "~>3.0"
23
+
24
+ gemspec :path=>"../"
@@ -0,0 +1,154 @@
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: /Users/phill/Development/ruby/vanity
9
+ specs:
10
+ vanity (1.8.3.beta2)
11
+ redis (>= 2.1)
12
+ redis-namespace (>= 1.1.0)
13
+
14
+ GEM
15
+ remote: https://rubygems.org/
16
+ specs:
17
+ SystemTimer (1.2.3)
18
+ actionmailer (4.0.0)
19
+ actionpack (= 4.0.0)
20
+ mail (~> 2.5.3)
21
+ actionpack (4.0.0)
22
+ activesupport (= 4.0.0)
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.0)
28
+ activesupport (= 4.0.0)
29
+ builder (~> 3.1.0)
30
+ activerecord (4.0.0)
31
+ activemodel (= 4.0.0)
32
+ activerecord-deprecated_finders (~> 1.0.2)
33
+ activesupport (= 4.0.0)
34
+ arel (~> 4.0.0)
35
+ activerecord-deprecated_finders (1.0.3)
36
+ activesupport (4.0.0)
37
+ i18n (~> 0.6, >= 0.6.4)
38
+ minitest (~> 4.2)
39
+ multi_json (~> 1.3)
40
+ thread_safe (~> 0.1)
41
+ tzinfo (~> 0.3.37)
42
+ addressable (2.3.5)
43
+ appraisal (0.5.2)
44
+ bundler
45
+ rake
46
+ arel (4.0.1)
47
+ atomic (1.1.14)
48
+ backports (3.3.5)
49
+ bson (1.9.2)
50
+ bson_ext (1.9.2)
51
+ bson (~> 1.9.2)
52
+ builder (3.1.4)
53
+ crack (0.4.1)
54
+ safe_yaml (~> 0.9.0)
55
+ daemon_controller (1.1.7)
56
+ erubis (2.7.0)
57
+ garb (0.9.1)
58
+ activesupport (>= 2.2.0)
59
+ crack (>= 0.1.6)
60
+ hike (1.2.3)
61
+ i18n (0.6.5)
62
+ integration (0.1.0)
63
+ mail (2.5.4)
64
+ mime-types (~> 1.16)
65
+ treetop (~> 1.4.8)
66
+ metaclass (0.0.1)
67
+ mime-types (1.25)
68
+ minitest (4.7.5)
69
+ mocha (0.14.0)
70
+ metaclass (~> 0.0.1)
71
+ mongo (1.9.2)
72
+ bson (~> 1.9.2)
73
+ multi_json (1.8.2)
74
+ mysql (2.9.1)
75
+ passenger (3.0.21)
76
+ daemon_controller (>= 1.0.0)
77
+ fastthread (>= 1.0.1)
78
+ rack
79
+ rake (>= 0.8.1)
80
+ pg (0.17.0)
81
+ polyglot (0.3.3)
82
+ rack (1.5.2)
83
+ rack-test (0.6.2)
84
+ rack (>= 1.0)
85
+ rails (4.0.0)
86
+ actionmailer (= 4.0.0)
87
+ actionpack (= 4.0.0)
88
+ activerecord (= 4.0.0)
89
+ activesupport (= 4.0.0)
90
+ bundler (>= 1.3.0, < 2.0)
91
+ railties (= 4.0.0)
92
+ sprockets-rails (~> 2.0.0)
93
+ railties (4.0.0)
94
+ actionpack (= 4.0.0)
95
+ activesupport (= 4.0.0)
96
+ rake (>= 0.8.7)
97
+ thor (>= 0.18.1, < 2.0)
98
+ rake (10.1.0)
99
+ redis (3.0.6)
100
+ redis-namespace (1.3.2)
101
+ redis (~> 3.0.4)
102
+ rubystats (0.2.3)
103
+ safe_yaml (0.9.7)
104
+ shoulda (3.5.0)
105
+ shoulda-context (~> 1.0, >= 1.0.1)
106
+ shoulda-matchers (>= 1.4.1, < 3.0)
107
+ shoulda-context (1.1.6)
108
+ shoulda-matchers (2.4.0)
109
+ activesupport (>= 3.0.0)
110
+ sprockets (2.10.0)
111
+ hike (~> 1.2)
112
+ multi_json (~> 1.0)
113
+ rack (~> 1.0)
114
+ tilt (~> 1.1, != 1.3.0)
115
+ sprockets-rails (2.0.1)
116
+ actionpack (>= 3.0)
117
+ activesupport (>= 3.0)
118
+ sprockets (~> 2.8)
119
+ thor (0.18.1)
120
+ thread_safe (0.1.3)
121
+ atomic
122
+ tilt (1.4.1)
123
+ timecop (0.6.3)
124
+ treetop (1.4.15)
125
+ polyglot
126
+ polyglot (>= 0.3.1)
127
+ tzinfo (0.3.38)
128
+ webmock (1.15.2)
129
+ addressable (>= 2.2.7)
130
+ crack (>= 0.3.2)
131
+
132
+ PLATFORMS
133
+ ruby
134
+
135
+ DEPENDENCIES
136
+ SystemTimer (= 1.2.3)
137
+ appraisal
138
+ backports
139
+ bson_ext
140
+ fastthread!
141
+ garb
142
+ integration
143
+ mocha
144
+ mongo
145
+ mysql
146
+ passenger (~> 3.0)
147
+ pg
148
+ rack
149
+ rails (= 4.0.0)
150
+ rubystats
151
+ shoulda
152
+ timecop
153
+ vanity!
154
+ webmock
@@ -13,6 +13,10 @@ module Vanity
13
13
  # Base model, stores connection and defines schema
14
14
  class VanityRecord < ActiveRecord::Base
15
15
  self.abstract_class = true
16
+
17
+ def self.needs_attr_accessible?
18
+ respond_to?(:attr_accessible) && !defined?(ActionController::StrongParameters)
19
+ end
16
20
  end
17
21
 
18
22
  # Schema model
@@ -32,7 +36,7 @@ module Vanity
32
36
 
33
37
  # Metric value
34
38
  class VanityMetricValue < VanityRecord
35
- attr_accessible :date, :index, :value if respond_to?(:attr_accessible)
39
+ attr_accessible :date, :index, :value if needs_attr_accessible?
36
40
 
37
41
  self.table_name = :vanity_metric_values
38
42
  belongs_to :vanity_metric
@@ -42,7 +46,7 @@ module Vanity
42
46
  class VanityExperiment < VanityRecord
43
47
  self.table_name = :vanity_experiments
44
48
  has_many :vanity_conversions, :dependent => :destroy
45
- attr_accessible :experiment_id if respond_to?(:attr_accessible)
49
+ attr_accessible :experiment_id if needs_attr_accessible?
46
50
 
47
51
  # Finds or creates the experiment
48
52
  def self.retrieve(experiment)
@@ -64,7 +68,7 @@ module Vanity
64
68
  # Participant model
65
69
  class VanityParticipant < VanityRecord
66
70
  self.table_name = :vanity_participants
67
- attr_accessible :experiment_id, :identity, :seen, :shown, :converted if respond_to?(:attr_accessible)
71
+ attr_accessible :experiment_id, :identity, :seen, :shown, :converted if needs_attr_accessible?
68
72
 
69
73
  # Finds the participant by experiment and identity. If
70
74
  # create is true then it will create the participant
@@ -1,5 +1,5 @@
1
1
  module Vanity
2
- VERSION = "1.8.3.beta"
2
+ VERSION = "1.8.3.beta2"
3
3
 
4
4
  module Version
5
5
  version = VERSION.to_s.split(".").map { |i| i.to_i }
@@ -2,9 +2,6 @@ require "test/test_helper"
2
2
 
3
3
  context ".playground_should_autoconnect?" do
4
4
 
5
- setup do
6
- end
7
-
8
5
  test "returns true by default" do
9
6
  autoconnect = Vanity::Autoconnect.playground_should_autoconnect?
10
7
  assert autoconnect == true
@@ -46,5 +46,9 @@ module Dummy
46
46
 
47
47
  # Configure sensitive parameters which will be filtered from the log file.
48
48
  config.filter_parameters += [:password]
49
+
50
+ config.eager_load = (ENV['RAILS_ENV'] || ENV['RACK_ENV']) == "production" if Rails::Application.respond_to?(:eager_load!)
51
+
52
+ ActiveSupport::Deprecation.silenced = true if ActiveSupport::Deprecation.respond_to?(:silenced) && ENV['CI']
49
53
  end
50
54
  end
@@ -54,5 +54,5 @@ Dummy::Application.routes.draw do
54
54
 
55
55
  # This is a legacy wild controller route that's not recommended for RESTful applications.
56
56
  # Note: This route will make all actions in every controller accessible via GET requests.
57
- match ':controller(/:action(/:id(.:format)))'
57
+ match ':controller(/:action(/:id(.:format)))', :via => [:get]
58
58
  end
@@ -13,7 +13,7 @@ class AbTestController < ActionController::Base
13
13
  end
14
14
 
15
15
  def test_capture
16
- if Rails.version.to_i == 3
16
+ if defined?(Rails::Railtie)
17
17
  render :inline=>"<%= ab_test :simple do |value| %><%= value %><% end %>"
18
18
  else
19
19
  render :inline=>"<% ab_test :simple do |value| %><%= value %><% end %>"
@@ -152,10 +152,11 @@ class ExperimentTest < Test::Unit::TestCase
152
152
  def test_complete_updates_completed_at
153
153
  new_ab_test(:ice_cream_flavor) { metrics :happiness }
154
154
 
155
- Timecop.freeze(2008, 9, 1, 12, 0, 0) do
155
+ time = Time.utc(2008, 9, 1, 12, 0, 0)
156
+ Timecop.freeze(time) do
156
157
  experiment(:ice_cream_flavor).complete!(1)
157
158
  end
158
- assert_equal Time.local(2008, 9, 1, 12, 0, 0), experiment(:ice_cream_flavor).completed_at
159
+ assert_equal time, experiment(:ice_cream_flavor).completed_at
159
160
  end
160
161
 
161
162
  end
@@ -163,7 +163,7 @@ context "Metric name" do
163
163
  end
164
164
  assert_equal "Yawns per second", Vanity.playground.metric(:yawns_sec).name
165
165
  end
166
- end
166
+ end
167
167
 
168
168
 
169
169
  context "Metric description" do
@@ -237,7 +237,7 @@ context "Metric last_update_at" do
237
237
  end
238
238
  assert_in_delta metric.last_update_at.to_i, (Time.now + 1.day).to_i, 1
239
239
  end
240
- end
240
+ end
241
241
 
242
242
 
243
243
  context "Metric data" do
data/test/rails_test.rb CHANGED
@@ -165,7 +165,7 @@ class VanityMailer < ActionMailer::Base
165
165
  experiment(:pie_or_cake).chooses(forced_outcome)
166
166
 
167
167
  if defined?(Rails::Railtie)
168
- mail :subject =>ab_test(:pie_or_cake).to_s
168
+ mail :subject =>ab_test(:pie_or_cake).to_s, :body => ""
169
169
  else
170
170
  subject ab_test(:pie_or_cake).to_s
171
171
  body ""
@@ -442,10 +442,10 @@ $:.unshift File.expand_path("../lib")
442
442
  RAILS_ROOT = File.expand_path(".")
443
443
  RB
444
444
  code = code_setup
445
- code += defined?(Rails::Railtie) ? load_rails_3(env) : load_rails_2(env)
445
+ code += defined?(Rails::Railtie) ? load_rails_3_or_4(env) : load_rails_2(env)
446
446
  code += %Q{\nrequire "vanity"\n}
447
447
  code += before_initialize
448
- code += defined?(Rails::Railtie) ? initialize_rails_3 : initialize_rails_2
448
+ code += defined?(Rails::Railtie) ? initialize_rails_3_or_4 : initialize_rails_2
449
449
  code += after_initialize
450
450
  tmp.write code
451
451
  tmp.flush
@@ -468,7 +468,7 @@ initializer.check_gem_dependencies
468
468
  RB
469
469
  end
470
470
 
471
- def load_rails_3(env)
471
+ def load_rails_3_or_4(env)
472
472
  <<-RB
473
473
  ENV['BUNDLE_GEMFILE'] ||= "#{ENV['BUNDLE_GEMFILE']}"
474
474
  require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -481,6 +481,8 @@ Bundler.require(:default)
481
481
  module Foo
482
482
  class Application < Rails::Application
483
483
  config.active_support.deprecation = :notify
484
+ config.eager_load = #{env == "production"} if Rails::Application.respond_to?(:eager_load!)
485
+ ActiveSupport::Deprecation.silenced = true if ActiveSupport::Deprecation.respond_to?(:silenced) && ENV['CI']
484
486
  end
485
487
  end
486
488
  RB
@@ -492,7 +494,7 @@ initializer.after_initialize
492
494
  RB
493
495
  end
494
496
 
495
- def initialize_rails_3
497
+ def initialize_rails_3_or_4
496
498
  <<-RB
497
499
  Foo::Application.initialize!
498
500
  RB
data/test/test_helper.rb CHANGED
@@ -45,10 +45,7 @@ if $VERBOSE
45
45
  $logger.level = Logger::DEBUG
46
46
  end
47
47
 
48
-
49
- class Test::Unit::TestCase
50
- include WebMock::API
51
-
48
+ module VanityTestHelpers
52
49
  # We go destructive on the database at the end of each run, so make sure we
53
50
  # don't use databases you care about. For Redis, we pick database 15
54
51
  # (default is 0).
@@ -64,11 +61,18 @@ class Test::Unit::TestCase
64
61
  defined?(Rails::Railtie)
65
62
  end
66
63
 
67
- def setup
64
+ def setup_after
68
65
  FileUtils.mkpath "tmp/experiments/metrics"
69
66
  new_playground
70
67
  end
71
68
 
69
+ def teardown_after
70
+ Vanity.context = nil
71
+ FileUtils.rm_rf "tmp"
72
+ Vanity.playground.connection.flushdb if Vanity.playground.connected?
73
+ WebMock.reset!
74
+ end
75
+
72
76
  # Call this on teardown. It wipes put the playground and any state held in it
73
77
  # (mostly experiments), resets vanity ID, and clears database of all experiments.
74
78
  def nuke_playground
@@ -116,17 +120,33 @@ class Test::Unit::TestCase
116
120
  Vanity.playground.stubs(:connection).returns(stub(:flushdb=>nil))
117
121
  end
118
122
 
119
- def teardown
120
- Vanity.context = nil
121
- FileUtils.rm_rf "tmp"
122
- Vanity.playground.connection.flushdb if Vanity.playground.connected?
123
- WebMock.reset!
123
+ # Defining setup/tear down in a module and including it below doesn't
124
+ # override the built-in setup/teardown methods, so we alias_method_chain
125
+ # them to run.
126
+ def self.included(klass)
127
+ klass.class_eval {
128
+ alias :teardown_before :teardown
129
+ alias :teardown :teardown_after
130
+
131
+ alias :setup_before :setup
132
+ alias :setup :setup_after
133
+ }
124
134
  end
135
+ end
125
136
 
137
+ class Test::Unit::TestCase
138
+ include WebMock::API
139
+ include VanityTestHelpers
126
140
  end
127
141
 
142
+ if defined?(ActiveSupport::TestCase)
143
+ class ActiveSupport::TestCase
144
+ include WebMock::API
145
+ include VanityTestHelpers
146
+ end
147
+ end
128
148
 
129
- if ENV["DB"] == "postgres"
149
+ if ENV["DB"] == "postgres"
130
150
  ActiveRecord::Base.establish_connection :adapter=>"postgresql", :database=>"vanity_test"
131
151
  else
132
152
  ActiveRecord::Base.establish_connection :adapter=>"mysql", :database=>"vanity_test"
@@ -139,18 +159,7 @@ if ENV["DB"] == "mysql" || ENV["DB"] == "postgres"
139
159
  VanityMigration.up
140
160
  end
141
161
 
142
-
143
- class Array
144
- # Not in Ruby 1.8.6.
145
- unless method_defined?(:shuffle)
146
- def shuffle
147
- copy = clone
148
- Array.new(size) { copy.delete_at(Kernel.rand(copy.size)) }
149
- end
150
- end
151
- end
152
-
153
-
162
+ # test/spec/mini v3
154
163
  # Source: http://gist.github.com/25455
155
164
  def context(*args, &block)
156
165
  return super unless (name = args.first) && block
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: 1.8.3.beta
4
+ version: 1.8.3.beta2
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: 2013-11-16 00:00:00.000000000 Z
12
+ date: 2013-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
@@ -94,6 +94,8 @@ files:
94
94
  - gemfiles/rails31.gemfile.lock
95
95
  - gemfiles/rails32.gemfile
96
96
  - gemfiles/rails32.gemfile.lock
97
+ - gemfiles/rails4.gemfile
98
+ - gemfiles/rails4.gemfile.lock
97
99
  - generators/templates/vanity_migration.rb
98
100
  - generators/vanity_generator.rb
99
101
  - lib/generators/templates/vanity_migration.rb
@@ -194,7 +196,7 @@ licenses:
194
196
  post_install_message: To get started run vanity --help
195
197
  rdoc_options:
196
198
  - --title
197
- - Vanity 1.8.3.beta
199
+ - Vanity 1.8.3.beta2
198
200
  - --main
199
201
  - README.rdoc
200
202
  - --webcvs