zhongwen_tools 0.12.4 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.md +74 -165
  4. data/Rakefile +0 -1
  5. data/lib/zhongwen_tools/{string/caps.rb → caps.rb} +19 -1
  6. data/lib/zhongwen_tools/core.rb +19 -0
  7. data/lib/zhongwen_tools/core_ext/integer.rb +8 -0
  8. data/lib/zhongwen_tools/core_ext/string.rb +10 -0
  9. data/lib/zhongwen_tools/fullwidth.rb +102 -0
  10. data/lib/zhongwen_tools/integer_extension.rb +31 -0
  11. data/lib/zhongwen_tools/number/number_table.rb +44 -0
  12. data/lib/zhongwen_tools/number.rb +221 -0
  13. data/lib/zhongwen_tools/regex.rb +38 -22
  14. data/lib/zhongwen_tools/romanization/pinyin.rb +231 -0
  15. data/lib/zhongwen_tools/romanization/{pyn_to_py.rb → pinyin_table.rb} +2 -1
  16. data/lib/zhongwen_tools/romanization/romanization_table.rb +425 -0
  17. data/lib/zhongwen_tools/romanization.rb +199 -136
  18. data/lib/zhongwen_tools/{string/ruby19.rb → ruby_19.rb} +1 -2
  19. data/lib/zhongwen_tools/{conversion → script}/conversion_data +0 -0
  20. data/lib/zhongwen_tools/{conversion.rb → script.rb} +21 -34
  21. data/lib/zhongwen_tools/string_extension.rb +136 -0
  22. data/lib/zhongwen_tools/unicode.rb +25 -0
  23. data/lib/zhongwen_tools/uri.rb +14 -0
  24. data/lib/zhongwen_tools/version.rb +1 -1
  25. data/lib/zhongwen_tools/zhongwen.rb +29 -0
  26. data/lib/zhongwen_tools.rb +2 -3
  27. data/test/test_caps.rb +26 -0
  28. data/test/test_core.rb +13 -0
  29. data/test/test_fullwidth.rb +30 -0
  30. data/test/test_helper.rb +4 -12
  31. data/test/test_helpers/unload_zhongwen_tools_script.rb +5 -0
  32. data/test/test_integer_extension.rb +34 -0
  33. data/test/test_number.rb +79 -0
  34. data/test/test_pinyin.rb +68 -0
  35. data/test/test_regex.rb +41 -0
  36. data/test/test_romanization.rb +110 -133
  37. data/test/{test_conversion.rb → test_script.rb} +41 -44
  38. data/test/test_string_extension.rb +94 -0
  39. data/test/test_unicode.rb +27 -0
  40. data/test/test_uri.rb +16 -0
  41. data/test/test_zhongwen.rb +37 -0
  42. data/zhongwen_tools.gemspec +1 -1
  43. metadata +93 -52
  44. data/Gemfile.1.8.7 +0 -8
  45. data/lib/zhongwen_tools/conversion/string.rb +0 -19
  46. data/lib/zhongwen_tools/integer.rb +0 -28
  47. data/lib/zhongwen_tools/numbers.rb +0 -195
  48. data/lib/zhongwen_tools/regex/ruby18.rb +0 -15
  49. data/lib/zhongwen_tools/romanization/conversion_table.rb +0 -425
  50. data/lib/zhongwen_tools/romanization/detect.rb +0 -141
  51. data/lib/zhongwen_tools/romanization/string.rb +0 -36
  52. data/lib/zhongwen_tools/string/fullwidth.rb +0 -85
  53. data/lib/zhongwen_tools/string/ruby18.rb +0 -96
  54. data/lib/zhongwen_tools/string.rb +0 -164
  55. data/test/test_integer.rb +0 -31
  56. data/test/test_numbers.rb +0 -68
  57. data/test/test_string.rb +0 -133
@@ -1,16 +1,10 @@
1
- #encoding: utf-8
1
+ # encoding: utf-8
2
2
  $:.unshift File.join(File.dirname(__FILE__),'..','lib')
3
3
 
4
4
  require './test/test_helper'
5
- require 'zhongwen_tools/conversion'
6
- class String
7
- include ZhongwenTools::Conversion
8
- include ZhongwenTools::String
9
- end
10
-
11
- class TestConversion < Minitest::Test
12
-
5
+ class TestScript < Minitest::Test
13
6
  def setup
7
+ load 'zhongwen_tools/script.rb'
14
8
  @strings = [
15
9
  {
16
10
  :zhs => '干部一干人等干事不干不净',
@@ -48,76 +42,79 @@ class TestConversion < Minitest::Test
48
42
  :zhcn => '旧金山台球冠军是笑星'
49
43
  }
50
44
  ]
51
-
52
45
  end
53
46
 
54
47
  def test_to_zht
55
48
  type = :zht
56
- @strings.each do |zh_hash|
57
- zh_hash.each do |k, str|
58
- assert_equal zh_hash[type], ZhongwenTools::Conversion.to_zht(str) , k unless [:zhcn, :zhhk, :zhtw].include? k
59
- end
49
+ @strings.each do |hash|
50
+ result = ZhongwenTools::Script.to_zht(hash[:zhs], type)
51
+ message = "#{ hash[type] } should equal #{ result }"
52
+ assert_equal hash[type],result, message
60
53
  end
61
54
  end
62
55
 
63
56
  def test_to_zhs
64
57
  type = :zhs
65
- @strings.each do |zh_hash|
66
- zh_hash.each do |k, str|
67
- assert_equal zh_hash[type], str.to_zhs , k unless [:zhcn, :zhhk, :zhtw].include? k
68
- end
58
+ @strings.each do |hash|
59
+ result = ZhongwenTools::Script.to_zhs(hash[:zht], type)
60
+ message = "#{ hash[type] } should equal #{ result }"
61
+ assert_equal hash[type], result, message
69
62
  end
70
63
 
71
64
  end
72
65
 
73
66
  def test_to_zhtw
74
67
  type = :zhtw
75
- @strings.each do |zh_hash|
76
- zh_hash.each do |k, str|
77
- assert_equal zh_hash[type], str.to_zhtw , k unless [:zht].include? k
68
+ @strings.each do |hash|
69
+ hash.each do |k, str|
70
+ result = ZhongwenTools::Script.to_zht(str, type)
71
+ message = "#{ hash[type] } should equal #{ result }"
72
+ assert_equal hash[type], result, message unless [:zht].include? k
78
73
  end
79
74
  end
80
-
81
75
  end
82
76
 
83
77
  def test_to_zhhk
84
78
  type = :zhhk
85
79
 
86
- #can only convert tw to hk
87
- @strings.each do |zh_hash|
88
- zh_hash.each do |k, str|
89
- assert_equal zh_hash[type], ZhongwenTools::Conversion.to_zhhk(str) , k unless [:zht, :zhcn].include? k
80
+ # NOTE: Can only convert tw to hk
81
+ @strings.each do |hash|
82
+ hash.each do |k, str|
83
+ result = ZhongwenTools::Script.to_zht(str, type)
84
+ message = "#{ hash[type] } should equal #{ result }"
85
+ assert_equal hash[type], result, message unless [:zht, :zhcn].include? k
90
86
  end
91
87
  end
92
88
  end
93
89
 
94
90
  def test_to_zhcn
95
91
  type = :zhcn
96
- @strings.each do |zh_hash|
97
- zh_hash.each do |k, str|
98
- assert_equal zh_hash[type], ZhongwenTools::Conversion.to_zhcn(str) , k unless [:zhs ].include? k
92
+ @strings.each do |hash|
93
+ hash.each do |k, str|
94
+ result = ZhongwenTools::Script.to_zhs(str, type)
95
+ message = "#{ hash[type] } should equal #{ result }"
96
+ assert_equal hash[type], result, message unless [:zhs].include? k
99
97
  end
100
98
  end
101
99
  end
102
100
 
103
101
  def test_zhs?
104
- @strings.each do |zh_hash|
105
- assert zh_hash[:zhcn].zhs?
106
- assert zh_hash[:zhs].zhs?
107
- refute zh_hash[:zht].zhs?
108
- refute zh_hash[:zhtw].zhs?
109
- refute zh_hash[:zhhk].zhs?
102
+ @strings.each do |hash|
103
+ assert ZhongwenTools::Script.zhs?(hash[:zhcn])
104
+ assert ZhongwenTools::Script.zhs?(hash[:zhs])
105
+ refute ZhongwenTools::Script.zhs?(hash[:zht])
106
+ refute ZhongwenTools::Script.zhs?(hash[:zhtw])
107
+ refute ZhongwenTools::Script.zhs?(hash[:zhhk])
110
108
  end
111
109
  end
112
110
 
113
111
  def test_zht?
114
- @strings.each do |zh_hash|
115
- refute zh_hash[:zhcn].zht?
116
- refute zh_hash[:zhs].zht?
117
- assert zh_hash[:zht].zht?
118
- assert zh_hash[:zhtw].zht?
119
- assert zh_hash[:zhhk].zht?, zh_hash[:zhhk]
112
+ @strings.each do |hash|
113
+ refute ZhongwenTools::Script.zht?(hash[:zhcn])
114
+ refute ZhongwenTools::Script.zht?(hash[:zhs])
115
+ assert ZhongwenTools::Script.zht?(hash[:zht])
116
+ assert ZhongwenTools::Script.zht?(hash[:zhtw])
117
+ assert ZhongwenTools::Script.zht?(hash[:zhhk])
120
118
  end
