context-filters 0.9.0 → 0.9.1
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/lib/context-filters/filters.rb +2 -2
- data/lib/context-filters/version.rb +1 -1
- data/test/context-filters/global_context_test.rb +19 -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: dbd686f4da29b6833e989c2fbf4511bf23d99c2b
|
4
|
+
data.tar.gz: ed9ca9da7754db99621a9e12737b6f593107ab11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b253abc8dfbd195feb542a6441d0ab977aff2e7b1de80aa0152158de59218525438078280496a979231e479713779d0d28d015b3299288cf1a3387d1f1a995d
|
7
|
+
data.tar.gz: e91836fa6d5a557b96b019769ddacf8b9030942c9766f24ce5cf9ec619c2dd5038c403af9110f0c3f376062c673930e678050a2a517fb1aef3de10f71ae026b2
|
@@ -63,8 +63,8 @@ class ContextFilters::Filters
|
|
63
63
|
# @param options [Object] a filter for selecting matching blocks
|
64
64
|
def select_filters(target, options)
|
65
65
|
found = @filters.fetch(options, [])
|
66
|
-
if Hash === options
|
67
|
-
then found += @filters.fetch(options.merge(:target => target), [])
|
66
|
+
if Hash === options || options.nil?
|
67
|
+
then found += @filters.fetch((options||{}).merge(:target => target), [])
|
68
68
|
end
|
69
69
|
found
|
70
70
|
end
|
@@ -49,6 +49,25 @@ describe ContextFilters::GlobalContext do
|
|
49
49
|
subject.evaluate_filters(filter_test_subject, :change)
|
50
50
|
end
|
51
51
|
|
52
|
+
it "does apply targeted filters in top context" do
|
53
|
+
addition = Proc.new { |value| value+1 }
|
54
|
+
multiplication = Proc.new { |value| value*3 }
|
55
|
+
subject.filter(nil, {:target => filter_test_subject}, &addition)
|
56
|
+
subject.filter(nil, {:target => nil}, &multiplication)
|
57
|
+
subject.evaluate_filters(filter_test_subject, :change)
|
58
|
+
filter_test_subject.value.must_equal(4)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "does apply targeted filters in sub context" do
|
62
|
+
addition = Proc.new { |value| value+1 }
|
63
|
+
multiplication = Proc.new { |value| value*3 }
|
64
|
+
subject.context << { :a => 1 }
|
65
|
+
subject.filter(nil, {:a => 1, :target => filter_test_subject}, &addition)
|
66
|
+
subject.filter(nil, {:a => 1, :target => nil}, &multiplication)
|
67
|
+
subject.evaluate_filters(filter_test_subject, :change)
|
68
|
+
filter_test_subject.value.must_equal(4)
|
69
|
+
end
|
70
|
+
|
52
71
|
end #evaluate_command
|
53
72
|
|
54
73
|
describe "#group" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: context-filters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Papis
|
@@ -145,6 +145,6 @@ test_files:
|
|
145
145
|
- test/context-filters/priority_filters_test.rb
|
146
146
|
- test/context-filters/local_context_test.rb
|
147
147
|
- test/context-filters/context_test.rb
|
148
|
-
- test/context-filters/global_context_test.rb
|
149
148
|
- test/context-filters/filters_test.rb
|
149
|
+
- test/context-filters/global_context_test.rb
|
150
150
|
has_rdoc:
|