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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 536820144ef1284e973430e684d7511a5f4a21b5
4
- data.tar.gz: 235adb7c959a9c0a01e3d2234ac1abf75fefc79a
3
+ metadata.gz: 5f07aaf4564ff809d31a86c8186a347b9ce2d36f
4
+ data.tar.gz: e744522c287bb3fc08bb7dfcbef8e0ac4e0d9547
5
5
  SHA512:
6
- metadata.gz: fcf06b8a4f831aac76d9ecd772b972f05b855e70fab14fca2d40aa5f6504fdd4045a56bc5a84dc22e1bb0cf857d72b6e6f0ce8133f37d95dae78f2f05e360330
7
- data.tar.gz: 526585ebbd8b4ecc987f31d5c591cbc8352708df9af9601f1a01c8ae8bb22f06da2da73e6017f2fbbd6f8b71e747009e16f2a6c88b0c0d215fe61c4222268b95
6
+ metadata.gz: 048d9360b620e08702b104da592f1e7bedf698fc3babd770578846738958b73967e7c435a8d94572d23d19b184cf5501d7a213d6eea463a3439bee38fe023852
7
+ data.tar.gz: 5e2b60600bcf771aeaa6607c1f860a40590b9b7e4071035a5390d1d93ec817094a30ffbd6fcca7c0fbc124c1dc9922b8d4302b49c87d98b4eabb837b95504138
@@ -1 +1 @@
1
- ruby-2.2.0
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
  ---------------
@@ -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
- results << pinyin
94
- results << splitter
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
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module ChinesePinyin
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
@@ -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.7.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-03-10 00:00:00.000000000 Z
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.5
56
+ rubygems_version: 2.4.6
57
57
  signing_key:
58
58
  specification_version: 4
59
59
  summary: translate chinese hanzi to pinyin.