121
- end
122
-
123
- end
119
+ end
120
+ end
@@ -0,0 +1,94 @@
1
+ # encoding: utf-8
2
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
3
+
4
+ require './test/test_helper'
5
+ require 'zhongwen_tools'
6
+
7
+ if RUBY_VERSION < '2.0.0'
8
+ String.send(:include, ZhongwenTools::StringExtension)
9
+ else
10
+ using ZhongwenTools
11
+ end
12
+
13
+ class TestStringExtention < Minitest::Test
14
+ def setup
15
+ @caps = { u: 'ĀLĀBÓ', d: 'ālābó', c: 'Ālābó' }
16
+ @fw = { hw: 'hello',fw: 'hello', mixed: 'hello' }
17
+
18
+ @rom = {
19
+ pyn: 'ni3 hao3',
20
+ py: 'nǐ hǎo',
21
+ bpmf: 'ㄋㄧ3 ㄏㄠ3',
22
+ yale: 'ni3 hau3',
23
+ typy: 'ni3 hao3',
24
+ wg: 'ni3 hao3',
25
+ mps2: 'ni3 hau3'
26
+ }
27
+
28
+ @zh = {
29
+ :zhs => '嘴里吃着鲔鱼三明治',
30
+ :zht => '嘴裡吃著鮪魚三明治',
31
+ :zhtw => '嘴裡吃著鮪魚三明治',
32
+ :zhhk => '嘴裏吃着吞拿魚三文治',
33
+ :zhcn => '嘴里吃着金枪鱼三明治'
34
+ }
35
+ @unicode = { codepoint:"\\u4e2d\\u6587", unicode: '中文' }
36
+ end
37
+
38
+ def test_methods
39
+ assert_kind_of Array, @caps[:u].chars
40
+ # caps.rb
41
+ assert_equal 'Hello', 'hello'.capitalize
42
+ assert_equal @caps[:d], @caps[:u].zh_downcase
43
+ assert_equal @caps[:u], @caps[:c].zh_upcase
44
+
45
+ # fullwidth.rb
46
+ assert_equal @fw[:hw], @fw[:fw].to_halfwidth
47
+ assert_equal @fw[:hw], @fw[:mixed].to_halfwidth
48
+ assert @fw[:hw].halfwidth?
49
+ assert @fw[:fw].fullwidth?
50
+ assert @fw[:mixed].fullwidth?
51
+ refute @fw[:mixed].halfwidth?
52
+
53
+ # romanization
54
+ # NOTE: MUST use eval because "Any indirect method access ... shall not honor refinements in the caller context during method lookup."
55
+ @rom.each do |from, str|
56
+ @rom.each do |to, expected_result|
57
+ if [:py, :pyn].include?(from)
58
+ assert_equal expected_result, eval("str.to_#{to}"), "'#{str}'.to_#{to} should equal #{expected_result}"
59
+ else
60
+ assert_equal expected_result, eval("str.to_#{to}(:#{from})"), "'#{str}'.to_#{to}(#{from}) should equal #{expected_result}"
61
+ end
62
+ end
63
+ end
64
+
65
+
66
+ # script.rb
67
+ load 'zhongwen_tools/script.rb'# unless ZhongwenTools.const_defined?(:Script)
68
+ assert_equal @zh[:zht], @zh[:zhs].to_zht
69
+ assert_equal @zh[:zhs], @zh[:zht].to_zhs
70
+ assert_equal @zh[:zhcn], @zh[:zhhk].to_zhcn
71
+ assert_equal @zh[:zhcn], @zh[:zhtw].to_zhcn
72
+ assert_equal @zh[:zhhk], @zh[:zhhk].to_zhhk
73
+ assert_equal @zh[:zhhk], @zh[:zhcn].to_zhhk
74
+ assert_equal @zh[:zhtw], @zh[:zhhk].to_zhtw
75
+ assert_equal @zh[:zhtw], @zh[:zhcn].to_zhtw
76
+
77
+ # unicode.rb
78
+ assert_equal @unicode[:codepoint], @unicode[:unicode].to_codepoint
79
+ assert_equal @unicode[:unicode], @unicode[:codepoint].from_codepoint
80
+ refute @unicode[:unicode].ascii?
81
+ assert @unicode[:unicode].multibyte?
82
+
83
+ # uri.rb
84
+ # NOTE: refinements can't test for "respond_to"
85
+ assert ''.uri_escape
86
+ assert ''.uri_encode
87
+
88
+ # zhongwen.rb
89
+ assert @zh[:zhs].zh?
90
+ assert @zh[:zhs].has_zh?
91
+ assert '。'.has_zh_punctuation?
92
+ assert_equal '你好', '你好!'.strip_zh_punctuation
93
+ end
94
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
3
+
4
+ require './test/test_helper'
5
+ require 'zhongwen_tools/unicode'
6
+ class TestUnicode < Minitest::Test
7
+ def test_to_codepoint
8
+ assert_equal "\\u4e2d\\u6587", ZhongwenTools::Unicode.to_codepoint('中文')
9
+ assert_equal "\\u4e2d", ZhongwenTools::Unicode.to_codepoint('中')
10
+ end
11
+
12
+ def test_from_codepoint
13
+ assert_equal '中', ZhongwenTools::Unicode.from_codepoint("\\u4e2d")
14
+ assert_equal '中文', ZhongwenTools::Unicode.from_codepoint("\\u4e2d\\u6587")
15
+ end
16
+
17
+ def test_ascii
18
+ refute ZhongwenTools::Unicode.ascii?('中文')
19
+ assert ZhongwenTools::Unicode.ascii?('Chinese')
20
+ end
21
+
22
+ def test_multibyte
23
+ assert ZhongwenTools::Unicode.multibyte?('中文')
24
+ refute ZhongwenTools::Unicode.multibyte?('Chinese')
25
+ end
26
+ end
27
+
data/test/test_uri.rb ADDED
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
3
+
4
+ require './test/test_helper'
5
+ require 'zhongwen_tools/uri'
6
+ class TestUri < Minitest::Test
7
+ def test_uri_encode
8
+ str = '你们'
9
+ assert_equal URI.encode(str), ZhongwenTools::URI.encode(str)
10
+ end
11
+
12
+ def test_uri_escape
13
+ str = '你们'
14
+ assert_equal URI.escape(str), ZhongwenTools::URI.escape(str)
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
3
+
4
+ require './test/test_helper'
5
+ require 'zhongwen_tools/zhongwen'
6
+
7
+ class TestZhongwen < Minitest::Test
8
+ def setup
9
+ @hw = 'hello'
10
+ @fw = 'hello'
11
+ @mixed = '你好Kailin'
12
+ @zh = '你好'
13
+ end
14
+
15
+ def test_has_zh?
16
+ assert ZhongwenTools::Zhongwen.has_zh? @zh
17
+ assert ZhongwenTools::Zhongwen.has_zh? @mixed
18
+ refute ZhongwenTools::Zhongwen.has_zh? @hw
19
+ refute ZhongwenTools::Zhongwen.has_zh? @fw
20
+ end
21
+
22
+ def test_zh?
23
+ assert ZhongwenTools::Zhongwen.zh? @zh
24
+ refute ZhongwenTools::Zhongwen.zh? @mixed
25
+ refute ZhongwenTools::Zhongwen.zh? @hw
26
+ refute ZhongwenTools::Zhongwen.zh? @fw
27
+ end
28
+
29
+ def test_has_zh_punctuation
30
+ assert ZhongwenTools::Zhongwen.has_zh_punctuation?('你好!')
31
+ refute ZhongwenTools::Zhongwen.has_zh_punctuation?('你好')
32
+ end
33
+
34
+ def test_strip_zh_punctuation
35
+ assert_equal '你好', ZhongwenTools::Zhongwen.strip_zh_punctuation('你好!')
36
+ end
37
+ end
@@ -11,7 +11,6 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "https://github.com/stevendaniels/zhongwen_tools"
12
12
  s.summary = %q{Zhongwen Tools provide romanization conversions and helper methods for Chinese.}
