field_test 0.3.1 → 0.3.2

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.

Potentially problematic release.


This version of field_test might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5935d4b9a0cca9bd7d08fb1e0acaf5ab6e0e7f8c8c44b71efae5a3667a0d37a6
4
- data.tar.gz: e839006d04adfe1e06d27c2b32b8ea601ada47106b05537bf6a11168c8b0864a
3
+ metadata.gz: 2a60826c451cf3807f5e111f2b4a619f4c07db0011ff27e7f2ceb0dd03bd1807
4
+ data.tar.gz: 1150b7a05035bf91193dcdaca20a7075b1350d50ef037afebe6a1866baea5fb9
5
5
  SHA512:
6
- metadata.gz: 0ab03821f1b5a95f8cf2681820ab4d13c10bde98889e2d5995cd05f7426f815d207bfcdd894db0da90acb1e1743adf6f7256c75d5f62572e27f7183a0992a722
7
- data.tar.gz: 84009fba31741d3c737f0623b580512bed5dadd455c35691fbe0388899dcf706a8d5ed1740f3d94cb877058e19740aa5321a5b51ef7595c31cea483b85dfd1bc
6
+ metadata.gz: 9a2644d12172b876b33ddc7faec2c4490623fed35aa7ae1848f0486a9ff176a80c2bdc2db66ec9196b93034f8566dbfc11c2027f524177a946427b6c4b10d71b
7
+ data.tar.gz: 1dc282f0f054e7a95bdc4dfccd1361c11f28b53d70a2b5083ba73e40d3af13230246ad85e38990f74e7dab01a48fb5be9fefc5b2e6e1d8dff8cf066bb1dc525a
@@ -1,4 +1,8 @@
1
- ## 0.3.1 [unreleased]
1
+ ## 0.3.2 (2020-04-16)
2
+
3
+ - Added support for excluding IP addresses
4
+
5
+ ## 0.3.1 (2019-07-01)
2
6
 
3
7
  - Added `closed` and `keep_variant`
4
8
  - Added `field_test_upgrade_memberships` method
@@ -9,7 +13,7 @@ Security
9
13
 
