flipper-activerecord 0.1.1 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ec2097f8dbc9a98ef38c03221acee5ac110f2ba
4
- data.tar.gz: da9f1e5cabe70e31c723d8e99f3bf86380ff1fb1
3
+ metadata.gz: fd52078ee557c71d42582fa6f0f42c09d4fb27a2
4
+ data.tar.gz: 9f98915938d51a381e89ea8385adf9c734e84172
5
5
  SHA512:
6
- metadata.gz: e1d30fd53b36dde9f18a0ee96a0f77f1c8e4e253765f2a2fc14881c1225ba62a9731d6cbd413b9de0dda210ac89adf151a7b845ccfacd6631f6cc658582d9f96
7
- data.tar.gz: d0160bd0df31d7ef1605186092bde0e207eec478bf019e93ea62cbbc1e74a4da3a08cc16d2069a66d492996bc6fca35084f3552bf479bb968ae8723734b3c14d
6
+ metadata.gz: e9dbe12859ba393e06c46edfd758703a1483ea672a2ba27696d4a473b06c6b322876c2cc5cd44658a52b2ea0caab5f0296109a3bf8d35c8687526daec1201892
7
+ data.tar.gz: 42b9c3b9973e0903b65094b14f3ad9553fdf6fb11a933756fccda1c074983612527f5bc8c2dc9901276e7639f6c6b800c9f373c6fc00a447b4439fa62e89b7a2
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- gem 'flipper', github: "bgentry/flipper"
5
4
  gem 'database_cleaner'
6
5
  gem 'pg'
7
6
  gem 'rake'
@@ -1,33 +1,27 @@
1
- GIT
2
- remote: git://github.com/bgentry/flipper.git
3
- revision: 8f09e1c75db3a926fe12d1f91a8bb869a19d90f1
4
- specs:
5
- flipper (0.6.2)
6
-
7
1
  PATH
8
2
  remote: .
9
3
  specs:
10
- flipper-activerecord (0.1.1)
11
- activerecord (>= 4.2.0.beta2)
4
+ flipper-activerecord (0.1.2)
5
+ activerecord (~> 4.2)
12
6
  flipper (~> 0.6)
13
7
 
14
8
  GEM
15
9
  remote: https://rubygems.org/
16
10
  specs:
17
- activemodel (4.2.0.beta2)
18
- activesupport (= 4.2.0.beta2)
11
+ activemodel (4.2.5.1)
12
+ activesupport (= 4.2.5.1)
19
13
  builder (~> 3.1)
20
- activerecord (4.2.0.beta2)
21
- activemodel (= 4.2.0.beta2)
22
- activesupport (= 4.2.0.beta2)
23
- arel (>= 6.0.0.beta1, < 6.1)
24
- activesupport (4.2.0.beta2)
25
- i18n (>= 0.7.0.beta1, < 0.8)
14
+ activerecord (4.2.5.1)
15
+ activemodel (= 4.2.5.1)
16
+ activesupport (= 4.2.5.1)
17
+ arel (~> 6.0)
18
+ activesupport (4.2.5.1)
19
+ i18n (~> 0.7)
26
20
  json (~> 1.7, >= 1.7.7)
27
21
  minitest (~> 5.1)
28
- thread_safe (~> 0.1)
22
+ thread_safe (~> 0.3, >= 0.3.4)
29
23
  tzinfo (~> 1.1)
30
- arel (6.0.0.beta1)
24
+ arel (6.0.3)
31
25
  builder (3.2.2)
32
26
  celluloid (0.16.0)
33
27
  timers (~> 4.0.0)
@@ -35,6 +29,7 @@ GEM
35
29
  database_cleaner (1.3.0)
36
30
  diff-lcs (1.2.5)
37
31
  ffi (1.9.5)
32
+ flipper (0.7.4)
38
33
  formatador (0.2.5)
39
34
  guard (2.6.1)
40
35
  formatador (>= 0.2.4)
@@ -49,15 +44,15 @@ GEM
49
44
  guard (~> 2.1)
50
45
  rspec (>= 2.14, < 4.0)
51
46
  hitimes (1.2.2)
52
- i18n (0.7.0.beta1)
53
- json (1.8.1)
47
+ i18n (0.7.0)
48
+ json (1.8.3)
54
49
  listen (2.7.11)
55
50
  celluloid (>= 0.15.2)
56
51
  rb-fsevent (>= 0.9.3)
57
52
  rb-inotify (>= 0.9)
58
53
  lumberjack (1.0.9)
59
54
  method_source (0.8.2)
60
- minitest (5.4.2)
55
+ minitest (5.8.4)
61
56
  pg (0.17.1)
62
57
  pry (0.10.1)
63
58
  coderay (~> 1.1.0)
@@ -81,7 +76,7 @@ GEM
81
76
  rspec-support (3.1.1)
82
77
  slop (3.6.0)
83
78
  thor (0.19.1)
84
- thread_safe (0.3.4)
79
+ thread_safe (0.3.5)
85
80
  timecop (0.7.1)
86
81
  timers (4.0.1)
87
82
  hitimes
@@ -93,7 +88,6 @@ PLATFORMS
93
88
 
94
89
  DEPENDENCIES
95
90
  database_cleaner
96
- flipper!
97
91
  flipper-activerecord!
98
92
  guard
99
93
  guard-bundler
@@ -103,3 +97,6 @@ DEPENDENCIES
103
97
  rb-fsevent
104
98
  rspec
105
99
  timecop