13
13
  s.description = %q{Chinese tools for romanization conversions and other helpful string functions for Chinese.}
14
-
15
14
  s.rubyforge_project = "zhongwen_tools"
16
15
 
17
16
  s.files = `git ls-files`.split("\n")
@@ -26,5 +25,6 @@ Gem::Specification.new do |s|
26
25
  s.add_development_dependency('coveralls', '~> 0.7', '>= 0.7.0')
27
26
  s.add_development_dependency('minitest', '~> 5.3', '>= 5.3.0')
28
27
  s.add_development_dependency('pry', '~> 0.9', '>= 0.9.12')
28
+ s.add_development_dependency('minitest-reporters', '~> 1.0', '>= 1.0.4')
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,129 +1,149 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zhongwen_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.15.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-06-30 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '10.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '10.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: simplecov
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.7'
34
- - - ">="
34
+ - - '>='
35
35
  - !ruby/object:Gem::Version
36
36
  version: 0.7.0
37
37
  type: :development
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "~>"
41
+ - - ~>
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0.7'
44
- - - ">="
44
+ - - '>='
45
45
  - !ruby/object:Gem::Version
46
46
  version: 0.7.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: simplecov-gem-adapter
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.0'
54
- - - ">="
54
+ - - '>='
55
55
  - !ruby/object:Gem::Version
56
56
  version: 1.0.1
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - "~>"
61
+ - - ~>
62
62
  - !ruby/object:Gem::Version
63
63
  version: '1.0'
64
- - - ">="
64
+ - - '>='
65
65
  - !ruby/object:Gem::Version
66
66
  version: 1.0.1
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: coveralls
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "~>"
71
+ - - ~>
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0.7'
74
- - - ">="
74
+ - - '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: 0.7.0
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ~>
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0.7'
84
- - - ">="
84
+ - - '>='
85
85
  - !ruby/object:Gem::Version
86
86
  version: 0.7.0
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: minitest
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - "~>"
91
+ - - ~>
92
92
  - !ruby/object:Gem::Version
93
93
  version: '5.3'
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 5.3.0
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '5.3'
104
- - - ">="
104
+ - - '>='
105
105
  - !ruby/object:Gem::Version
106
106
  version: 5.3.0
107
107
  - !ruby/object:Gem::Dependency
108
108
  name: pry
109
109
  requirement: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - "~>"
111
+ - - ~>
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0.9'
114
- - - ">="
114
+ - - '>='
115
115
  - !ruby/object:Gem::Version
116
116
  version: 0.9.12
117
117
  type: :development
118
118
  prerelease: false
119
119
  version_requirements: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - "~>"
121
+ - - ~>
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0.9'
124
- - - ">="
124
+ - - '>='
125
125
  - !ruby/object:Gem::Version
126
126
  version: 0.9.12
127
+ - !ruby/object:Gem::Dependency
128
+ name: minitest-reporters
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '1.0'
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: 1.0.4
137
+ type: :development
138
+ prerelease: false
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ~>
142
+ - !ruby/object:Gem::Version
143
+ version: '1.0'
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: 1.0.4
127
147
  description: Chinese tools for romanization conversions and other helpful string functions
128
148
  for Chinese.
129
149
  email:
@@ -132,36 +152,47 @@ executables: []
132
152
  extensions: []
133
153
  extra_rdoc_files: []
134
154
  files:
135
- - ".travis.yml"
155
+ - .travis.yml
136
156
  - Gemfile
137
- - Gemfile.1.8.7
138
157
  - README.md
139
158
  - Rakefile
140
159
  - lib/zhongwen_tools.rb
141
- - lib/zhongwen_tools/conversion.rb
142
- - lib/zhongwen_tools/conversion/conversion_data
143
- - lib/zhongwen_tools/conversion/string.rb
144
- - lib/zhongwen_tools/integer.rb
145
- - lib/zhongwen_tools/numbers.rb
160
+ - lib/zhongwen_tools/caps.rb
161
+ - lib/zhongwen_tools/core.rb
162
+ - lib/zhongwen_tools/core_ext/integer.rb
163
+ - lib/zhongwen_tools/core_ext/string.rb
164
+ - lib/zhongwen_tools/fullwidth.rb
165
+ - lib/zhongwen_tools/integer_extension.rb
166
+ - lib/zhongwen_tools/number.rb
167
+ - lib/zhongwen_tools/number/number_table.rb
146
168
  - lib/zhongwen_tools/regex.rb
147
- - lib/zhongwen_tools/regex/ruby18.rb
148
169
  - lib/zhongwen_tools/romanization.rb
149
- - lib/zhongwen_tools/romanization/conversion_table.rb
150
- - lib/zhongwen_tools/romanization/detect.rb
151
- - lib/zhongwen_tools/romanization/pyn_to_py.rb
152
- - lib/zhongwen_tools/romanization/string.rb
153
- - lib/zhongwen_tools/string.rb
154
- - lib/zhongwen_tools/string/caps.rb
155
- - lib/zhongwen_tools/string/fullwidth.rb
156
- - lib/zhongwen_tools/string/ruby18.rb
157
- - lib/zhongwen_tools/string/ruby19.rb
170
+ - lib/zhongwen_tools/romanization/pinyin.rb
171
+ - lib/zhongwen_tools/romanization/pinyin_table.rb
172
+ - lib/zhongwen_tools/romanization/romanization_table.rb
173
+ - lib/zhongwen_tools/ruby_19.rb
174
+ - lib/zhongwen_tools/script.rb
175
+ - lib/zhongwen_tools/script/conversion_data
176
+ - lib/zhongwen_tools/string_extension.rb
177
+ - lib/zhongwen_tools/unicode.rb
178
+ - lib/zhongwen_tools/uri.rb
158
179
  - lib/zhongwen_tools/version.rb
159
- - test/test_conversion.rb
180
+ - lib/zhongwen_tools/zhongwen.rb
181
+ - test/test_caps.rb
182
+ - test/test_core.rb
183
+ - test/test_fullwidth.rb
160
184
  - test/test_helper.rb
