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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1078458dda85cc9f4050925f006b34f2e1ee39b8
4
- data.tar.gz: dacd493ed0495b299a8ee86a0c64caf9801a5592
3
+ metadata.gz: e61dc38eeb1444066269e580c7c3a880b6e15170
4
+ data.tar.gz: a12cac98e62742661db8450e735b7c44636fd370
5
5
  SHA512:
6
- metadata.gz: 8ea5d12b472ae9e4f81d6f921b4839e3f2392bfc5c458529f3b38fed03294ce06dd01cd3a83415217a5ad21a020c2141efc1f593fcfd81c788615ab9c7d13d2f
7
- data.tar.gz: 72cd5e9767b0a2c50be2dcdd12619928470209b38c7fc33cd60038215c960d72ef127e3573d127d9e7e6fd002964176d1f6774012ab0b143b35fef94cdaec2d6
6
+ metadata.gz: 0a3011a4375b955271716f85ec0114d03620a83a598c7f9ac43ad64252d84247775d097833986dcaa125fb32053a8081b6b1c6aa6ddbb791bbe6ce7300a593d4
7
+ data.tar.gz: bc5730e9e3fd06c98319144cdd597244619532e2e314b03b6fa933a2964aedf8bc068c9f0bd2c8947716789638faa7c524ace87e583105cb9aa0a43428042887
data/.travis.yml CHANGED
@@ -2,4 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1.0
4
4
  - 2.1.1
5
- - 2.0.0
5
+ - 2.0.0
6
+ addons:
7
+ code_climate:
8
+ repo_token: dd19314b5df203b54211c7c14ac5f9332d06fec5225a0f9b40b3218514423437
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
@@ -3,5 +3,7 @@ require "sandthorn_event_filter/event"
3
3
  require "sandthorn_event_filter/filter"
4
4
 
5
5
  module SandthornEventFilter
6
- # Your code goes here...
6
+ def self.filter(*args)
7
+ Filter.new(*args)
8
+ end
7
9
  end
@@ -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| matchers.all? { |matcher| matcher.match?(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
@@ -1,3 +1,3 @@
1
1
  module SandthornEventFilter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2.1"
3
3
  end
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.6"
28
28
  spec.add_development_dependency "rake"
29
+ spec.add_development_dependency "codeclimate-test-reporter"
29
30
 
30
31
  spec.add_runtime_dependency "hamster"
31
32
 
@@ -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
- filters = [IdentityMatcher.new, IdentityMatcher.new]
36
- new_chain = chain.add(filters)
37
- filters.each do |filter|
38
- expect(filter).to receive(:match?).exactly(3).times.and_call_original
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
@@ -1,3 +1,11 @@
1
+ if ENV['CODECLIMATE_REPO_TOKEN']
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+ else
5
+ require 'simplecov'
6
+ SimpleCov.start
7
+ end
8
+
1
9
  require 'sandthorn_event_filter'
2
10
  require './spec/data/events'
3
11
 
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-27 00:00:00.000000000 Z
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