Permalink
Browse files

updated doc + made release ready

  • Loading branch information...
1 parent 0484002 commit 967cf46ee77975cc354fa1132aa99380716f0adb @mattetti committed May 27, 2008
Showing with 73 additions and 22 deletions.
  1. +1 −1 License.txt
  2. +4 −3 Manifest.txt
  3. +22 −1 README.txt
  4. +1 −1 config/hoe.rb
  5. +10 −0 lib/han-converter.rb
  6. +3 −3 lib/han-converter/version.rb
  7. +22 −0 spec/han-converter_spec.rb
  8. +1 −0 spec/spec.opts
  9. +9 −0 spec/spec_helper.rb
  10. +0 −11 test/test_han-converter.rb
  11. +0 −2 test/test_helper.rb
View
@@ -1,4 +1,4 @@
-Copyright (c) 2008 FIXME full name
+Copyright (c) 2008 Matt Aimonetti
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -6,8 +6,8 @@ Rakefile
config/hoe.rb
config/requirements.rb
lib/han-converter.rb
+lib/converter_table.rb
lib/han-converter/version.rb
-lib/han-converter.rb
log/debug.log
script/destroy
script/generate
@@ -16,8 +16,9 @@ setup.rb
tasks/deployment.rake
tasks/environment.rake
tasks/website.rake
-test/test_han-converter.rb
-test/test_helper.rb
+spec/han-converter_spec.rb
+spec/spec.opts
+spec/spec_helper.rb
website/index.html
website/index.txt
website/javascripts/rounded_corners_lite.inc.js
View
@@ -1 +1,22 @@
-README
+Converts traditional to simplified Chinese and vice versa.
+
+Installation:
+--------------
+sudo gem install matta-han-converter --source=http://gems.github.com
+
+Usage:
+------
+
+>> require 'han-converter'
+=> true
+>> "在您的手機上觀看和上載 YouTube 影片".to_simplified
+=> "在您的手机上观看和上载 YouTube 影片"
+
+>> "在您的手机上观看和上载 YouTube 影片".to_traditional
+=> "在您的手機上觀看咊上載 YouTube 影片"
+
+It won't be as good as manual translation but it works ok for me. The speed can probably be improved by going down to C land, but I don't have time to do that right now and I probably won't really need the speed for a little while.
+
+-Matt
+
+matt aimonetti [at] gmailDotCom
View
@@ -31,7 +31,7 @@ def rubyforge_username
REV = nil
# UNCOMMENT IF REQUIRED:
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
-VERS = Han-converter::VERSION::STRING + (REV ? ".#{REV}" : "")
+VERS = HanConverter::VERSION::STRING + (REV ? ".#{REV}" : "")
RDOC_OPTS = ['--quiet', '--title', 'han-converter documentation',
"--opname", "index.html",
"--line-numbers",
View
@@ -13,6 +13,16 @@ def to_simplified
end.join('')
end
+ def to_traditional
+ self.chars.split(//).map do |char|
+ if new_char_h = traditional_to_simplified.detect{|k,v| v == char.string}
+ new_char_h.first
+ else
+ char.string
+ end
+ end.join('')
+ end
+
end
class String
@@ -1,8 +1,8 @@
-module Han-converter #:nodoc:
+module HanConverter #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
- MINOR = 0
- TINY = 1
+ MINOR = 1
+ TINY = 0
STRING = [MAJOR, MINOR, TINY].join('.')
end
View
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/spec_helper.rb'
+
+describe "han-converter" do
+
+ it "should convert a traditional string into simplified Chinese" do
+ "關於我們".to_simplified.should == "关於我们"
+ end
+
+ it "should handle spacing in a string" do
+ "在您的手機上觀看和上載 YouTube 影片。".to_simplified.should == "在您的手机上观看和上载 YouTube 影片。"
+ end
+
+ it "should convert simplified to traditional" do
+ "关於我们".to_traditional.should == "關於我們"
+ end
+
+ it "should handle none chinese chars to" do
+ "ceci est un test".to_simplified.should == "ceci est un test"
+ "l'école de Ruby".to_simplified.should == "l'école de Ruby"
+ end
+
+end
View
@@ -0,0 +1 @@
+--colour
View
@@ -0,0 +1,9 @@
+begin
+ require 'spec'
+rescue LoadError
+ require 'rubygems'
+ gem 'rspec'
+ require 'spec'
+end
+
+require File.dirname(__FILE__) + '/../lib/han-converter.rb'
View
@@ -1,11 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper.rb'
-
-class TestHan-converter < Test::Unit::TestCase
-
- def setup
- end
-
- def test_truth
- assert true
- end
-end
View
@@ -1,2 +0,0 @@
-require 'test/unit'
-require File.dirname(__FILE__) + '/../lib/han-converter'

0 comments on commit 967cf46

Please sign in to comment.