Hello community, here is the log from the commit of package rubygem-text for openSUSE:Factory checked in at 2015-04-15 16:24:17 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-text (Old) and /work/SRC/openSUSE:Factory/.rubygem-text.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-text" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-text/rubygem-text.changes 2015-02-11 16:45:43.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-text.new/rubygem-text.changes 2015-04-15 16:24:18.000000000 +0200 @@ -1,0 +2,5 @@ +Tue Apr 14 04:31:32 UTC 2015 - co...@suse.com + +- updated to version 1.3.1 + +------------------------------------------------------------------- Old: ---- text-1.3.0.gem New: ---- text-1.3.1.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-text.spec ++++++ --- /var/tmp/diff_new_pack.tvF5l3/_old 2015-04-15 16:24:18.000000000 +0200 +++ /var/tmp/diff_new_pack.tvF5l3/_new 2015-04-15 16:24:18.000000000 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-text -Version: 1.3.0 +Version: 1.3.1 Release: 0 %define mod_name text %define mod_full_name %{mod_name}-%{version} ++++++ text-1.3.0.gem -> text-1.3.1.gem ++++++ Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/text/levenshtein.rb new/lib/text/levenshtein.rb --- old/lib/text/levenshtein.rb 2014-06-24 00:05:44.000000000 +0200 +++ new/lib/text/levenshtein.rb 2015-04-13 16:54:51.000000000 +0200 @@ -36,14 +36,15 @@ private def distance_with_maximum(str1, str2, max_distance) # :nodoc: - s, t = [str1, str2].sort_by(&:length). - map{ |str| str.encode(Encoding::UTF_8).unpack("U*") } + s = str1.encode(Encoding::UTF_8).unpack("U*") + t = str2.encode(Encoding::UTF_8).unpack("U*") + n = s.length m = t.length big_int = n * m - return m if n.zero? - return n if m.zero? - return 0 if s == t + + # Swap if necessary so that s is always the shorter of the two strings + s, t, n, m = t, s, m, n if m < n # If the length difference is already greater than the max_distance, then # there is nothing else to check @@ -51,6 +52,10 @@ return max_distance end + return 0 if s == t + return m if n.zero? + return n if m.zero? + # The values necessary for our threshold are written; the ones after must # be filled with large integers since the tailing member of the threshold # window in the bottom array will run min across them @@ -84,10 +89,12 @@ # computer science and computational biology. # Cambridge, UK: Cambridge University Press. ISBN 0-521-58519-8. # pp. 263–264. - min = [0, i - max_distance - 1].max - max = [m - 1, i + max_distance].min + min = i - max_distance - 1 + min = 0 if min < 0 + max = i + max_distance + max = m - 1 if max > m - 1 - (min .. max).each do |j| + min.upto(max) do |j| # If the diagonal value is already greater than the max_distance # then we can safety return: the diagonal will never go lower again. # See: http://www.levenshtein.net/ @@ -96,11 +103,11 @@ end cost = s[i] == t[j] ? 0 : 1 - x = [ - d[j+1] + 1, # insertion - e + 1, # deletion - d[j] + cost # substitution - ].min + insertion = d[j + 1] + 1 + deletion = e + 1 + substitution = d[j] + cost + x = insertion < deletion ? insertion : deletion + x = substitution if substitution < x d[j] = e e = x @@ -116,9 +123,12 @@ end def distance_without_maximum(str1, str2) # :nodoc: - s, t = [str1, str2].map{ |str| str.encode(Encoding::UTF_8).unpack("U*") } + s = str1.encode(Encoding::UTF_8).unpack("U*") + t = str2.encode(Encoding::UTF_8).unpack("U*") + n = s.length m = t.length + return m if n.zero? return n if m.zero? @@ -128,12 +138,13 @@ n.times do |i| e = i + 1 m.times do |j| - cost = (s[i] == t[j]) ? 0 : 1 - x = [ - d[j+1] + 1, # insertion - e + 1, # deletion - d[j] + cost # substitution - ].min + cost = s[i] == t[j] ? 0 : 1 + insertion = d[j + 1] + 1 + deletion = e + 1 + substitution = d[j] + cost + x = insertion < deletion ? insertion : deletion + x = substitution if substitution < x + d[j] = e e = x end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/text/version.rb new/lib/text/version.rb --- old/lib/text/version.rb 2014-06-24 00:05:44.000000000 +0200 +++ new/lib/text/version.rb 2015-04-13 16:54:51.000000000 +0200 @@ -2,7 +2,7 @@ module VERSION #:nodoc: MAJOR = 1 MINOR = 3 - TINY = 0 + TINY = 1 STRING = [MAJOR, MINOR, TINY].join('.') end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2014-06-24 00:05:44.000000000 +0200 +++ new/metadata 2015-04-13 16:54:51.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: text version: !ruby/object:Gem::Version - version: 1.3.0 + version: 1.3.1 platform: ruby authors: - Paul Battley @@ -10,7 +10,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2014-06-23 00:00:00.000000000 Z +date: 2015-04-13 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake @@ -80,7 +80,7 @@ version: '0' requirements: [] rubyforge_project: text -rubygems_version: 2.2.2 +rubygems_version: 2.4.5 signing_key: specification_version: 4 summary: A collection of text algorithms diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/levenshtein_test.rb new/test/levenshtein_test.rb --- old/test/levenshtein_test.rb 2014-06-24 00:05:44.000000000 +0200 +++ new/test/levenshtein_test.rb 2015-04-13 16:54:51.000000000 +0200 @@ -48,6 +48,12 @@ assert_equal 3, distance("kitten", "sitting", 4) end + def test_should_return_calculated_distance_when_less_than_maximum_for_empty_strings + assert_equal 3, distance("", "cat", 4) + assert_equal 3, distance("cat", "", 5) + assert_equal 0, distance("", "", 2) + end + def test_should_return_calculated_distance_when_same_as_maximum assert_equal 0, distance("test", "test", 0) assert_equal 1, distance("test", "tent", 1) @@ -55,12 +61,23 @@ assert_equal 3, distance("kitten", "sitting", 3) end + def test_should_return_calculated_distance_when_same_as_maximum_for_empty_strings + assert_equal 3, distance("", "cat", 3) + assert_equal 3, distance("cat", "", 3) + assert_equal 0, distance("", "", 0) + end + def test_should_return_specified_maximum_if_distance_is_more assert_equal 1, distance("gumbo", "gambol", 1) assert_equal 2, distance("kitten", "sitting", 2) assert_equal 1, distance("test", "tasf", 1) end + def test_should_return_specified_maximum_if_distance_is_more_for_empty_strings + assert_equal 2, distance("kitten", "", 2) + assert_equal 3, distance("", "kitten", 3) + end + def test_should_return_maximum_distance_for_strings_with_additions_at_start assert_equal 1, distance("1234", "01234") assert_equal 0, distance("1234", "01234", 0)