filter 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  require "filter/condition"
2
2
  require "filter/or"
3
3
  require "filter/and"
4
+ require "filter/not"
4
5
 
5
6
  # == Synopsys
6
7
  # Extension for Ruby <code>Enumerable</code> module
@@ -19,5 +19,10 @@ module Filter
19
19
  Filter.or(self, other)
20
20
  end
21
21
  alias | or
22
+
23
+ def not
24
+ Filter.not(self)
25
+ end
26
+ alias ~ not
22
27
  end
23
28
  end
@@ -0,0 +1,14 @@
1
+ require "filter/condition"
2
+
3
+ module Filter
4
+ class Not < Condition
5
+ def ===(other)
6
+ !super
7
+ end
8
+ end
9
+
10
+ def not(pattern)
11
+ Not.new(pattern)
12
+ end
13
+ module_function :not
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Filter
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -66,5 +66,7 @@ describe Enumerable do
66
66
  # 0 and negative
67
67
  conditions = Filter.and(:zero?, :even?) | proc { |n| n < 0 }
68
68
  [-1, 0, 1].filter(conditions).should == [-1, 0]
69
+
70
+ [1, 2, 3].filter(Filter.not(:odd?)).should == [2]
69
71
  end
70
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &13830380 !ruby/object:Gem::Requirement
16
+ requirement: &25273380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *13830380
24
+ version_requirements: *25273380
25
25
  description: ! "== Synopsys\n<code>Enumerable#filter</code> - extended <code>Enumerable#select</code>\n\n==
26
26
  Examples\nString filter (acts like <code>Enumerable#grep</code>):\n [1, 2, 3, 'ab'].filter(/a/)
27
27
  \ # => ['ab']\n [1, 2, 3, '3'].filter('3') # => ['3']\n\nYou
@@ -60,6 +60,7 @@ files:
60
60
  - lib/filter/matchers/hash.rb
61
61
  - lib/filter/matchers/nil.rb
62
62
  - lib/filter/matchers/symbol.rb
63
+ - lib/filter/not.rb
63
64
  - lib/filter/or.rb
64
65
  - lib/filter/version.rb
65
66
  - spec/filter_spec.rb