chinese_pinyin 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +2 -0
- data/lib/chinese_pinyin.rb +6 -3
- data/lib/chinese_pinyin/version.rb +1 -1
- data/test/chinese_pinyin_test.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f07aaf4564ff809d31a86c8186a347b9ce2d36f
|
|
4
|
+
data.tar.gz: e744522c287bb3fc08bb7dfcbef8e0ac4e0d9547
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 048d9360b620e08702b104da592f1e7bedf698fc3babd770578846738958b73967e7c435a8d94572d23d19b184cf5501d7a213d6eea463a3439bee38fe023852
|
|
7
|
+
data.tar.gz: 5e2b60600bcf771aeaa6607c1f860a40590b9b7e4071035a5390d1d93ec817094a30ffbd6fcca7c0fbc124c1dc9922b8d4302b49c87d98b4eabb837b95504138
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby-2.2.
|
|
1
|
+
ruby-2.2.2
|
data/README.md
CHANGED
|
@@ -22,6 +22,8 @@ Usage
|
|
|
22
22
|
Pinyin.t('中国', splitter: '') => "zhongguo"
|
|
23
23
|
Pinyin.t('中国', tone: true) => "zhong1 guo2"
|
|
24
24
|
Pinyin.t('中国', tonemarks: true) => "zhōng guó"
|
|
25
|
+
Pinyin.t('北京') { |letters| letters[0].upcase } => 'BJ'
|
|
26
|
+
Pinyin.t('北京') { |letters, i| letters[0].upcase if i == 0 } => 'B'
|
|
25
27
|
|
|
26
28
|
Polyphone Issue
|
|
27
29
|
---------------
|
data/lib/chinese_pinyin.rb
CHANGED
|
@@ -89,9 +89,12 @@ class Pinyin
|
|
|
89
89
|
break if pinyin.tr! v, TONE_MARK[v.to_sym][tone_index]
|
|
90
90
|
}
|
|
91
91
|
end
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
if block_given?
|
|
93
|
+
results << (yield pinyin, results.size)
|
|
94
|
+
else
|
|
95
|
+
results << pinyin
|
|
96
|
+
results << splitter
|
|
97
|
+
end
|
|
95
98
|
else
|
|
96
99
|
if char =~ /[a-zA-Z0-9]/
|
|
97
100
|
results << char
|
data/test/chinese_pinyin_test.rb
CHANGED
|
@@ -43,4 +43,9 @@ class PinyinTest < Test::Unit::TestCase
|
|
|
43
43
|
assert_equal('zhōng guó', Pinyin.t('中国', tonemarks: true))
|
|
44
44
|
assert_equal('běi jīng', Pinyin.t('北京', tonemarks: true))
|
|
45
45
|
end
|
|
46
|
+
|
|
47
|
+
def test_t_with_custom
|
|
48
|
+
assert_equal('BJ', Pinyin.t('北京') { |letters| letters[0].upcase } )
|
|
49
|
+
assert_equal('B', Pinyin.t('北京') { |letters, i| letters[0].upcase if i == 0 } )
|
|
50
|
+
end
|
|
46
51
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chinese_pinyin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Huang
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2015-
|
|
12
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: translate chinese hanzi to pinyin.
|
|
15
15
|
email:
|
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
53
53
|
version: 1.3.6
|
|
54
54
|
requirements: []
|
|
55
55
|
rubyforge_project:
|
|
56
|
-
rubygems_version: 2.4.
|
|
56
|
+
rubygems_version: 2.4.6
|
|
57
57
|
signing_key:
|
|
58
58
|
specification_version: 4
|
|
59
59
|
summary: translate chinese hanzi to pinyin.
|