toggles 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/toggles/feature.rb +1 -0
- data/lib/toggles/feature/permissions/operation.rb +2 -1
- data/lib/toggles/feature/permissions/operation/and.rb +1 -3
- data/lib/toggles/feature/permissions/operation/{property.rb → attribute.rb} +1 -3
- data/lib/toggles/feature/permissions/operation/not.rb +17 -0
- data/lib/toggles/feature/permissions/operation/or.rb +1 -3
- data/spec/toggles/feature/permissions/operation/and_spec.rb +9 -0
- data/spec/toggles/feature/permissions/operation/attribute_spec.rb +9 -0
- data/spec/toggles/feature/permissions/operation/gt_spec.rb +6 -0
- data/spec/toggles/feature/permissions/operation/in_spec.rb +6 -0
- data/spec/toggles/feature/permissions/operation/lt_spec.rb +6 -0
- data/spec/toggles/feature/permissions/operation/not_spec.rb +6 -0
- data/spec/toggles/feature/permissions/operation/or_spec.rb +6 -0
- data/spec/toggles/feature/permissions/operation/range_spec.rb +5 -0
- data/toggles.gemspec +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51bb6e97c911c1565aeb75d196617d10e71d9903
|
4
|
+
data.tar.gz: dd23e2efe0e2d7973efecc74692e2c87630c799a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2020f4c3044bec0802bc2dc168f1fa2e7f5053e5b90185272cbcf57e968453c4b49968ec948867505bf10b2d8ad75944cc2e78fbe8cac52d47d9e05648488294
|
7
|
+
data.tar.gz: abe63515e325397441f189c63e4261e23769127ed1a8d2994af7b9d0cd34323854edf989e2aad44de28b538da2a0747ba7a01fb996b4c3ef80a4fbcbaaf17e90
|
data/lib/toggles/feature.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require "toggles/feature/permissions/operation/and"
|
2
|
+
require "toggles/feature/permissions/operation/attribute"
|
2
3
|
require "toggles/feature/permissions/operation/gt"
|
3
4
|
require "toggles/feature/permissions/operation/in"
|
4
5
|
require "toggles/feature/permissions/operation/lt"
|
6
|
+
require "toggles/feature/permissions/operation/not"
|
5
7
|
require "toggles/feature/permissions/operation/or"
|
6
|
-
require "toggles/feature/permissions/operation/property"
|
7
8
|
require "toggles/feature/permissions/operation/range"
|
@@ -4,9 +4,7 @@ module Feature
|
|
4
4
|
class And
|
5
5
|
def self.call(entity, attr_name, expected)
|
6
6
|
expected.all? do |operation, value|
|
7
|
-
OPERATIONS
|
8
|
-
entity, attr_name, value
|
9
|
-
)
|
7
|
+
OPERATIONS[operation.to_sym].call(entity, attr_name, value)
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
@@ -5,9 +5,7 @@ module Feature
|
|
5
5
|
def self.call(entity, attr_name, expected)
|
6
6
|
if expected.kind_of? Hash
|
7
7
|
expected.all? do |operation, value|
|
8
|
-
OPERATIONS
|
9
|
-
entity, attr_name, value
|
10
|
-
)
|
8
|
+
OPERATIONS[operation.to_sym].call(entity, attr_name, value)
|
11
9
|
end
|
12
10
|
else
|
13
11
|
entity.send(attr_name) == expected
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Feature
|
2
|
+
class Permissions
|
3
|
+
module Operation
|
4
|
+
class Not
|
5
|
+
def self.call(entity, attr_name, expected)
|
6
|
+
if expected.kind_of? Hash
|
7
|
+
expected.none? do |operation, value|
|
8
|
+
OPERATIONS[operation.to_sym].call(entity, attr_name, value)
|
9
|
+
end
|
10
|
+
else
|
11
|
+
entity.send(attr_name) != expected
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -4,9 +4,7 @@ module Feature
|
|
4
4
|
class Or
|
5
5
|
def self.call(entity, attr_name, expected)
|
6
6
|
expected.any? do |operation, value|
|
7
|
-
OPERATIONS
|
8
|
-
entity, attr_name, value
|
9
|
-
)
|
7
|
+
OPERATIONS[operation.to_sym].call(entity, attr_name, value)
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
describe Feature::Permissions::Operation::Attribute do
|
2
|
+
specify do
|
3
|
+
expect(described_class.call(double(id: 50), :id, 50)).to eq true
|
4
|
+
expect(described_class.call(double(id: 50), :id, 51)).to eq false
|
5
|
+
|
6
|
+
expect(described_class.call(double(id: 50), :id, {"in" => (0..50), "not" => 49})).to eq true
|
7
|
+
expect(described_class.call(double(id: 49), :id, {"in" => (0..50), "not" => 49})).to eq false
|
8
|
+
end
|
9
|
+
end
|
data/toggles.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toggles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Tribone
|
@@ -126,15 +126,24 @@ files:
|
|
126
126
|
- lib/toggles/feature/permissions.rb
|
127
127
|
- lib/toggles/feature/permissions/operation.rb
|
128
128
|
- lib/toggles/feature/permissions/operation/and.rb
|
129
|
+
- lib/toggles/feature/permissions/operation/attribute.rb
|
129
130
|
- lib/toggles/feature/permissions/operation/gt.rb
|
130
131
|
- lib/toggles/feature/permissions/operation/in.rb
|
131
132
|
- lib/toggles/feature/permissions/operation/lt.rb
|
133
|
+
- lib/toggles/feature/permissions/operation/not.rb
|
132
134
|
- lib/toggles/feature/permissions/operation/or.rb
|
133
|
-
- lib/toggles/feature/permissions/operation/property.rb
|
134
135
|
- lib/toggles/feature/permissions/operation/range.rb
|
135
136
|
- lib/toggles/feature/subject.rb
|
136
137
|
- spec/spec_helper.rb
|
137
138
|
- spec/toggles/feature/base_spec.rb
|
139
|
+
- spec/toggles/feature/permissions/operation/and_spec.rb
|
140
|
+
- spec/toggles/feature/permissions/operation/attribute_spec.rb
|
141
|
+
- spec/toggles/feature/permissions/operation/gt_spec.rb
|
142
|
+
- spec/toggles/feature/permissions/operation/in_spec.rb
|
143
|
+
- spec/toggles/feature/permissions/operation/lt_spec.rb
|
144
|
+
- spec/toggles/feature/permissions/operation/not_spec.rb
|
145
|
+
- spec/toggles/feature/permissions/operation/or_spec.rb
|
146
|
+
- spec/toggles/feature/permissions/operation/range_spec.rb
|
138
147
|
- spec/toggles/feature/permissions_spec.rb
|
139
148
|
- spec/toggles/feature/subject_spec.rb
|
140
149
|
- spec/toggles_spec.rb
|
@@ -166,6 +175,14 @@ summary: YAML backed feature toggles
|
|
166
175
|
test_files:
|
167
176
|
- spec/spec_helper.rb
|
168
177
|
- spec/toggles/feature/base_spec.rb
|
178
|
+
- spec/toggles/feature/permissions/operation/and_spec.rb
|
179
|
+
- spec/toggles/feature/permissions/operation/attribute_spec.rb
|
180
|
+
- spec/toggles/feature/permissions/operation/gt_spec.rb
|
181
|
+
- spec/toggles/feature/permissions/operation/in_spec.rb
|
182
|
+
- spec/toggles/feature/permissions/operation/lt_spec.rb
|
183
|
+
- spec/toggles/feature/permissions/operation/not_spec.rb
|
184
|
+
- spec/toggles/feature/permissions/operation/or_spec.rb
|
185
|
+
- spec/toggles/feature/permissions/operation/range_spec.rb
|
169
186
|
- spec/toggles/feature/permissions_spec.rb
|
170
187
|
- spec/toggles/feature/subject_spec.rb
|
171
188
|
- spec/toggles_spec.rb
|