toggles 0.0.6 → 0.0.7

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: 31164f56157983183da56700b347bb70a5373058
4
- data.tar.gz: 9b258b42d5b7e8d7fdf95b91ec8c19ddfab5820f
3
+ metadata.gz: 021ee95f3fb8265217d9601170a5217b47660cf6
4
+ data.tar.gz: c91a3c28066e419b87776e39819dea4e1cc96f6f
5
5
  SHA512:
6
- metadata.gz: 2f70ab0bda18fe55346c769b49eafcb1d67a7faf0e73eefbcf86686d8131fdc951ece6caf64f71722ab454211780b0525ab2fe6c2a6fdd781fe1ad87432adcae
7
- data.tar.gz: fda41fa20f04da055008917544349718ca39b24ab6455e644651558f05cbcb5e50e5d85d2af73e8c2e47f33fd3881603e5776e0d6cfda4f979e6cb6f4f39d820
6
+ metadata.gz: 49bfb5d18dfbfdf227129a6503d338b2d919851798975674e097d44c2ff42e4ba06680c559f75a2bade07f5567844aeb04fafcffb59e4b0611a571f36e275987
7
+ data.tar.gz: e0653c4394f6bf883b43894e23df308bf8af04061387db2663a1982ae793a1b98e231b4f3a2bb65ff9fbb1233f66317471d90d40b51dd5c2cfd4b227fa06b1ac
@@ -0,0 +1,4 @@
1
+ user:
2
+ or:
3
+ foo: 20
4
+ bar: 30
@@ -1,9 +1,9 @@
1
1
  require "find"
2
2
 
3
3
  require "toggles/feature/base"
4
- require "toggles/feature/subject"
5
4
  require "toggles/feature/operation"
6
5
  require "toggles/feature/permissions"
6
+ require "toggles/feature/subject"
7
7
 
8
8
  module Feature
9
9
  OPERATIONS = {and: Operation::And,
@@ -3,7 +3,11 @@ module Feature
3
3
  class Or
4
4
  def self.call(entity, attr_name, expected)
5
5
  expected.any? do |operation, value|
6
- OPERATIONS[operation.to_sym].call(entity, attr_name, value)
6
+ if OPERATIONS.include? operation.to_sym
7
+ OPERATIONS[operation.to_sym].call(entity, attr_name, value)
8
+ else
9
+ Operation::Attribute.call(entity, operation, value)
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -30,7 +30,7 @@ module Feature
30
30
  end
31
31
 
32
32
  rule.all? do |key, value|
33
- OPERATIONS.fetch(key, Operation::Attribute).call(entity, key, value)
33
+ OPERATIONS.fetch(key.to_sym, Operation::Attribute).call(entity, key, value)
34
34
  end
35
35
  end
36
36
  end
@@ -0,0 +1,11 @@
1
+ describe Feature::OrAttributes do
2
+ specify do
3
+ expect(Feature::OrAttributes.enabled_for?(
4
+ user: double(foo: 20, bar: 10))).to eq true
5
+ expect(Feature::OrAttributes.enabled_for?(
6
+ user: double(foo: 10, bar: 30))).to eq true
7
+
8
+ expect(Feature::OrAttributes.enabled_for?(
9
+ user: double(foo: 10, bar: 10))).to eq false
10
+ end
11
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "toggles"
3
- s.version = "0.0.6"
3
+ s.version = "0.0.7"
4
4
  s.authors = ["Andrew Tribone"]
5
5
  s.summary = "YAML backed feature toggles"
6
6
  s.email = "tribone@easypost.com"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toggles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Tribone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-22 00:00:00.000000000 Z
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,6 +121,7 @@ files:
121
121
  - features/collection.yml
122
122
  - features/multiple_subjects.yml
123
123
  - features/nested_attributes.yml
124
+ - features/or_attributes.yml
124
125
  - features/type.yml
125
126
  - lib/toggles.rb
126
127
  - lib/toggles/feature.rb
@@ -140,6 +141,7 @@ files:
140
141
  - spec/toggles/feature/acceptance/collection_spec.rb
141
142
  - spec/toggles/feature/acceptance/multiple_subjects_spec.rb
142
143
  - spec/toggles/feature/acceptance/nested_attributes_spec.rb
144
+ - spec/toggles/feature/acceptance/or_attributes_spec.rb
143
145
  - spec/toggles/feature/acceptance/type_spec.rb
144
146
  - spec/toggles/feature/base_spec.rb
145
147
  - spec/toggles/feature/operation/and_spec.rb
@@ -182,6 +184,7 @@ test_files:
182
184
  - spec/toggles/feature/acceptance/collection_spec.rb
183
185
  - spec/toggles/feature/acceptance/multiple_subjects_spec.rb
184
186
  - spec/toggles/feature/acceptance/nested_attributes_spec.rb
187
+ - spec/toggles/feature/acceptance/or_attributes_spec.rb
185
188
  - spec/toggles/feature/acceptance/type_spec.rb
186
189
  - spec/toggles/feature/base_spec.rb
187
190
  - spec/toggles/feature/operation/and_spec.rb