161
- - test/test_integer.rb
162
- - test/test_numbers.rb
185
+ - test/test_helpers/unload_zhongwen_tools_script.rb
186
+ - test/test_integer_extension.rb
187
+ - test/test_number.rb
188
+ - test/test_pinyin.rb
189
+ - test/test_regex.rb
163
190
  - test/test_romanization.rb
164
- - test/test_string.rb
191
+ - test/test_script.rb
192
+ - test/test_string_extension.rb
193
+ - test/test_unicode.rb
194
+ - test/test_uri.rb
195
+ - test/test_zhongwen.rb
165
196
  - zhongwen_tools.gemspec
166
197
  homepage: https://github.com/stevendaniels/zhongwen_tools
167
198
  licenses:
@@ -173,24 +204,34 @@ require_paths:
173
204
  - lib
174
205
  required_ruby_version: !ruby/object:Gem::Requirement
175
206
  requirements:
176
- - - ">="
207
+ - - '>='
177
208
  - !ruby/object:Gem::Version
178
209
  version: '0'
179
210
  required_rubygems_version: !ruby/object:Gem::Requirement
180
211
  requirements:
181
- - - ">="
212
+ - - '>='
182
213
  - !ruby/object:Gem::Version
183
214
  version: '0'
184
215
  requirements: []
185
216
  rubyforge_project: zhongwen_tools
186
- rubygems_version: 2.2.2
217
+ rubygems_version: 2.0.14
187
218
  signing_key:
188
219
  specification_version: 4
189
220
  summary: Zhongwen Tools provide romanization conversions and helper methods for Chinese.
190
221
  test_files:
191
- - test/test_conversion.rb
222
+ - test/test_caps.rb
223
+ - test/test_core.rb
224
+ - test/test_fullwidth.rb
192
225
  - test/test_helper.rb
193
- - test/test_integer.rb
194
- - test/test_numbers.rb
226
+ - test/test_helpers/unload_zhongwen_tools_script.rb
227
+ - test/test_integer_extension.rb
228
+ - test/test_number.rb
229
+ - test/test_pinyin.rb
230
+ - test/test_regex.rb
195
231
  - test/test_romanization.rb
196
- - test/test_string.rb
232
+ - test/test_script.rb
233
+ - test/test_string_extension.rb
234
+ - test/test_unicode.rb
235
+ - test/test_uri.rb
236
+ - test/test_zhongwen.rb
237
+ has_rdoc:
data/Gemfile.1.8.7 DELETED
@@ -1,8 +0,0 @@
1
- source "https://rubygems.org"
2
- # Specify your gem's dependencies in zhongwen_tools.gemspec
3
- gemspec
4
-
5
- group :test do
6
- gem 'minitest' if RUBY_VERSION < '1.9'
7
- gem 'pry'
8
- end
@@ -1,19 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module ZhongwenTools
4
- module String
5
- include ZhongwenTools::Conversion
6
-
7
- def zht?(str = nil)
8
- str ||= self
9
-
10
- str == convert(:zht, str) || str == convert(:zhhk, str)
11
- end
12
-
13
- def zhs?(str = nil)
14
- str ||= self
15
-
16
- str == convert(:zhs, str)
17
- end
18
- end
19
- end
@@ -1,28 +0,0 @@
1
- # encoding: utf-8
2
- require 'zhongwen_tools/numbers'
3
-
4
- module ZhongwenTools
5
- module Integer
6
- include ZhongwenTools::Numbers
7
- extend self
8
-
9
- def to_zh(type = nil)
10
- type == :zht ? self.to_zht? : self.to_zhs
11
- end
12
-
13
- def to_zhs(int = nil)
14
- int ||= self
15
- number_to_zhs :num, int.to_s
16
- end
17
-
18
- def to_zht(int = nil)
19
- int ||= self
20
- number_to_zht :num, int.to_s
21
- end
22
-
23
- def to_pyn(int = nil)
24
- int ||= self
25
- number_to_pyn int.to_s, :num
26
- end
27
- end
28
- end