100
+
101
+ BUNDLED WITH
102
+ 1.11.2
@@ -0,0 +1,178 @@
1
+ # Flipper ActiveRecord
2
+
3
+ An [ActiveRecord](https://github.com/rails/rails/tree/master/activerecord) adapter for [Flipper](https://github.com/jnunemaker/flipper).
4
+
5
+ Currently, this targets Rails 4.2 because it uses real foreign keys via
6
+ `add_foreign_key` and `remove_foreign_key`.
7
+
8
+ For users requiring Rails 3.2 support, please see: [Flipper ActiveRecord 3.2](https://github.com/blueboxjesse/flipper-activerecord).
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'flipper-activerecord'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself with:
21
+
22
+ $ gem install flipper-activerecord
23
+
24
+ Generate a migration to create the required database tables:
25
+
26
+ $ rails g flipper:active_record
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ require 'flipper/adapters/activerecord'
32
+ adapter = Flipper::Adapters::ActiveRecord.new
33
+ flipper = Flipper.new(adapter)
34
+ # profit...
35
+ ```
36
+
37
+ ## Internals
38
+
39
+ Two database tables are used: `flipper_features` and `flipper_gates`.
40
+
41
+ A list of all available features is stored in the `flipper_features` table:
42
+
43
+ ```ruby
44
+ require 'flipper/adapters/activerecord'
45
+
46
+ adapter = Flipper::Adapters::ActiveRecord.new
47
+ flipper = Flipper.new(adapter)
48
+
49
+ # Register a few groups.
50
+ Flipper.register(:admins) { |thing| thing.admin? }
51
+ Flipper.register(:early_access) { |thing| thing.early_access? }
52
+
53
+ # Create a user class that has flipper_id instance method.
54
+ User = Struct.new(:flipper_id)
55
+
56
+ flipper[:stats].enable
57
+ flipper[:stats].enable flipper.group(:admins)
58
+ flipper[:stats].enable User.new('25')
59
+ flipper[:stats].enable User.new('90')
60
+ flipper[:stats].enable User.new('180')
61
+ flipper[:stats].enable flipper.random(15)
62
+ flipper[:stats].enable flipper.actors(45)
63
+
64
+ flipper[:awesomeness].enable
65
+ flipper[:awesomeness].enable flipper.group(:admins)
66
+
67
+
68
+ print 'all features: '
69
+ pp Flipper::ActiveRecord::Feature.all
70
+ # Flipper::ActiveRecord::Feature Load (0.3ms) SELECT "flipper_features".* FROM "flipper_features"
71
+ # [#<Flipper::ActiveRecord::Feature:0x007fa883c6b578
72
+ # id: 1,
73
+ # name: "stats",
74
+ # created_at: Wed, 08 Oct 2014 07:21:27 UTC +00:00,
75
+ # updated_at: Wed, 08 Oct 2014 07:21:27 UTC +00:00>,
76
+ # #<Flipper::ActiveRecord::Feature:0x007fa883c6ada8
77
+ # id: 2,
78
+ # name: "awesomeness",
79
+ # created_at: Wed, 08 Oct 2014 07:21:38 UTC +00:00,
80
+ # updated_at: Wed, 08 Oct 2014 07:21:38 UTC +00:00>]
81
+
82
+ print 'all gates: '
83
+ pp Flipper::ActiveRecord::Gate.all
84
+ # Flipper::ActiveRecord::Gate Load (0.4ms) SELECT "flipper_gates".* FROM "flipper_gates"
85
+ # [#<Flipper::ActiveRecord::Gate:0x007fa883c42ab0
86
+ # id: 1,
87
+ # flipper_feature_id: 1,
88
+ # name: "boolean",
89
+ # value: "true",
90
+ # created_at: Wed, 08 Oct 2014 07:21:27 UTC +00:00,
91
+ # updated_at: Wed, 08 Oct 2014 07:21:27 UTC +00:00>,
92
+ # #<Flipper::ActiveRecord::Gate:0x007fa883c42290
93
+ # id: 2,
94
+ # flipper_feature_id: 1,
95
+ # name: "groups",
96
+ # value: "admins",
97
+ # created_at: Wed, 08 Oct 2014 07:21:31 UTC +00:00,
98
+ # updated_at: Wed, 08 Oct 2014 07:21:31 UTC +00:00>,
99
+ # #<Flipper::ActiveRecord::Gate:0x007fa883c41b10
100
+ # id: 3,
101
+ # flipper_feature_id: 1,
102
+ # name: "actors",
103
+ # value: "25",
104
+ # created_at: Wed, 08 Oct 2014 07:21:31 UTC +00:00,
105
+ # updated_at: Wed, 08 Oct 2014 07:21:31 UTC +00:00>,
106
+ # #<Flipper::ActiveRecord::Gate:0x007fa883c41408
107
+ # id: 4,
108
+ # flipper_feature_id: 1,
109
+ # name: "actors",
110
+ # value: "90",
111
+ # created_at: Wed, 08 Oct 2014 07:21:31 UTC +00:00,
112
+ # updated_at: Wed, 08 Oct 2014 07:21:31 UTC +00:00>,
113
+ # #<Flipper::ActiveRecord::Gate:0x007fa883c40c38
114
+ # id: 5,
115
+ # flipper_feature_id: 1,
116
+ # name: "actors",
117
+ # value: "180",
118
+ # created_at: Wed, 08 Oct 2014 07:21:31 UTC +00:00,
119
+ # updated_at: Wed, 08 Oct 2014 07:21:31 UTC +00:00>,
120
+ # #<Flipper::ActiveRecord::Gate:0x007fa883c40558
121
+ # id: 6,
122
+ # flipper_feature_id: 1,
123
+ # name: "percentage_of_random",
124
+ # value: "15",
125
+ # created_at: Wed, 08 Oct 2014 07:21:38 UTC +00:00,
126
+ # updated_at: Wed, 08 Oct 2014 07:21:38 UTC +00:00>,
127
+ # #<Flipper::ActiveRecord::Gate:0x007fa883c3bda0
128
+ # id: 7,
129
+ # flipper_feature_id: 1,
130
+ # name: "percentage_of_actors",
131
+ # value: "45",
132
+ # created_at: Wed, 08 Oct 2014 07:21:38 UTC +00:00,
133
+ # updated_at: Wed, 08 Oct 2014 07:21:38 UTC +00:00>,
134
+ # #<Flipper::ActiveRecord::Gate:0x007fa883c3b5f8
135
+ # id: 8,
136
+ # flipper_feature_id: 2,
137
+ # name: "boolean",
138
+ # value: "true",
139
+ # created_at: Wed, 08 Oct 2014 07:21:38 UTC +00:00,
140
+ # updated_at: Wed, 08 Oct 2014 07:21:38 UTC +00:00>,
141
+ # #<Flipper::ActiveRecord::Gate:0x007fa883c3afe0
142
+ # id: 9,
143
+ # flipper_feature_id: 2,
144
+ # name: "groups",
145
+ # value: "admins",
146
+ # created_at: Wed, 08 Oct 2014 07:21:39 UTC +00:00,
147
+ # updated_at: Wed, 08 Oct 2014 07:21:39 UTC +00:00>]
148
+
149
+ puts 'flipper get of feature'
150
+ pp adapter.get(flipper[:stats])
151
+ # flipper get of feature
152
+ # SQL (0.6ms) SELECT DISTINCT "flipper_features"."id" FROM "flipper_features" LEFT OUTER JOIN "flipper_gates" ON "flipper_gates"."flipper_feature_id" = "flipper_features"."id" WHERE "flipper_features"."name" = $1 LIMIT 1 [["name", "stats"]]
153
+ # SQL (0.3ms) SELECT "flipper_features"."id" AS t0_r0, "flipper_features"."name" AS t0_r1, "flipper_features"."created_at" AS t0_r2, "flipper_features"."updated_at" AS t0_r3, "flipper_gates"."id" AS t1_r0, "flipper_gates"."flipper_feature_id" AS t1_r1, "flipper_gates"."name" AS t1_r2, "flipper_gates"."value" AS t1_r3, "flipper_gates"."created_at" AS t1_r4, "flipper_gates"."updated_at" AS t1_r5 FROM "flipper_features" LEFT OUTER JOIN "flipper_gates" ON "flipper_gates"."flipper_feature_id" = "flipper_features"."id" WHERE "flipper_features"."name" = $1 AND "flipper_features"."id" IN (1) [["name", "stats"]]
154
+ # {:boolean=>"true",
155
+ # :groups=>#<Set: {"admins"}>,
156
+ # :actors=>#<Set: {"25", "90", "180"}>,
157
+ # :percentage_of_actors=>"45",
158
+ # :percentage_of_random=>"15"}
159
+ ```
160
+
161
+ ## Testing
162
+
163
+ ```
164
+ dbcreate flipper_activerecord_test
165
+ rspec
166
+ ```
167
+
168
+ ## Contributing
169
+
170
+ 1. Fork it
171
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
172
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
173
+ 4. Push to the branch (`git push origin my-new-feature`)
174
+ 5. Create new Pull Request
175
+
176
+ ## Thanks
177
+
178
+ Thanks to John Nunemaker for making Flipper and its adapters!
@@ -16,5 +16,5 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
17
 
18
18
  gem.add_dependency 'flipper', '~> 0.6'
19
- gem.add_dependency 'activerecord', '>= 4.2.0.beta2'
19
+ gem.add_dependency 'activerecord', '~> 4.2'
20
20
  end
@@ -1,7 +1,7 @@
1
1
  module Flipper
2
2
  module Adapters
3
3
  class ActiveRecord
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper-activerecord
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
  - Blake Gentry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2016-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flipper
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.0.beta2
33
+ version: '4.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.0.beta2
40
+ version: '4.2'
41
41
  description: ActiveRecord adapter for Flipper
42
42
  email:
43
43
  - blakesgentry@gmail.com
@@ -50,6 +50,7 @@ files:
50
50
  - Gemfile.lock
51
51
  - Guardfile
52
52
  - LICENSE
53
+ - README.md
53
54
  - flipper-activerecord.gemspec
54
55
  - lib/flipper-activerecord.rb
55
56
  - lib/flipper/activerecord/feature.rb
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  version: '0'
82
83
  requirements: []
83
84
  rubyforge_project:
84
- rubygems_version: 2.2.2
85
+ rubygems_version: 2.4.5.1
85
86
  signing_key:
86
87
  specification_version: 4
87
88
  summary: ActiveRecord adapter for Flipper