10
14
  - Fixed arbitrary variants via query parameters - see [#17](https://github.com/ankane/field_test/issues/17)
11
15
 
12
- ## 0.3.0
16
+ ## 0.3.0 (2019-06-02)
13
17
 
14
18
  - Added support for native apps
15
19
  - Added `cookies` option
@@ -23,36 +27,36 @@ Breaking changes
23
27
  - Split out participant id and type
24
28
  - Changed participant logic for emails
25
29
 
26
- ## 0.2.4
30
+ ## 0.2.4 (2019-01-03)
27
31
 
28
32
  - Fixed `PG::AmbiguousColumn` error
29
33
 
30
- ## 0.2.3
34
+ ## 0.2.3 (2018-01-28)
31
35
 
32
36
  - Fixed participant reporting for multiple goals
33
37
 
34
- ## 0.2.2
38
+ ## 0.2.2 (2017-05-01)
35
39
 
36
40
  - Added support for Rails 5.1
37
41
 
38
- ## 0.2.1
42
+ ## 0.2.1 (2016-12-18)
39
43
 
40
44
  - Added support for multiple goals
41
45
 
42
- ## 0.2.0
46
+ ## 0.2.0 (2016-12-17)
43
47
 
44
48
  - Better web UI
45
49
  - Removed `cookie:` prefix for unknown participants
46
50
 
47
- ## 0.1.2
51
+ ## 0.1.2 (2016-12-17)
48
52
 
49
53
  - Exclude bots
50
54
  - Mailer improvements
51
55
 
52
- ## 0.1.1
56
+ ## 0.1.1 (2016-12-15)
53
57
 
54
58
  - Added basic web UI
55
59
 
56
- ## 0.1.0
60
+ ## 0.1.0 (2016-12-14)
57
61
 
58
62
  - First release
data/README.md CHANGED
@@ -151,6 +151,15 @@ You can also manually pass a participant with:
151
151
  field_test(:button_color, participant: company)
152
152
  ```
153
153
 
154
+ ## Jobs
155
+
156
+ To get variants in jobs, models, and other contexts, use:
157
+
158
+ ```ruby
159
+ experiment = FieldTest::Experiment.find(:button_color)
160
+ button_color = experiment.variant(user)
161
+ ```
162
+
154
163
  ## Config
155
164
 
156
165
  By default, bots are returned the first variant and excluded from metrics. Change this with:
@@ -160,6 +169,15 @@ exclude:
160
169
  bots: false
161
170
  ```
162
171
 
172
+ Exclude certain IP addresses with:
173
+
174
+ ```yml
175
+ exclude:
176
+ ips:
177
+ - 127.0.0.1
178
+ - 10.0.0.0/8
179
+ ```
180
+
163
181
  Keep track of when experiments started and ended. Use any format `Time.parse` accepts. Variants assigned outside this window are not included in metrics.
164
182
 
165
183
  ```yml
@@ -281,7 +299,7 @@ ENV["FIELD_TEST_USERNAME"] = "moonrise"
281
299
  ENV["FIELD_TEST_PASSWORD"] = "kingdom"
282
300
  ```
283
301
 
284
- ## Reference
302
+ ## Updating Variants
285
303
 
286
304
  Assign a specific variant to a user with:
287
305
 
@@ -292,6 +310,8 @@ experiment.variant(participant, variant: "green")
292
310
 
293
311
  You can also change a user’s variant from the dashboard.
294
312
 
313
+ ## Associations
314
+
295
315
  To associate models with field test memberships, use:
296
316
 
297
317
  ```ruby
@@ -341,7 +361,7 @@ rails generate migration upgrade_field_test_participants
341
361
  with:
342
362
 
343
363
  ```ruby
344
- class UpgradeFieldTestParticipants < ActiveRecord::Migration[5.2]
364
+ class UpgradeFieldTestParticipants < ActiveRecord::Migration[6.0]
345
365
  def change
346
366
  add_column :field_test_memberships, :participant_type, :string
347
367
  add_column :field_test_memberships, :participant_id, :string
@@ -392,3 +412,12 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
392
412
  - Fix bugs and [submit pull requests](https://github.com/ankane/field_test/pulls)
393
413
  - Write, clarify, or fix documentation
394
414
  - Suggest or add new features
415
+
416
+ To get started with development:
417
+
418
+ ```sh
419
+ git clone https://github.com/ankane/field_test.git
420
+ cd field_test
421
+ bundle install
422
+ bundle exec rake test
423
+ ```
@@ -30,6 +30,10 @@ module FieldTest
30
30
  @config ||= YAML.load(ERB.new(File.read(config_path)).result)
31
31
  end
32
32
 
33
+ def self.excluded_ips
34
+ @excluded_ips ||= Array(config["exclude"] && config["exclude"]["ips"]).map { |ip| IPAddr.new(ip) }
35
+ end
36
+
33
37
  def self.exclude_bots?
34
38
  config["exclude"] && config["exclude"]["bots"]
35
39
  end
@@ -16,6 +16,8 @@ module FieldTest
16
16
  options[:exclude] = Browser.new(request.user_agent).bot?
17
17
  end
18
18
 
19
+ options[:exclude] ||= FieldTest.excluded_ips.any? { |ip| ip.include?(request.remote_ip) }
20
+
19
21
  options[:ip] = request.remote_ip
20
22
  options[:user_agent] = request.user_agent
21
23
  end
@@ -1,3 +1,3 @@
1
1
  module FieldTest
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: field_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-02 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: browser
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.0'
69
69
  - !ruby/object:Gem::Dependency
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  - !ruby/object:Gem::Version
206
206
  version: '0'
207
207
  requirements: []
208
- rubygems_version: 3.0.4
208
+ rubygems_version: 3.1.2
209
209
  signing_key:
210
210
  specification_version: 4
211
211
  summary: A/B testing for Rails