pinny 0.1.0 → 0.1.1
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.
- data/Rakefile +3 -6
- data/lib/pinny.rb +12 -10
- data/pinny.gemspec +4 -4
- data/test/pinny_test.rb +5 -3
- metadata +18 -40
data/Rakefile
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
1
|
require "rubygems"
|
5
2
|
require "rubygems/package_task"
|
6
3
|
require "rdoc/task"
|
@@ -24,7 +21,7 @@ spec = Gem::Specification.new do |s|
|
|
24
21
|
|
25
22
|
# Change these as appropriate
|
26
23
|
s.name = "pinny"
|
27
|
-
s.version = "0.1.
|
24
|
+
s.version = "0.1.1"
|
28
25
|
s.summary = "Pinyin conversion tool"
|
29
26
|
s.author = "Matthew Rudy Jacobs"
|
30
27
|
s.email = "MatthewRudyJacobs@gmail.com"
|
@@ -53,7 +50,7 @@ end
|
|
53
50
|
# be automatically building a gem for this project. If you're not
|
54
51
|
# using GitHub, edit as appropriate.
|
55
52
|
#
|
56
|
-
# To publish your gem online, install the 'gemcutter' gem; Read more
|
53
|
+
# To publish your gem online, install the 'gemcutter' gem; Read more
|
57
54
|
# about that here: http://gemcutter.org/pages/gem_docs
|
58
55
|
Gem::PackageTask.new(spec) do |pkg|
|
59
56
|
pkg.gem_spec = spec
|
@@ -74,7 +71,7 @@ task :package => :gemspec
|
|
74
71
|
|
75
72
|
# Generate documentation
|
76
73
|
RDoc::Task.new do |rd|
|
77
|
-
|
74
|
+
|
78
75
|
rd.rdoc_files.include("lib/**/*.rb")
|
79
76
|
rd.rdoc_dir = "rdoc"
|
80
77
|
end
|
data/lib/pinny.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
module Pinny
|
2
|
-
|
4
|
+
|
3
5
|
TONES = {
|
4
6
|
"a" => [nil, "ā", "á", "ǎ", "à"],
|
5
7
|
"e" => [nil, "ē", "é", "ě", "è"],
|
@@ -8,7 +10,7 @@ module Pinny
|
|
8
10
|
"u" => [nil, "ū", "ú", "ǔ", "ù"],
|
9
11
|
"v" => [nil, "ǖ", "ǘ", "ǚ", "ǜ"]
|
10
12
|
}
|
11
|
-
|
13
|
+
|
12
14
|
module ModuleMethods
|
13
15
|
def to_pinyin(string)
|
14
16
|
string.split(/\b/).map do |word|
|
@@ -19,19 +21,19 @@ module Pinny
|
|
19
21
|
end
|
20
22
|
end.join("")
|
21
23
|
end
|
22
|
-
|
24
|
+
|
23
25
|
def is_pinyin?(word)
|
24
26
|
word =~ /^\w+[1-5]$/
|
25
27
|
end
|
26
|
-
|
28
|
+
|
27
29
|
def extract_tone(word)
|
28
30
|
tone = word.scan(/[1-4]$/).first
|
29
|
-
|
31
|
+
|
30
32
|
word.sub!(/\d$/, "")
|
31
|
-
|
33
|
+
|
32
34
|
tone && tone.to_i
|
33
35
|
end
|
34
|
-
|
36
|
+
|
35
37
|
def lowest_vowel(word)
|
36
38
|
case word
|
37
39
|
when /a/i then "a"
|
@@ -42,7 +44,7 @@ module Pinny
|
|
42
44
|
when /v/i then "v"
|
43
45
|
end
|
44
46
|
end
|
45
|
-
|
47
|
+
|
46
48
|
def add_tone_mark(word)
|
47
49
|
if t = extract_tone(word)
|
48
50
|
v = lowest_vowel(word)
|
@@ -53,8 +55,8 @@ module Pinny
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
56
|
-
|
58
|
+
|
57
59
|
extend ModuleMethods
|
58
|
-
|
60
|
+
|
59
61
|
end
|
60
62
|
|
data/pinny.gemspec
CHANGED
@@ -7,12 +7,12 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Matthew Rudy Jacobs"]
|
9
9
|
s.date = %q{2011-10-13}
|
10
|
-
s.email = %q{
|
11
|
-
s.files = ["lib/pinny.rb"]
|
12
|
-
s.homepage = %q{http://
|
10
|
+
s.email = %q{MatthewRudyJacobs@gmail.com}
|
11
|
+
s.files = ["pinny.gemspec", "Rakefile", "test/pinny_test.rb", "test/test_helper.rb", "lib/pinny.rb"]
|
12
|
+
s.homepage = %q{http://github.com/matthewrudy/pinny}
|
13
13
|
s.require_paths = ["lib"]
|
14
14
|
s.rubygems_version = %q{1.4.2}
|
15
|
-
s.summary = %q{
|
15
|
+
s.summary = %q{Pinyin conversion tool}
|
16
16
|
|
17
17
|
if s.respond_to? :specification_version then
|
18
18
|
s.specification_version = 3
|
data/test/pinny_test.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
require 'pinny'
|
3
5
|
|
4
6
|
class PinnyTest < ActiveSupport::TestCase
|
5
|
-
|
7
|
+
|
6
8
|
test "to_pinyin - simple" do
|
7
9
|
assert_equal "Ní hǎo", Pinny.to_pinyin("Ni2 hao3")
|
8
10
|
end
|
9
|
-
|
11
|
+
|
10
12
|
test "to_pinyin - capital A" do
|
11
13
|
assert_equal "Ai", Pinny.to_pinyin("Ai4")
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
end
|
metadata
CHANGED
@@ -1,71 +1,49 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pinny
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Matthew Rudy Jacobs
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-10-13 00:00:00 +08:00
|
19
|
-
default_executable:
|
12
|
+
date: 2012-12-31 00:00:00.000000000 Z
|
20
13
|
dependencies: []
|
21
|
-
|
22
14
|
description:
|
23
15
|
email: MatthewRudyJacobs@gmail.com
|
24
16
|
executables: []
|
25
|
-
|
26
17
|
extensions: []
|
27
|
-
|
28
18
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
files:
|
19
|
+
files:
|
31
20
|
- pinny.gemspec
|
32
21
|
- Rakefile
|
33
22
|
- test/pinny_test.rb
|
34
23
|
- test/test_helper.rb
|
35
24
|
- lib/pinny.rb
|
36
|
-
has_rdoc: true
|
37
25
|
homepage: http://github.com/matthewrudy/pinny
|
38
26
|
licenses: []
|
39
|
-
|
40
27
|
post_install_message:
|
41
28
|
rdoc_options: []
|
42
|
-
|
43
|
-
require_paths:
|
29
|
+
require_paths:
|
44
30
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
32
|
none: false
|
47
|
-
requirements:
|
48
|
-
- -
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
|
52
|
-
- 0
|
53
|
-
version: "0"
|
54
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
38
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
63
43
|
requirements: []
|
64
|
-
|
65
44
|
rubyforge_project:
|
66
|
-
rubygems_version: 1.
|
45
|
+
rubygems_version: 1.8.24
|
67
46
|
signing_key:
|
68
47
|
specification_version: 3
|
69
48
|
summary: Pinyin conversion tool
|
70
49
|
test_files: []
|
71
|
-
|