black_and_white 0.1.5 → 0.1.6

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: 579a1f71214e978a74e7a8f43c02cb3220c33fe0
4
- data.tar.gz: 422a80af8edca9d2168bd2dc0a324639618bf2c9
3
+ metadata.gz: 8e779b2341b287d09338e106253de2fd2a804ab6
4
+ data.tar.gz: 793d5a54c18cea751353123b16f818a8ff5b8812
5
5
  SHA512:
6
- metadata.gz: 6fdd44ff52bcde3a8247bca43ccbc75bbaaf855d7565a28a6ece023f8f8e1c5c1b2d425db98e0ea6e914228b9f9de4ac1d9e2931b8afaac15d9584bb3386a534
7
- data.tar.gz: 7642b27356e3a2664c028a99fe3ac8edef07dc8ef81a976332c7ac38f7fcf324c49d7046d12c98b990fda923772b6aa6abce5c6afde512c8e898859be214837d
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.5'
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?(::Rails) && ::Rails.version.start_with?('5')
48
+ if defined?(Rails) && Rails.version.start_with?('5')
49
49
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
50
50
  end
51
51
  end
@@ -1,3 +1,3 @@
1
1
  module BlackAndWhite
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -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.5
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-23 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler