modalsupport 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -6,7 +6,7 @@ class Regexp
6
6
  def match(str, i=0)
7
7
  str = str[i..-1] if i>0
8
8
  m = self.match_old(str)
9
- if block_given?
9
+ if m && block_given?
10
10
  yield m
11
11
  else
12
12
  m
@@ -6,7 +6,7 @@ class String
6
6
  def match(re, i=0)
7
7
  str = i>0 ? self[i..-1] : self
8
8
  m = str.match_old(re)
9
- if block_given?
9
+ if m && block_given?
10
10
  yield m
11
11
  else
12
12
  m
data/modalsupport.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{modalsupport}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Javier Goizueta"]
data/test/test_match.rb CHANGED
@@ -2,11 +2,18 @@ require 'helper'
2
2
 
3
3
  class TestGsub < Test::Unit::TestCase
4
4
 
5
- should "pass match info to a block" do
5
+ should "pass match info to a block and return the block result" do
6
6
  assert_equal "axa", "xxx axa yue asx aya aza".match_one(/a.a/){|match| match.to_s}
7
7
  assert_equal "axa", /a.a/.match_one("xxx axa yue asx aya aza"){|match| match.to_s}
8
8
  end
9
9
 
10
+ should "return nil if no match" do
11
+ assert_equal "axa", "xxx axa yue asx aya aza".match_one(/a.a/){|match| match.to_s}
12
+ assert_equal "axa", /a.a/.match_one("xxx axa yue asx aya aza"){|match| match.to_s}
13
+ assert_nil "xxx axa yue asx aya aza".match_one(/b.b/){|match| match.to_s}
14
+ assert_nil /b.b/.match_one("xxx axa yue asx aya aza"){|match| match.to_s}
15
+ end
16
+
10
17
  should "map all matches to an array" do
11
18
  assert_equal ["axa", "aya", "aza"], "xxx axa yue asx aya aza".match_all(/a.a/){|match| match.to_s}
12
19
  assert_equal ["axa", "aya", "aza"], /a.a/.match_all("xxx axa yue asx aya aza"){|match| match.to_s}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modalsupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Goizueta