black_and_white 0.1.5 → 0.1.6
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.
- checksums.yaml +4 -4
- data/README.md +17 -3
- data/lib/black_and_white/helpers/database.rb +5 -5
- data/lib/black_and_white/version.rb +1 -1
- data/lib/black_and_white.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e779b2341b287d09338e106253de2fd2a804ab6
|
4
|
+
data.tar.gz: 793d5a54c18cea751353123b16f818a8ff5b8812
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2ea3c62d3fffb2c44c4fbd1c01faf952fbff9f73f9a5b2519afe708c2234e85c698cce0ca1753ac9f8524396da9637ba1f5ee679c9293c278d8c7af2afd7033
|
7
|
+
data.tar.gz: 3e1a37311ce38390a9a4815d94f607fbfae2f47ddfffde4e4be890b6d22c4da10677c7580b28a126c77acdfcfde393d220a7b9639eb330572131c80b2acb729e
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
gem 'black_and_white', '~> 0.1.
|
13
|
+
gem 'black_and_white', '~> 0.1.6'
|
14
14
|
```
|
15
15
|
|
16
16
|
And then execute:
|
@@ -36,7 +36,7 @@ BlackAndWhite.configure do |config|
|
|
36
36
|
config.bw_main_table = :ab_tests
|
37
37
|
config.bw_join_table = :ab_tests_users
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
BlackAndWhite::Hooks.init
|
41
41
|
```
|
42
42
|
|
@@ -45,7 +45,8 @@ After this run:
|
|
45
45
|
rails g black_and_white:migrations
|
46
46
|
```
|
47
47
|
this will create the necessary migrations in the `db/migrate` folder.
|
48
|
-
Review them and then feel free to migrate.
|
48
|
+
Review them and then feel free to migrate. Keep in mind that they give
|
49
|
+
you only some very basic columns. You can add as much as you want.
|
49
50
|
|
50
51
|
### For ActiveRecord objects:
|
51
52
|
Include the black_and_white module for activerecord interactions. The base class may have multiple a/b tests:
|
@@ -86,6 +87,19 @@ user.ab_participate!('My Inactive test', raise_on_missing: true)
|
|
86
87
|
=> AbTestError, "no A/B Test with name My Inactive test exists or it is not active"
|
87
88
|
```
|
88
89
|
|
90
|
+
If you added additional db colums or you want to add or extend more logic you can
|
91
|
+
use the `add` method which evaluates the given block in the scope of
|
92
|
+
the main `BlackAndWhite` module. That way you don't have to worry about
|
93
|
+
code location
|
94
|
+
```ruby
|
95
|
+
model User < ActiveRecord::Base
|
96
|
+
include BlackAndWhite::ActiveRecord
|
97
|
+
BlackAndWhite.add(self) do
|
98
|
+
def my_new_method; end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
```
|
102
|
+
|
89
103
|
## Contributing
|
90
104
|
|
91
105
|
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.
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module BlackAndWhite
|
2
2
|
module Helpers
|
3
3
|
module Database
|
4
|
-
def bw_tests_table_name_pluralize
|
5
|
-
BlackAndWhite.config.bw_main_table.to_s.pluralize
|
6
|
-
end
|
7
|
-
|
8
4
|
def bw_tests_table_data
|
9
5
|
<<RUBY
|
10
6
|
t.string :name, unique: true, null: false
|
@@ -44,8 +40,12 @@ RUBY
|
|
44
40
|
BlackAndWhite.config.bw_class_table.to_s.singularize
|
45
41
|
end
|
46
42
|
|
43
|
+
def bw_tests_table_name_pluralize
|
44
|
+
BlackAndWhite.config.bw_main_table.to_s.pluralize
|
45
|
+
end
|
46
|
+
|
47
47
|
def migration_version
|
48
|
-
if defined?(
|
48
|
+
if defined?(Rails) && Rails.version.start_with?('5')
|
49
49
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
50
50
|
end
|
51
51
|
end
|
data/lib/black_and_white.rb
CHANGED
@@ -6,7 +6,12 @@ require "black_and_white/active_record/error"
|
|
6
6
|
require "black_and_white/helpers/utils"
|
7
7
|
|
8
8
|
module BlackAndWhite
|
9
|
+
|
9
10
|
def self.create(args = {})
|
10
11
|
ActiveRecord::Test.create(args)
|
11
12
|
end
|
13
|
+
|
14
|
+
def self.add(klass, &block)
|
15
|
+
klass.class_eval(&block)
|
16
|
+
end
|
12
17
|
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.
|
4
|
+
version: 0.1.6
|
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-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|