text-hyphen 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,14 @@
1
+ == 1.4 / 2012.08.25
2
+
3
+ * Feature:
4
+ * Kirill Maksimov (https://github.com/netoneko) added Russian-language
5
+ hyphenation, complete with test. Thanks! In Ruby 1.8, the encoding is
6
+ KOI8-R. Also submitted by Dmitry Lihachev (https://github.com/lda).
7
+ * Bug Fix:
8
+ * Visualization with hyphens larger than one character (such as the HTML
9
+ soft-hyphen entity) would not be correct; this has been resolved. Thanks to
10
+ hadmut (https://github.com/hadmut) for reporting this issue.
11
+
1
12
  == 1.3 / 2012.06.20
2
13
  * Feature:
3
14
  * Cezary Baginsky (https://github.com/e2) added the ability to specify a
@@ -15,10 +15,11 @@ hyphenation pattern files are based on the sources available from
15
15
  {CTAN}[http://www.ctan.org] as of 2004.12.19 and have been manually translated
16
16
  by Austin Ziegler.
17
17
 
18
- This is a small feature release adding support for custom hyphens and fixing a
19
- bug in ruby-hyphen. This release provides both Ruby 1.8.7 and Ruby 1.9.2
20
- support. This is the last major release supporting Ruby 1.8 interpreters.
21
- Future versions will only work with Ruby 1.9 or later interpreters.
18
+ This is a small feature release adding Russian language support and fixing a
19
+ bug in the custom hyphen support introduced last version. This release provides
20
+ both Ruby 1.8.7 and Ruby 1.9.2 support (but please read below). In short, Ruby
21
+ 1.8 support is deprecated and I will not be providing any bug fixes related to
22
+ Ruby 1.8. New features will be developed and tested against Ruby 1.9 only.
22
23
 
23
24
  == Where
24
25
 
@@ -63,6 +64,25 @@ debug control) and support for UTF-8 under Ruby 1.9.
63
64
  == Install
64
65
  gem install text-hyphen
65
66
 
67
+ === A Note About Ruby 1.8 Support
68
+
69
+ I've been saying for a couple of releases that "this is the last major release
70
+ supporting Ruby 1.8 interpreters. Future versions will only work with Ruby 1.9
71
+ or later interpreters." Let me clarify my position on this, because removing
72
+ Ruby 1.8 support requires effort that I am not putting in as of yet.
73
+
74
+ * I currently use rbenv and this machine has a version with Ruby 1.8.7
75
+ installed (and Mac OS X ships with Ruby 1.8.7 anyway).
76
+ * I will continue to run the test suite against all installed versions of Ruby
77
+ that I have on this machine.
78
+ * If you submit a patch or pull request, I do not require 1.8.7 support. Until
79
+ I decide to move this project from 1.x to 2.x versioning, features that do
80
+ not support 1.8 must be guarded. If the feature is sufficiently complex, I
81
+ can be convinced to switch to 2.x.
82
+ * I will not fix any bugs related to Ruby 1.8.7. I will accept patches or pull
83
+ requests that fix bugs that others find, however.
84
+ * I strongly recommend that your gem specification for text-hyphen be '~> 1.4'.
85
+
66
86
  == Developers
67
87
 
68
88
  After checking out the source, run:
@@ -8,7 +8,7 @@ end
8
8
  # a specific language's hyphenation patterns.
9
9
  class Text::Hyphen
10
10
  DEBUG = false
11
- VERSION = '1.3'
11
+ VERSION = '1.4'
12
12
 
13
13
  DEFAULT_MIN_LEFT = 2
14
14
  DEFAULT_MIN_RIGHT = 2
@@ -160,8 +160,11 @@ class Text::Hyphen
160
160
  def visualise(word, hyphen = '-')
161
161
  return @vcache[word] if @vcache.has_key?(word)
162
162
  w = word.dup
163
+ s = hyphen.size
163
164
  hyphenate(w).each_with_index do |pos, n|
164
- w[pos.to_i + n, 0] = hyphen if pos != 0
165
+ # Insert the hyphen string at the ported position plus the offset of
166
+ # the last hyphen string inserted.
167
+ w[pos.to_i + (n * s), 0] = hyphen unless pos.zero?
165
168
  end
166
169
  @vcache[word] = w
167
170
  end
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require 'test/unit'
2
3
  require 'text-hyphen'
3
4
 
@@ -59,10 +60,19 @@ class TestTextHyphen < Test::Unit::TestCase
59
60
  def test_alt_hyphen_for_visualize
60
61
  a = Text::Hyphen.new.visualize('backpack', SOFT_HYPHEN)
61
62
  assert_equal "back#{SOFT_HYPHEN}pack", a
63
+
64
+ a = Text::Hyphen.new.visualize('representation', SOFT_HYPHEN)
65
+ assert_equal "rep#{SOFT_HYPHEN}re#{SOFT_HYPHEN}sen#{SOFT_HYPHEN}ta#{SOFT_HYPHEN}tion", a
62
66
  end
63
67
 
64
68
  def test_alt_hyphen_for_hyphenate_to
65
69
  a = Text::Hyphen.new.hyphenate_to('backpack', 5, SOFT_HYPHEN)
66
70
  assert_equal ["back#{SOFT_HYPHEN}", 'pack'], a
71
+
72
+ end
73
+
74
+ def test_russian
75
+ a = Text::Hyphen.new(:language => 'ru').visualize('скоропалительный')
76
+ assert_equal "ско-ро-па-ли-тель-ный", a
67
77
  end
68
78
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "text-hyphen"
5
- s.version = "1.3"
5
+ s.version = "1.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Austin Ziegler"]
9
- s.date = "2012-06-21"
9
+ s.date = "2012-08-26"
10
10
  s.description = "Text::Hyphen is a Ruby library to hyphenate words in various languages using\nRuby-fied versions of TeX hyphenation patterns. It will properly hyphenate\nvarious words according to the rules of the language the word is written in.\nThe algorithm is based on that of the TeX typesetting system by Donald E.\nKnuth.\n\nThis is originally based on the Perl implementation of\n{TeX::Hyphen}[http://search.cpan.org/author/JANPAZ/TeX-Hyphen-0.140/lib/TeX/Hyphen.pm]\nand the {Ruby port}[http://rubyforge.org/projects/text-format]. The language\nhyphenation pattern files are based on the sources available from\n{CTAN}[http://www.ctan.org] as of 2004.12.19 and have been manually translated\nby Austin Ziegler.\n\nThis is a small feature release adding support for custom hyphens and fixing a\nbug in ruby-hyphen. This release provides both Ruby 1.8.7 and Ruby 1.9.2\nsupport. This is the last major release supporting Ruby 1.8 interpreters.\nFuture versions will only work with Ruby 1.9 or later interpreters."
11
11
  s.email = ["austin@rubyforge.org"]
12
12
  s.executables = ["ruby-hyphen"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text-hyphen
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
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: 2012-06-21 00:00:00.000000000 Z
12
+ date: 2012-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyforge
@@ -148,13 +148,15 @@ description: ! 'Text::Hyphen is a Ruby library to hyphenate words in various lan
148
148
  by Austin Ziegler.
149
149
 
150
150
 
151
- This is a small feature release adding support for custom hyphens and fixing a
151
+ This is a small feature release adding Russian language support and fixing a
152
152
 
153
- bug in ruby-hyphen. This release provides both Ruby 1.8.7 and Ruby 1.9.2
153
+ bug in the custom hyphen support introduced last version. This release provides
154
154
 
155
- support. This is the last major release supporting Ruby 1.8 interpreters.
155
+ both Ruby 1.8.7 and Ruby 1.9.2 support (but please read below). In short, Ruby
156
156
 
157
- Future versions will only work with Ruby 1.9 or later interpreters.'
157
+ 1.8 support is deprecated and I will not be providing any bug fixes related to
158
+
159
+ Ruby 1.8. New features will be developed and tested against Ruby 1.9 only.'
158
160
  email:
159
161
  - austin@rubyforge.org
160
162
  executables: