match_skeleton 1.0.2 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52a61ea103053eb70d87995bab360db6e7557096
4
- data.tar.gz: 28407978b5f043b2f180e7166da4b67d005ad64f
3
+ metadata.gz: 5871a4eea2d9b69ce70caf1e809c1d692059daec
4
+ data.tar.gz: f370ed11a1ac8b1f8fc8464097671593406188e2
5
5
  SHA512:
6
- metadata.gz: aea87a97397f62d2f4facb609a264c7f5e57720c54fd2d2914d8354566556d4fa7ea88b98fd097d99f93235f518f757be22b06bd9e9762e6779cc21554a74ea7
7
- data.tar.gz: bb95f8a27ea564603d1a5f4438253cd11df97c4c6b28000a420ddcba89c0697790e3b7f391aef2fa7d8bc8cf57cd69c305a378a3c4e621577c6053805230291d
6
+ metadata.gz: 03c3d685b7f040519c54d9dedabe8657281b01e6b27629b66965eee5ef21ba129149e4afd0cc74bb3d4ccb661b19a502f19431a4b15bfd9296ae7c83eb361565
7
+ data.tar.gz: 85fa223207412a249af57f807cb5ae7854d4507d98422a337949adc06b4ced66dd707d09db7b4bfddb13119bf4e51367ccb788a20badccccb0e393c171c5ba72
data/ChangeLog CHANGED
@@ -1,6 +1,12 @@
1
+ -----
2
+ (Version: 1.0.3)
3
+ 2016-05-27 Masa Sakano
4
+ * Fixed a bug in #== for both MatchSkeleton and MatchData in lib/match_skeleton.rb and lib/match_skeleton/match_data.rb that it raises NoMethodErro when a completely different object is given as the argument. test/test_match_skeleton.rb is updated to reflect it.
5
+
1
6
  -----
2
7
  (Version: 1.0.2)
3
8
  2016-05-19 Masa Sakano
9
+
4
10
  * Fixed 2 bugs of (1) values_at (2) nil captures.
5
11
 
6
12
  -----
@@ -14,9 +14,10 @@ class MatchData
14
14
  # @param [#string, #regexp, #pre_match] All the methods have to be there. Practically, {MatchSkeleton} and {MatchData}
15
15
  # @return [Boolean]
16
16
  def ==(obj)
17
- (string == obj.string) &&
18
- (regexp == obj.regexp) &&
19
- (pre_match == obj.pre_match)
17
+ !!((defined?(obj.string) && string == obj.string) &&
18
+ (defined?(obj.regexp) && regexp == obj.regexp) &&
19
+ (defined?(obj.pre_match) && pre_match == obj.pre_match))
20
+ # nb., defined?() can return nil, and then nil (not false) will be returned.
20
21
  end
21
22
 
22
23
  end
@@ -63,9 +63,10 @@ class MatchSkeleton
63
63
  # @return [Boolean]
64
64
  # @see #eql?
65
65
  def ==(obj)
66
- (string == obj.string) &&
67
- (regexp == obj.regexp) &&
68
- (pre_match == obj.pre_match)
66
+ !!((defined?(obj.string) && string == obj.string) &&
67
+ (defined?(obj.regexp) && regexp == obj.regexp) &&
68
+ (defined?(obj.pre_match) && pre_match == obj.pre_match))
69
+ # nb., defined?() can return nil, and then nil (not false) will be returned.
69
70
  end
70
71
 
71
72
  # The same as {MatchData#[]}
@@ -124,11 +124,21 @@ class TestMatchSkeleton < Minitest::Test
124
124
  re1 = /g/
125
125
  pos = 3
126
126
 
127
+ # Equal with self
127
128
  md1 = s.match(re1, pos)
128
129
  ms1 = MatchSkeleton.new(md1, s, pos_begin: pos)
129
130
  assert_equal true, (ms1 == md1)
130
131
  assert_equal true, (md1 == ms1)
132
+ assert_equal true, (ms1.eql?(ms1))
133
+ assert_equal true, (md1.eql?(md1))
131
134
  assert_equal false, (ms1.eql?(md1))
135
+ assert_equal false, (md1.eql?(ms1))
136
+ # NOTE: Do not use assert() but use assert_equal(false, ...) to test,
137
+ # because the result can well be nil, as opposed to false.
138
+
139
+ # Equal with something completely different
140
+ assert_equal false, (md1 == 'random')
141
+ assert_equal false, (ms1 == 'random')
132
142
 
133
143
  # pos_begin does not count.
134
144
  ms1p = ms1.dup
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: match_skeleton
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masa Sakano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-19 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: MatchSkeleton is a class equivalent to MatchData with negligible memory
14
14
  use. As long as the original string is not destructively modified, it behaves almost