zhongwen_tools 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8925c565bf7d5e1d3c7b97722ca0e7f7c3cbf1f3
4
- data.tar.gz: 791bf7afed3e879f8bbf0aa3d7a5f67283775c6d
3
+ metadata.gz: 36a2e0463a764596b32d674fae73e6d70d5b35b0
4
+ data.tar.gz: 0695198696d219b954a7842929f2f9a29c27cb30
5
5
  SHA512:
6
- metadata.gz: a1479ff5ea06eac8d87db4a05a436667a63a22456595b7890e90476ebdb57fbee34a8a833b4731d18900496431ddf355bb216320d23f9f1b84d90e25e8449dad
7
- data.tar.gz: b2b7627d8a968ade60b34fdea85e7ced988e4dbf71506bcce4162213a9c49aae1b50cd373664fc313a27b8867aab8a95fb3581167d357503063b5c87bd744d96
6
+ metadata.gz: 4f3910228f09b9ee451c91d102824b69219bc0a37eec00a8cb1199978ac9c6bfd9e6f528b2dc87ec08dcf1a25171e1de1a008ed58aefa756f45b602e228f916e
7
+ data.tar.gz: a5e68d15248041507fe3f125f8c2de36e8a60dcd3bf2d16c8a48020b2dbcf770ce3b74ea55b3a68b0e510b1b020c03c006bb0aab4e4b6c765aa09833e8314f9d
data/README.md CHANGED
@@ -15,13 +15,15 @@ Install as a gem
15
15
 
16
16
  Add the ZhongwenTools component you need to your classes as a module.
17
17
 
18
+ require 'zhongwen_tools/romanization'
19
+
18
20
  class String
19
21
  include ZhongwenTools::Romanization
20
22
  end
21
23
 
22
24
  str = "ni3 hao3" #pinyin with numbers
23
25
  str.to_pinyin #=> "nǐ hǎo"
24
- str.to_zhuyinfuhao #=>
26
+ str.to_zhuyin_fuhao #=> "ㄋㄧ3 ㄏㄠ3"
25
27
 
26
28
  mzd = "Mao Tse-tung"
27
29
  mzd.to_pinyin #=> "Mao Zedong"
@@ -37,7 +39,7 @@ ZhongwenTools includes the following Modules:
37
39
  2. ZhongwenTools::Numbers - methods for identifying Chinese numbers and for converting to and from Chinese.
38
40
  3. ZhongwenTools::Integer - methods for converting integers into Chinese or pinyin.
39
41
  4. ZhongwenTools::Romanization - methods for converting between Chinese romanization systems.
40
- 5. ZhongwenTools::Conversion => functions for converting between Chinese scripts.
42
+ 5. ZhongwenTools::Conversion - methods for converting between Chinese scripts.
41
43
 
42
44
 
43
45
  ### Using ZhongwenTools::String
@@ -66,7 +68,7 @@ ZhongwenTools includes the following Modules:
66
68
  #### The following capitalization methods work for pinyin.
67
69
  require 'zhongwen_tools/string'
68
70
  ZhongwenTools::String.downcase 'Àomén' #=> 'àomén' does pinyin/ lowercase
69
- ZhongwenTools::String.upcase 'àomén' #=> --> does pinyin uppercase
71
+ ZhongwenTools::String.upcase 'àomén' #=> 'ÀOMÉN'
70
72
  ZhongwenTools::String.capitalize 'àomén' #=> 'Àomén'
71
73
 
72
74
  #### Ruby 1.8 safe methods
@@ -83,11 +85,11 @@ with multibyte strings in an simple way.
83
85
  ### Numbers
84
86
  Functions for converting to and from Chinese numbers.
85
87
 
86
- ZhongwenTools::Number.number_zht 12000 #=> '一萬二千'
87
- ZhongwenTools::Number.number_zhs 42 #=> '四十二'
88
- ZhongwenTools::Number.number_to_pyn 42 #=> 'si4-shi2-er4'
89
- ZhongwenTools::Number.number_to_int '四十二' #=> 42
90
- ZhongwenTools::Number.number? '四十二' #=> true
88
+ ZhongwenTools::Numbers.number_to_zht :num, 12000 #=> '一萬二千'
89
+ ZhongwenTools::Numbers.number_to_zhs :num, 42 #=> '四十二'
90
+ ZhongwenTools::Numbers.number_to_pyn :num, 42 #=> 'si4-shi2-er4'
91
+ ZhongwenTools::Numbers.zh_number_to_number '四十二' #=> 42
92
+ ZhongwenTools::Numbers.number? '四十二' #=> true
91
93
 
92
94
  ### Integers
93
95
  Monkey-patch your integers for Chinese.
@@ -113,7 +115,6 @@ scripts. It **does not convert Chinese characters to pinyin** (see ZhongwenTools
113
115
 
114
116
 
115
117
  str = "ni3 hao3"
116
- romanization_system = "pyn" #pyn|wg|yale|bpmf|zhyfh|wade-giles|bopomofo
117
118
 
118
119
  str.to_pinyin #=> "nǐ hǎo"
119
120
  str.to_py #=> "nǐ hǎo"
@@ -129,12 +130,12 @@ scripts. It **does not convert Chinese characters to pinyin** (see ZhongwenTools
129
130
 
130
131
  ### Conversion
131
132
  Functions for converting between scripts (e.g. traditional Chinese to
132
- simplified Chinese) and [TODO] between chinese and romanization systems (e.g.
133
+ simplified Chinese) and [TODO] between Chinese and romanization systems (e.g.
133
134
  Chinese to pinyin).
134
135
  Conversion methods must be required explicitly.
135
136
 
136
137
  gem 'zhongwen_tools'
137
- require 'zhongwen_tools/romanization'
138
+ require 'zhongwen_tools/conversion'
138
139
 
139
140
  ZhongwenTools::Conversion.to_zhs '華語' #=> '华语'
140
141
  ZhongwenTools::Conversion.to_zht '华语' #=> '華語'
data/Rakefile CHANGED
@@ -12,3 +12,42 @@ end
12
12
 
13
13
  desc "Run tests"
14
14
  task :default => :test
15
+
16
+
17
+ def setup_18
18
+ commands = [
19
+ 'cp Gemfile Gemfile.bak',
20
+ 'mv .ruby-version-1.8.7 .ruby-version',
21
+ 'cp Gemfile.1.8.7 Gemfile',
22
+ 'bundle install --local',
23
+ ]
24
+
25
+ commands.each{ |c| `#{ c }` }
26
+ end
27
+
28
+ def teardown_18
29
+ commands = [
30
+ 'mv .ruby-version .ruby-version-1.8.7 ',
31
+ 'cp Gemfile.bak Gemfile && rm Gemfile.bak',
32
+ 'bundle install --local'
33
+ ]
34
+
35
+ commands.each{ |c|
36
+ `#{ c }`
37
+ }
38
+ end
39
+
40
+
41
+ namespace :ruby_18 do
42
+ desc "Switch to 1.8.7"
43
+ task :setup do
44
+ setup_18 if File.exist?('.ruby-version-1.8.7')
45
+ puts 'Using Ruby 1.8.7'
46
+ end
47
+
48
+ desc "Teardown to 1.8.7"
49
+ task :teardown do
50
+ teardown_18 unless File.exist?('.ruby-version-1.8.7')
51
+ puts 'Using Ruby 2.1.0'
52
+ end
53
+ end
@@ -37,13 +37,14 @@ module ZhongwenTools
37
37
  # wg?('pin1-yin1')
38
38
  # # => false
39
39
  # There are some situations where wg == pyn, but there's no way to differentiate the two.
40
- def wg?(str = nil)
40
+ def wg?(str = nil, type = :pyn)
41
41
  #it shouldn't be pyn, but it should be able to conver to pyn
42
42
  str ||= self
43
43
  #easy ones.. is it py? pyn? zyfh? gyrm?
44
44
  #harder ones: is it typy, msp2, yale, wg
45
- wg = str._convert_romanization(str, :wg, :pyn)
46
-
45
+ wg = ZhongwenTools::Romanization.to_wade_giles(str, type)
46
+ # TODO: need to convert string to pyn.
47
+ pyn = str
47
48
  wg != pyn && wg.gsub(/[1-5]/,'')
48
49
  end
49
50
  end
@@ -5,6 +5,8 @@ require File.expand_path("../romanization/pyn_to_py", __FILE__)
5
5
 
6
6
  module ZhongwenTools
7
7
  module Romanization
8
+ extend self
9
+
8
10
  def to_pinyin(*args)
9
11
  str, from = _romanization_options(args)
10
12
 
@@ -1,3 +1,3 @@
1
1
  module ZhongwenTools
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
@@ -65,6 +65,8 @@ class TestRomanization < Minitest::Test
65
65
  def test_detect
66
66
  assert @str.pyn?
67
67
  refute @py.pyn?
68
+
69
+ assert 'chung1 kuo2'.wg?
68
70
  end
69
71
 
70
72
  def setup
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zhongwen_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Daniels
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-20 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake