black_and_white 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe603e2d2734c1274cc5de1418808152538d53a4
4
- data.tar.gz: 38a4ac58a26f7efe3f0dba5417a78bd422543f77
3
+ metadata.gz: 6a076aa61759d0fbc66173ceed6fd7f98056c342
4
+ data.tar.gz: 148aafcf667b76c0656d1c7ad729decdff9fe758
5
5
  SHA512:
6
- metadata.gz: 849ba4dda7fac51181030cb9e2a6c5e7eb567a5c7edad9cf02bd8fc060cae2fcec541c6df7305bdba9e331991c226fbf74bada8478c33f5d632b6f7953736dd1
7
- data.tar.gz: 69996498b6a174182848a071059765f5b052422d7b1a78a6aa1fa931190b4d54371a3fea7688a290fb140193f316477bb9488113c3ddb3f6db93f94dc50dd17f
6
+ metadata.gz: 64d543ed7774bd431564fdb4e0bfd84400daecb3e46005401122fc22cad7fc4f7c62eb2068fd6a63223a8bf0a9877f722d0da9ec6f41ad874c19a8847e19a637
7
+ data.tar.gz: aed3c1a19eec78ced485b4f7b58ed68551de2d93ae81e9ea45c1bed17475c030a21ef202b0354b642f1a1c746d0757c5fe5448d0e784f0b88ce3db07b1abc25b
data/README.md CHANGED
@@ -48,7 +48,7 @@ this will create the necessary migrations in the `db/migrate` folder.
48
48
  Review them and then feel free to migrate.
49
49
 
50
50
  ### For ActiveRecord objects:
51
- Include the black_and_white module for activerecord interactions:
51
+ Include the black_and_white module for activerecord interactions. The base class may have multiple a/b tests:
52
52
  ```ruby
53
53
  class User < ActiveRecord::Base
54
54
  include BlackAndWhite::ActiveRecord
@@ -63,6 +63,10 @@ By default all created tests are inactive.
63
63
  To add existing users (or any other object) to the A/B Test you can call:
64
64
  ```ruby
65
65
  user.ab_participate!('My Test')
66
+ user.ab_tests.size
67
+ => 1
68
+ user.ab_participates?('My Test')
69
+ => true
66
70
  ```
67
71
  You can also supply an additional block which is evaluated:
68
72
  ```ruby
@@ -70,10 +74,21 @@ user.ab_participate!('My Test') do |user|
70
74
  user.admin? # returns true, user is added to the ab test
71
75
  end
72
76
  ```
77
+ A couple of additional options are supported as well:
78
+
79
+ `join_inactive` => Join an a/b test, even if it is inactive
80
+ ```ruby
81
+ user.ab_participate!('My Inactive test', join_inactive: true)
82
+ ```
83
+ `raise_on_missing` => raises a custom error message if the given a/b test does not exist
84
+ ```ruby
85
+ user.ab_participate!('My Inactive test', raise_on_missing: true)
86
+ => AbTestError, "no A/B Test with name My Inactive test exists or it is not active"
87
+ ```
73
88
 
74
89
  ## Contributing
75
90
 
76
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/black_and_white. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
91
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wizardone/black_and_white. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
77
92
 
78
93
 
79
94
  ## License
@@ -34,11 +34,10 @@ module BlackAndWhite
34
34
  end
35
35
 
36
36
  def missing_ab_test(test_name)
37
- unless options[:raise_on_missing]
38
- return false
37
+ if options[:raise_on_missing]
38
+ raise AbTestError, "no A/B Test with name #{test_name} exists or it is not active"
39
39
  end
40
-
41
- raise AbTestError, "no A/B Test with name #{test_name} exists or it is not active"
40
+ false
42
41
  end
43
42
 
44
43
  def fetch_ab_test(name)
@@ -1,3 +1,3 @@
1
1
  module BlackAndWhite
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: black_and_white
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Slaveykov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-22 00:00:00.000000000 Z
11
+ date: 2016-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler