rubysl-abbrev 1.0.1 → 2.0.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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/lib/rubysl/abbrev/abbrev.rb +14 -15
- data/lib/rubysl/abbrev/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4e081d53efd8147b3ac2af9d865f692bfc7d86a
|
4
|
+
data.tar.gz: b1dbd05583d382564bf32f8f237d54c7999aae60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174cb0b14cc4fee25787c4d7f878dc4c206ef7a13a96529d500f9d70887cbc783b6c946463d217d1e113cd344561ef32686afccb0687c2cd960ae800de8c9a43
|
7
|
+
data.tar.gz: a05356117a5b408c7d312de7d83da3d93eed80aed0fc79e65bec3cbd0e578a050a44c7f08b797edde5684bc3151acdb8ae474a2652495494a76f1d149df1aac5
|
data/.travis.yml
CHANGED
data/lib/rubysl/abbrev/abbrev.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
#
|
2
|
+
#--
|
4
3
|
# Copyright (c) 2001,2003 Akinori MUSHA <knu@iDaemons.org>
|
5
4
|
#
|
6
5
|
# All rights reserved. You can redistribute and/or modify it under
|
@@ -8,8 +7,8 @@
|
|
8
7
|
#
|
9
8
|
# $Idaemons: /home/cvs/rb/abbrev.rb,v 1.2 2001/05/30 09:37:45 knu Exp $
|
10
9
|
# $RoughId: abbrev.rb,v 1.4 2003/10/14 19:45:42 knu Exp $
|
11
|
-
# $Id: abbrev.rb
|
12
|
-
|
10
|
+
# $Id: abbrev.rb 31635 2011-05-18 21:19:18Z drbrain $
|
11
|
+
#++
|
13
12
|
|
14
13
|
# Calculate the set of unique abbreviations for a given set of strings.
|
15
14
|
#
|
@@ -46,24 +45,24 @@ module Abbrev
|
|
46
45
|
seen = Hash.new(0)
|
47
46
|
|
48
47
|
if pattern.is_a?(String)
|
49
|
-
pattern = /^#{Regexp.quote(pattern)}/
|
48
|
+
pattern = /^#{Regexp.quote(pattern)}/ # regard as a prefix
|
50
49
|
end
|
51
50
|
|
52
51
|
words.each do |word|
|
53
52
|
next if (abbrev = word).empty?
|
54
53
|
while (len = abbrev.rindex(/[\w\W]\z/)) > 0
|
55
|
-
|
54
|
+
abbrev = word[0,len]
|
56
55
|
|
57
|
-
|
56
|
+
next if pattern && pattern !~ abbrev
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
58
|
+
case seen[abbrev] += 1
|
59
|
+
when 1
|
60
|
+
table[abbrev] = word
|
61
|
+
when 2
|
62
|
+
table.delete(abbrev)
|
63
|
+
else
|
64
|
+
break
|
65
|
+
end
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|