context-filters 0.9.0 → 0.9.1

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: a378eabd84a4a77fffc09011562666ec496ab827
4
- data.tar.gz: 3c63a922769d75d58efd77748888a45520b72dc5
3
+ metadata.gz: dbd686f4da29b6833e989c2fbf4511bf23d99c2b
4
+ data.tar.gz: ed9ca9da7754db99621a9e12737b6f593107ab11
5
5
  SHA512:
6
- metadata.gz: e0b7a8bc527aeca7a99e7fc0f6fd8cbb9a086cd3e06d07ede4f3003bd8fc08ac5b7853a88d13e90f96ac0f0fc659ff5f9fe1efd0e4e11a55a99946407479a034
7
- data.tar.gz: 12184765863f24c3f73885d8ec33457d1d7f379649b3843d81d487da9aaf8b79de95718d054b1acd1c9cd4122d8de01be02b9c528a1dbbdd76112742cbe1fc42
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
@@ -1,5 +1,5 @@
1
1
  # Build command text based on multiple filters
2
2
  class ContextFilters
3
3
  # version of the context-filters gem
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.1"
5
5
  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.0
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: