mug 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mug.rb CHANGED
@@ -12,6 +12,7 @@ require_relative 'mug/iterator/for'
12
12
  require_relative 'mug/iterator/method'
13
13
  require_relative 'mug/loop-with'
14
14
  require_relative 'mug/maybe'
15
+ require_relative 'mug/rexproc'
15
16
  require_relative 'mug/self'
16
17
  require_relative 'mug/tau'
17
18
  require_relative 'mug/to_h'
@@ -0,0 +1,26 @@
1
+
2
+ class Regexp
3
+ #
4
+ # Matches the regexp against the parameter object.
5
+ #
6
+ def to_proc
7
+ lambda {|s| self =~ s }
8
+ end
9
+ end
10
+
11
+ =begin
12
+ Copyright (c) 2014, Matthew Kerwin <matthew@kerwin.net.au>
13
+
14
+ Permission to use, copy, modify, and/or distribute this software for any
15
+ purpose with or without fee is hereby granted, provided that the above
16
+ copyright notice and this permission notice appear in all copies.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
19
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
20
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
21
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
23
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
24
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
+ =end
26
+
@@ -0,0 +1,12 @@
1
+ require 'test/unit'
2
+ $VERBOSE = true
3
+
4
+ require_relative '../lib/mug/rexproc'
5
+ class Test_rexproc < Test::Unit::TestCase
6
+ def test_rexproc
7
+ a = %w[foo bar baz]
8
+ assert_equal( %w[bar baz], a.select(&/\Ab/) )
9
+ assert_equal( %w[foo], a.reject(&/\Ab/) )
10
+ assert_equal( %[bar], a.find( &/\Ab/) )
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-15 00:00:00.000000000 Z
12
+ date: 2014-12-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! '== MUG: Matty''s Ultimate Gem
15
15
 
@@ -34,6 +34,7 @@ files:
34
34
  - lib/mug/bool.rb
35
35
  - lib/mug/iterator/for.rb
36
36
  - lib/mug/iterator/method.rb
37
+ - lib/mug/rexproc.rb
37
38
  - lib/mug/hash.rb
38
39
  - lib/mug/maybe.rb
39
40
  - lib/mug/clamp.rb
@@ -61,6 +62,7 @@ files:
61
62
  - test/test-top.rb
62
63
  - test/test-loop-with.rb
63
64
  - test/test-to_h.rb
65
+ - test/test-rexproc.rb
64
66
  - test/test-array-extend.rb
65
67
  - test/test-self.rb
66
68
  - test/test-iterator-method.rb
@@ -104,6 +106,7 @@ test_files:
104
106
  - test/test-top.rb
105
107
  - test/test-loop-with.rb
106
108
  - test/test-to_h.rb
109
+ - test/test-rexproc.rb
107
110
  - test/test-array-extend.rb
108
111
  - test/test-self.rb
109
112
  - test/test-iterator-method.rb