sandthorn_event_filter 0.0.1 → 0.0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/Gemfile.lock +11 -1
- data/lib/sandthorn_event_filter.rb +3 -1
- data/lib/sandthorn_event_filter/filter.rb +1 -4
- data/lib/sandthorn_event_filter/matchers/matcher_collection.rb +6 -1
- data/lib/sandthorn_event_filter/version.rb +1 -1
- data/sandthorn_event_filter.gemspec +1 -0
- data/spec/matchers/matcher_collection_spec.rb +22 -4
- data/spec/spec_helper.rb +8 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e61dc38eeb1444066269e580c7c3a880b6e15170
|
4
|
+
data.tar.gz: a12cac98e62742661db8450e735b7c44636fd370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a3011a4375b955271716f85ec0114d03620a83a598c7f9ac43ad64252d84247775d097833986dcaa125fb32053a8081b6b1c6aa6ddbb791bbe6ce7300a593d4
|
7
|
+
data.tar.gz: bc5730e9e3fd06c98319144cdd597244619532e2e314b03b6fa933a2964aedf8bc068c9f0bd2c8947716789638faa7c524ace87e583105cb9aa0a43428042887
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sandthorn_event_filter (0.0.1)
|
4
|
+
sandthorn_event_filter (0.0.2.1)
|
5
5
|
hamster
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
autotest-standalone (4.5.11)
|
11
|
+
codeclimate-test-reporter (0.4.0)
|
12
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
11
13
|
coderay (1.1.0)
|
12
14
|
diff-lcs (1.2.5)
|
15
|
+
docile (1.1.5)
|
13
16
|
dotenv (0.11.1)
|
14
17
|
dotenv-deployment (~> 0.0.2)
|
15
18
|
dotenv-deployment (0.0.2)
|
16
19
|
gem-release (0.7.3)
|
17
20
|
hamster (0.4.3)
|
18
21
|
method_source (0.8.2)
|
22
|
+
multi_json (1.10.1)
|
19
23
|
pry (0.10.0)
|
20
24
|
coderay (~> 1.1.0)
|
21
25
|
method_source (~> 0.8.1)
|
@@ -33,6 +37,11 @@ GEM
|
|
33
37
|
rspec-mocks (3.0.3)
|
34
38
|
rspec-support (~> 3.0.0)
|
35
39
|
rspec-support (3.0.3)
|
40
|
+
simplecov (0.9.0)
|
41
|
+
docile (~> 1.1.0)
|
42
|
+
multi_json
|
43
|
+
simplecov-html (~> 0.8.0)
|
44
|
+
simplecov-html (0.8.0)
|
36
45
|
slop (3.6.0)
|
37
46
|
|
38
47
|
PLATFORMS
|
@@ -41,6 +50,7 @@ PLATFORMS
|
|
41
50
|
DEPENDENCIES
|
42
51
|
autotest-standalone
|
43
52
|
bundler (~> 1.6)
|
53
|
+
codeclimate-test-reporter
|
44
54
|
dotenv
|
45
55
|
gem-release
|
46
56
|
pry
|
@@ -26,6 +26,7 @@ module SandthornEventFilter
|
|
26
26
|
include Enumerable
|
27
27
|
|
28
28
|
def_delegators :events, :each, :last, :length, :empty?, :[]
|
29
|
+
def_delegators :matchers, :apply, :match?
|
29
30
|
|
30
31
|
attr_reader :matchers, :original_events
|
31
32
|
|
@@ -69,9 +70,5 @@ module SandthornEventFilter
|
|
69
70
|
self.class.new(original_events, new_matchers)
|
70
71
|
end
|
71
72
|
|
72
|
-
def apply(events)
|
73
|
-
@matchers.apply(events)
|
74
|
-
end
|
75
|
-
|
76
73
|
end
|
77
74
|
end
|
@@ -16,7 +16,7 @@ module SandthornEventFilter
|
|
16
16
|
|
17
17
|
# Returns all events that match all of the matchers in the collection
|
18
18
|
def apply(events)
|
19
|
-
events.select { |event|
|
19
|
+
events.select { |event| match?(event) }
|
20
20
|
end
|
21
21
|
|
22
22
|
# Returns a new instance of MatcherCollection, with the new matchers added.
|
@@ -31,6 +31,11 @@ module SandthornEventFilter
|
|
31
31
|
self.class.new(matchers)
|
32
32
|
end
|
33
33
|
|
34
|
+
# Returns true if all matchers match the given event
|
35
|
+
def match?(event)
|
36
|
+
matchers.all? { |matcher| matcher.match?(event) }
|
37
|
+
end
|
38
|
+
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
@@ -32,16 +32,34 @@ module SandthornEventFilter
|
|
32
32
|
|
33
33
|
context "when there are matchers" do
|
34
34
|
it "should call match? on the matchers for each event" do
|
35
|
-
|
36
|
-
new_chain = chain.add(
|
37
|
-
|
38
|
-
expect(
|
35
|
+
matchers = [IdentityMatcher.new, IdentityMatcher.new]
|
36
|
+
new_chain = chain.add(matchers)
|
37
|
+
matchers.each do |matcher|
|
38
|
+
expect(matcher).to receive(:match?).exactly(3).times.and_call_original
|
39
39
|
end
|
40
40
|
new_chain.apply(events)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
describe ".match?" do
|
46
|
+
context "when all the matchers match" do
|
47
|
+
it "returns true" do
|
48
|
+
filters = [IdentityMatcher.new, IdentityMatcher.new]
|
49
|
+
new_chain = chain.add(filters)
|
50
|
+
expect(new_chain.match?({foo: :bar})).to be_truthy
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when one matchers doesn't match" do
|
55
|
+
it "returns false" do
|
56
|
+
filters = [IdentityMatcher.new, NotMatcher.new(IdentityMatcher.new)]
|
57
|
+
new_chain = chain.add(filters)
|
58
|
+
expect(new_chain.match?({foo: :bar})).to be_falsey
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
45
63
|
end
|
46
64
|
end
|
47
65
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandthorn_event_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesper Josefsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: codeclimate-test-reporter
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: hamster
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|