Permalink
Browse files

Added UTF-8 character support for ruby 1.9

  • Loading branch information...
1 parent 67162e5 commit 47028a560bb7f1b84037613f4c14ad7cf3690f87 @drbrain drbrain committed Apr 6, 2012
Showing with 24 additions and 2 deletions.
  1. +8 −2 lib/rdoc/generator/spellcheck.rb
  2. +16 −0 test/test_rdoc_generator_spellcheck.rb
@@ -1,3 +1,5 @@
+# coding: UTF-8
+
require 'raspell'
##
@@ -213,8 +215,10 @@ class RDoc::Generator::Spellcheck
pwd
racc
rbw
+ redistributions
refactor
refactored
+ startup
stderr
stdin
stdout
@@ -230,6 +234,7 @@ class RDoc::Generator::Spellcheck
uniq
unmaintained
unordered
+ untrusted
utf
validator
validators
@@ -305,7 +310,8 @@ def initialize options # :not-new:
@misspellings = Hash.new 0
- @spell = Aspell.new @options.spell_language
+ encoding_name = @options.encoding.name
+ @spell = Aspell.new @options.spell_language, nil, nil, encoding_name
@spell.suggestion_mode = Aspell::NORMAL
@spell.set_option 'run-together', 'true'
@@ -335,7 +341,7 @@ def add_name name
def find_misspelled comment
report = []
- comment.text.scan(/[a-z][a-z']+[a-z]/i) do |word|
+ comment.text.scan(/\p{L}[\p{L}']+\p{L}/i) do |word|
offset = $`.length # store
word = $` if word =~ /'s$/i
@@ -1,3 +1,5 @@
+# coding: UTF-8
+
require 'rubygems'
require 'minitest/autorun'
require 'stringio'
@@ -130,6 +132,12 @@ def test_add_name
assert true # just for counting
end
+ def test_add_name_utf_8
+ @sc.add_name 'Володя'
+
+ assert true # just for counting
+ end
+
def test_find_misspelled
c = comment @text
@@ -172,6 +180,14 @@ def test_find_misspelled_underscore
assert_equal 0, offset
end
+ def test_find_misspelled_utf_8
+ c = comment 'Marvin Gülker'
+
+ report = @sc.find_misspelled c
+
+ assert_empty report
+ end
+
def test_generate_alias
klass = @top_level.add_class RDoc::NormalClass, 'Object'

0 comments on commit 47028a5

Please sign in to comment.