romajinizer 0.1.0 → 0.6.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d92ebecb493d05de75503b26967db9f594f2e2024aedf1d5dfda1e3062c8dca2
4
+ data.tar.gz: b8433fc90acbd21d0ca22a9439a3f5381f0b0e391a9f8c7aa3ee1b7478b480aa
5
+ SHA512:
6
+ metadata.gz: 77176b40c787db2f96bd16411a4fb4b4834db8ea89e11062e2048b4538990135aab37ba7125a7ecb9021d7af1a6174770ebec87392c24442827006bab222ea87
7
+ data.tar.gz: ee141ea24828df2577aa4423af77a56aad748475af681432d7d88dac6761a98209c8b5283771558b14368b662855bfc294053fb8ba736eaff97ca8ffff624927
data/Gemfile CHANGED
@@ -1,13 +1,6 @@
1
1
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
2
 
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "rspec", "~> 2.3.0"
10
- gem "bundler", "~> 1.0.0"
11
- gem "jeweler", "~> 1.5.2"
12
- gem "rcov", ">= 0"
3
+ group :development, :test do
4
+ gem "rspec"
5
+ gem "jeweler"
13
6
  end
data/Gemfile.lock CHANGED
@@ -1,28 +1,78 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- diff-lcs (1.1.2)
5
- git (1.2.5)
6
- jeweler (1.5.2)
7
- bundler (~> 1.0.0)
4
+ addressable (2.4.0)
5
+ builder (3.2.4)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ diff-lcs (1.4.4)
9
+ faraday (0.9.2)
10
+ multipart-post (>= 1.2, < 3)
11
+ git (1.8.1)
12
+ rchardet (~> 1.8)
13
+ github_api (0.16.0)
14
+ addressable (~> 2.4.0)
15
+ descendants_tracker (~> 0.0.4)
16
+ faraday (~> 0.8, < 0.10)
17
+ hashie (>= 3.4)
18
+ mime-types (>= 1.16, < 3.0)
19
+ oauth2 (~> 1.0)
20
+ hashie (4.1.0)
21
+ highline (2.0.3)
22
+ jeweler (2.3.9)
23
+ builder
24
+ bundler
8
25
  git (>= 1.2.5)
26
+ github_api (~> 0.16.0)
27
+ highline (>= 1.6.15)
28
+ nokogiri (>= 1.5.10)
29
+ psych
9
30
  rake
10
- rake (0.8.7)
11
- rcov (0.9.9)
12
- rspec (2.3.0)
13
- rspec-core (~> 2.3.0)
14
- rspec-expectations (~> 2.3.0)
15
- rspec-mocks (~> 2.3.0)
16
- rspec-core (2.3.1)
17
- rspec-expectations (2.3.0)
18
- diff-lcs (~> 1.1.2)
19
- rspec-mocks (2.3.0)
31
+ rdoc
32
+ semver2
33
+ jwt (2.2.2)
34
+ mime-types (2.99.3)
35
+ mini_portile2 (2.5.0)
36
+ multi_json (1.15.0)
37
+ multi_xml (0.6.0)
38
+ multipart-post (2.1.1)
39
+ nokogiri (1.11.1)
40
+ mini_portile2 (~> 2.5.0)
41
+ racc (~> 1.4)
42
+ oauth2 (1.4.4)
43
+ faraday (>= 0.8, < 2.0)
44
+ jwt (>= 1.0, < 3.0)
45
+ multi_json (~> 1.3)
46
+ multi_xml (~> 0.5)
47
+ rack (>= 1.2, < 3)
48
+ psych (3.3.1)
49
+ racc (1.5.2)
50
+ rack (2.2.3)
51
+ rake (10.5.0)
52
+ rchardet (1.8.0)
53
+ rdoc (6.3.0)
54
+ rspec (3.10.0)
55
+ rspec-core (~> 3.10.0)
56
+ rspec-expectations (~> 3.10.0)
57
+ rspec-mocks (~> 3.10.0)
58
+ rspec-core (3.10.1)
59
+ rspec-support (~> 3.10.0)
60
+ rspec-expectations (3.10.1)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.10.0)
63
+ rspec-mocks (3.10.2)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.10.0)
66
+ rspec-support (3.10.2)
67
+ semver2 (3.4.2)
68
+ thread_safe (0.3.6)
20
69
 
21
70
  PLATFORMS
22
71
  ruby
23
72
 
24
73
  DEPENDENCIES
25
- bundler (~> 1.0.0)
26
- jeweler (~> 1.5.2)
27
- rcov
28
- rspec (~> 2.3.0)
74
+ jeweler
75
+ rspec
76
+
77
+ BUNDLED WITH
78
+ 1.17.3
@@ -1,8 +1,22 @@
1
- = romajinizer
1
+ Romajinizer
2
+ =====
2
3
 
3
- Description goes here.
4
+ A gem for helping you convert between Japanese hiragana, katakana, and Roman romaji alphabets. Please note that this gem is not used for converting kanji (libraries such as MeCab would be much more beneficial)
4
5
 
5
- == Contributing to romajinizer
6
+ Usage
7
+ =====
8
+
9
+ ### Getting Started
10
+
11
+ gem install romajinizer
12
+
13
+ ### Examples
14
+
15
+ Check out romajinizer_spec.rb under the spec/ folder for clear examples on how to best use this library.
16
+
17
+
18
+ Contributing to romajinizer
19
+ =====
6
20
 
7
21
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
22
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
@@ -12,7 +26,8 @@ Description goes here.
12
26
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
27
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
28
 
15
- == Copyright
29
+ Copyright
30
+ =====
16
31
 
17
32
  Copyright (c) 2011 Joe Ellis. See LICENSE.txt for
18
33
  further details.
data/Rakefile CHANGED
@@ -32,14 +32,9 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
32
32
  spec.pattern = FileList['spec/**/*_spec.rb']
33
33
  end
34
34
 
35
- RSpec::Core::RakeTask.new(:rcov) do |spec|
36
- spec.pattern = 'spec/**/*_spec.rb'
37
- spec.rcov = true
38
- end
39
-
40
35
  task :default => :spec
41
36
 
42
- require 'rake/rdoctask'
37
+ require 'rdoc/task'
43
38
  Rake::RDocTask.new do |rdoc|
44
39
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
40
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.6.0
data/lib/romajinizer.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  #
4
- # kana2rom.rb
4
+ # to_romaji.rb
5
5
  # A Ruby module for converting between hiragana, katakana and romaji.
6
6
  #
7
7
  # ---------------------------------------------------------------------------------
@@ -11,32 +11,60 @@
11
11
  #
12
12
  # ---------------------------------------------------------------------------------
13
13
  # Paul Chapman (paul [a../t] longweekendmobile 2010-04-01)
14
- # Repaired script to work with modern Ruby versions (1.86+), added comments,
14
+ # Repaired script to work with modern Ruby versions (1.86+), added comments,
15
15
  # made it support gaijin friendly transliterations!
16
16
  # ---------------------------------------------------------------------------------
17
17
 
18
18
  # ---------------------------------------------------------------------------------
19
19
  # Joe Ellis (joe at squarefour.net 2011-03-09)
20
- # Added a few more edge cases ('n romaji support),
21
- # Started gemifications so it can easily be used in any project
20
+ # Added a few more edge cases ('n romaji support),
21
+ # Started gemifications so it can easily be used in any project
22
22
  # Added normalization for double nn so that こんばn will still be converted to こんばん properly
23
23
  # ---------------------------------------------------------------------------------
24
24
 
25
25
  # USAGE
26
26
  #
27
- # Include kana2rom
27
+ # Include Kana2rom
28
28
  #
29
- # kana2rom(str) かな --> ロ-マ字 変換 / hira/katakana ->> romaji conv
30
- # rom2kata(str) ロ-マ字 --> 片仮名 変換 / romaji --> katakana conv
31
- # rom2hira(str) ロ-マ字 --> 平仮名 変換 / romaji --> hiragana conv
32
- # hira2kata(str) 平仮名 --> 片仮名 変換 / hiragana --> katakana conv
33
- # kata2hira(str) 片仮名 --> 平仮名 変換 / katakana ->> hiragana conv
29
+ # to_romaji(str) かな --> ロ-マ字 変換 / hira/katakana ->> romaji conv
30
+ # to_katakana(str) ロ-マ字 --> 片仮名 変換 / romaji --> katakana conv
31
+ # to_hiragana(str) ロ-マ字 --> 平仮名 変換 / romaji --> hiragana conv
32
+ # hira_to_kata(str) 平仮名 --> 片仮名 変換 / hiragana --> katakana conv
33
+ # kata_to_hira(str) 片仮名 --> 平仮名 変換 / katakana ->> hiragana conv
34
34
  # kana2kana(str) attempts either to either, returns unique strings only
35
35
  #
36
36
  # ---------------------------------------------------------------------------------
37
37
 
38
38
  module Kana2rom
39
39
 
40
+ NotKanaCharacters = [
41
+ '〜', '$', '#', '@', '!', '%', '^', '&', '*', '(', ')',
42
+ '_', 'ー', '+','=', '?', '>', '<', '、', '。', '/',
43
+ '』','『', '「', '」', '`'
44
+ ]
45
+
46
+ HiraganaCharacters = [
47
+ ' ', ' ', '々', 'っ', 'ょ', 'ゃ', 'ゅ', 'あ', 'い', 'う',
48
+ 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ', 'し', 'す', 'せ',
49
+ 'そ', 'た', 'ち', 'つ', 'て', 'と', 'な', 'に', 'ぬ', 'ね', 'の',
50
+ 'は', 'ひ', 'ふ', 'へ', 'ほ', 'ま', 'み', 'む', 'め', 'も', 'や',
51
+ 'ゆ', 'よ', 'ら', 'り', 'る', 'れ', 'ろ', 'わ', 'ゐ', 'ゑ', 'を',
52
+ 'ん', 'が', 'ぎ', 'ぐ', 'げ', 'ご', 'ざ', 'じ', 'ず', 'ぜ', 'ぞ',
53
+ 'だ', 'ぢ', 'づ', 'で', 'ど', 'ば', 'び', 'ぶ', 'べ', 'ぼ', 'ぱ',
54
+ 'ぴ', 'ぷ', 'ぺ', 'ぽ', 'ヶ'
55
+ ]
56
+
57
+ KatakanaCharacters = [
58
+ 'ョ', 'ャ', 'ュ', 'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク',
59
+ 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ',
60
+ 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ',
61
+ 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル',
62
+ 'レ', 'ロ', 'ワ', 'ゐ', 'ゑ', 'ヲ', 'ン', 'ガ', 'ギ', 'グ', 'ゲ',
63
+ 'ゴ', 'ザ', 'ジ', 'ズ', 'ゼ', 'ゾ', 'ダ', 'ヅ', 'ヂ', 'ズ', 'デ',
64
+ 'ド', 'バ', 'ビ', 'ブ', 'ベ', 'ボ', 'パ', 'ピ', 'プ', 'ペ', 'ポ'
65
+ ]
66
+
67
+
40
68
  Kana2romH={
41
69
  "ア"=>"a", "イ"=>"i", "ウ"=>"u", "エ"=>"e","オ"=>"o",
42
70
  "あ"=>"a", "い"=>"i", "う"=>"u", "え"=>"e","お"=>"o",
@@ -78,7 +106,7 @@ module Kana2rom
78
106
  ":"=>":", " " => " ", "@" => "@", "(" => "(", ")" => ")",
79
107
  " " => " "
80
108
  }
81
-
109
+
82
110
  Kana2romH2={
83
111
  "てぃ" => "ti", "でぃ" => "di"
84
112
  }
@@ -92,23 +120,23 @@ module Kana2rom
92
120
  "xa"=>"ァ", "xi"=>"ィ", "xu"=>"ゥ", "xe"=>"ェ", "xo"=>"ォ",
93
121
  "ka"=>"カ", "ki"=>"キ", "ku"=>"ク", "ke"=>"ケ", "ko"=>"コ",
94
122
  "ca"=>"カ", "cu"=>"ク", "co"=>"コ",
95
- "ga"=>"ガ", "gi"=>"ギ", "gu"=>"グ", "ge"=>"ゲ", "go"=>"ゴ",
96
- "sa"=>"サ", "si"=>"シ", "su"=>"ス", "se"=>"セ", "so"=>"ソ",
123
+ "ga"=>"ガ", "gi"=>"ギ", "gu"=>"グ", "ge"=>"ゲ", "go"=>"ゴ",
124
+ "sa"=>"サ", "si"=>"シ", "su"=>"ス", "se"=>"セ", "so"=>"ソ",
97
125
  "za"=>"ザ", "zi"=>"ジ", "zu"=>"ズ", "ze"=>"ゼ", "zo"=>"ゾ",
98
- "ja"=>"ジャ","ji"=>"ジ", "ju"=>"ジュ","je"=>"ジェ","jo"=>"ジョ",
99
- "ta"=>"タ", "ti"=>"チ", "tsu"=>"ツ", "te"=>"テ", "to"=>"ト",
100
- "da"=>"ダ", "di"=>"ヂ", "du"=>"ヅ", "de"=>"デ", "do"=>"ド",
101
- "na"=>"ナ", "ni"=>"ニ", "nu"=>"ヌ", "ne"=>"ネ", "no"=>"ノ",
102
- "ha"=>"ハ", "hi"=>"ヒ", "hu"=>"フ", "he"=>"ヘ", "ho"=>"ホ",
103
- "ba"=>"バ", "bi"=>"ビ", "bu"=>"ブ", "be"=>"ベ", "bo"=>"ボ",
104
- "pa"=>"パ", "pi"=>"ピ", "pu"=>"プ", "pe"=>"ペ", "po"=>"ポ",
105
- "va"=>"ヴァ","vi"=>"ヴィ","vu"=>"ヴ", "ve"=>"ヴェ","vo"=>"ヴォ",
106
- "fa"=>"ファ","fi"=>"フィ","fu"=>"フ", "fe"=>"フェ","fo"=>"フォ",
107
- "ma"=>"マ", "mi"=>"ミ", "mu"=>"ム", "me"=>"メ", "mo"=>"モ",
108
- "ya"=>"ヤ", "yi"=>"イ", "yu"=>"ユ", "ye"=>"イェ", "yo"=>"ヨ",
109
- "ra"=>"ラ", "ri"=>"リ", "ru"=>"ル", "re"=>"レ", "ro"=>"ロ",
110
- "la"=>"ラ", "li"=>"リ", "lu"=>"ル", "le"=>"レ", "lo"=>"ロ",
111
- "wa"=>"ワ", "wi"=>"ヰ", "wu"=>"ウ", "we"=>"ヱ", "wo"=>"ヲ",
126
+ "ja"=>"ジャ","ji"=>"ジ", "ju"=>"ジュ","je"=>"ジェ","jo"=>"ジョ",
127
+ "ta"=>"タ", "ti"=>"チ", "tsu"=>"ツ", "te"=>"テ", "to"=>"ト",
128
+ "da"=>"ダ", "di"=>"ヂ", "du"=>"ヅ", "de"=>"デ", "do"=>"ド",
129
+ "na"=>"ナ", "ni"=>"ニ", "nu"=>"ヌ", "ne"=>"ネ", "no"=>"ノ",
130
+ "ha"=>"ハ", "hi"=>"ヒ", "hu"=>"フ", "he"=>"ヘ", "ho"=>"ホ",
131
+ "ba"=>"バ", "bi"=>"ビ", "bu"=>"ブ", "be"=>"ベ", "bo"=>"ボ",
132
+ "pa"=>"パ", "pi"=>"ピ", "pu"=>"プ", "pe"=>"ペ", "po"=>"ポ",
133
+ "va"=>"ヴァ","vi"=>"ヴィ","vu"=>"ヴ", "ve"=>"ヴェ","vo"=>"ヴォ",
134
+ "fa"=>"ファ","fi"=>"フィ","fu"=>"フ", "fe"=>"フェ","fo"=>"フォ",
135
+ "ma"=>"マ", "mi"=>"ミ", "mu"=>"ム", "me"=>"メ", "mo"=>"モ",
136
+ "ya"=>"ヤ", "yi"=>"イ", "yu"=>"ユ", "ye"=>"イェ", "yo"=>"ヨ",
137
+ "ra"=>"ラ", "ri"=>"リ", "ru"=>"ル", "re"=>"レ", "ro"=>"ロ",
138
+ "la"=>"ラ", "li"=>"リ", "lu"=>"ル", "le"=>"レ", "lo"=>"ロ",
139
+ "wa"=>"ワ", "wi"=>"ヰ", "wu"=>"ウ", "we"=>"ヱ", "wo"=>"ヲ",
112
140
  "nn"=>"ン"
113
141
  }
114
142
 
@@ -117,23 +145,23 @@ module Kana2rom
117
145
  "tsu"=>"ツ",
118
146
  "xka"=>"ヵ", "xke"=>"ヶ",
119
147
  "xwa"=>"ヮ", "xtsu"=>"ッ", "xya"=>"ャ", "xyu"=>"ュ", "xyo"=>"ョ",
120
- "kya"=>"キャ", "kyi"=>"キィ", "kyu"=>"キュ", "kye"=>"キェ", "kyo"=>"キョ",
121
- "gya"=>"ギャ", "gyi"=>"ギィ", "gyu"=>"ギュ", "gye"=>"ギェ", "gyo"=>"ギョ",
122
- "sya"=>"シャ", "syi"=>"シィ", "syu"=>"シュ", "sye"=>"シェ", "syo"=>"ショ",
123
- "sha"=>"シャ", "shi"=>"シ", "shu"=>"シュ", "she"=>"シェ", "sho"=>"ショ",
124
- "zya"=>"ジャ", "zyi"=>"ジィ", "zyu"=>"ジュ", "zye"=>"ジェ", "zyo"=>"ジョ",
148
+ "kya"=>"キャ", "kyi"=>"キィ", "kyu"=>"キュ", "kye"=>"キェ", "kyo"=>"キョ",
149
+ "gya"=>"ギャ", "gyi"=>"ギィ", "gyu"=>"ギュ", "gye"=>"ギェ", "gyo"=>"ギョ",
150
+ "sya"=>"シャ", "syi"=>"シィ", "syu"=>"シュ", "sye"=>"シェ", "syo"=>"ショ",
151
+ "sha"=>"シャ", "shi"=>"シ", "shu"=>"シュ", "she"=>"シェ", "sho"=>"ショ",
152
+ "zya"=>"ジャ", "zyi"=>"ジィ", "zyu"=>"ジュ", "zye"=>"ジェ", "zyo"=>"ジョ",
125
153
  "jya"=>"ジャ", "jyi"=>"ジィ", "jyu"=>"ジュ", "jye"=>"ジェ", "jyo"=>"ジョ",
126
- "tya"=>"チャ", "tyi"=>"チィ", "tyu"=>"チュ", "tye"=>"チェ", "tyo"=>"チョ",
127
- "cya"=>"チャ", "cyi"=>"チィ", "cyu"=>"チュ", "cye"=>"チェ", "cyo"=>"チョ",
128
- "cha"=>"チャ", "chi"=>"チ", "chu"=>"チュ", "che"=>"チェ", "cho"=>"チョ",
129
- "tha"=>"テャ", "thi"=>"ティ", "thu"=>"テュ", "the"=>"テェ", "tho"=>"テョ",
130
- "dya"=>"ヂャ", "dyi"=>"ヂィ", "dyu"=>"ヂュ", "dye"=>"ヂェ", "dyo"=>"ヂョ",
131
- "dha"=>"デャ", "dhi"=>"ディ", "dhu"=>"デュ", "dhe"=>"デェ", "dho"=>"デョ",
154
+ "tya"=>"チャ", "tyi"=>"チィ", "tyu"=>"チュ", "tye"=>"チェ", "tyo"=>"チョ",
155
+ "cya"=>"チャ", "cyi"=>"チィ", "cyu"=>"チュ", "cye"=>"チェ", "cyo"=>"チョ",
156
+ "cha"=>"チャ", "chi"=>"チ", "chu"=>"チュ", "che"=>"チェ", "cho"=>"チョ",
157
+ "tha"=>"テャ", "thi"=>"ティ", "thu"=>"テュ", "the"=>"テェ", "tho"=>"テョ",
158
+ "dya"=>"ヂャ", "dyi"=>"ヂィ", "dyu"=>"ヂュ", "dye"=>"ヂェ", "dyo"=>"ヂョ",
159
+ "dha"=>"デャ", "dhi"=>"ディ", "dhu"=>"デュ", "dhe"=>"デェ", "dho"=>"デョ",
132
160
  "nya"=>"ニャ", "nyi"=>"ニィ", "nyu"=>"ニュ", "nye"=>"ニェ", "nyo"=>"ニョ",
133
- "hya"=>"ヒャ", "hyi"=>"ヒィ", "hyu"=>"ヒュ", "hye"=>"ヒェ", "hyo"=>"ヒョ",
134
- "bya"=>"ビャ", "byi"=>"ビィ", "byu"=>"ビュ", "bye"=>"ビェ", "byo"=>"ビョ",
135
- "pya"=>"ピャ", "pyi"=>"ピィ", "pyu"=>"ピュ", "pye"=>"ピェ", "pyo"=>"ピョ",
136
- "mya"=>"ミャ", "myi"=>"ミィ", "myu"=>"ミュ", "mye"=>"ミェ", "myo"=>"ミョ",
161
+ "hya"=>"ヒャ", "hyi"=>"ヒィ", "hyu"=>"ヒュ", "hye"=>"ヒェ", "hyo"=>"ヒョ",
162
+ "bya"=>"ビャ", "byi"=>"ビィ", "byu"=>"ビュ", "bye"=>"ビェ", "byo"=>"ビョ",
163
+ "pya"=>"ピャ", "pyi"=>"ピィ", "pyu"=>"ピュ", "pye"=>"ピェ", "pyo"=>"ピョ",
164
+ "mya"=>"ミャ", "myi"=>"ミィ", "myu"=>"ミュ", "mye"=>"ミェ", "myo"=>"ミョ",
137
165
  "rya"=>"リャ", "ryi"=>"リィ", "ryu"=>"リュ", "rye"=>"リェ", "ryo"=>"リョ",
138
166
  "lya"=>"リャ", "lyi"=>"リィ", "lyu"=>"リュ", "lye"=>"リェ", "lyo"=>"リョ"
139
167
  }
@@ -158,19 +186,19 @@ module Kana2rom
158
186
  "ッ"=>"っ", "ャ"=>"ゃ", "ュ"=>"ゅ", "ョ"=>"ょ",
159
187
  "ヴ"=>"う゛", "ヵ"=>"か", "ヶ"=>"が", "ヮ"=>"ゎ"
160
188
  }
161
-
189
+
162
190
  Hira2kataH={}; Kata2hiraH.each_pair{|k,v| Hira2kataH[v]=k}; Hira2kataH["か"]="カ"; Hira2kataH["が"]="ガ"
163
191
 
164
- def kana2rom
192
+ def to_romaji
165
193
  s=""
166
194
  self.each_char do |c|
167
195
  if (Kana2romH.key?(c))
168
196
  s += Kana2romH[c]
169
- else
197
+ else
170
198
  s += c
171
199
  end
172
200
  end
173
-
201
+
174
202
  s=s.gsub(/(k)([aiueo])(")/,'g\2').gsub(/(s)([aiueo])(")/,'z\2').gsub(/(t)([aiueo])(")/,'d\2')
175
203
  s=s.gsub(/(h)([aiueo])(")/,'b\2').gsub(/([fh])([aiueo])(')/,'p\2').gsub(/u"/,'vu') # [半]濁点゛゜
176
204
  #---------------------------------------------------------
@@ -216,22 +244,22 @@ module Kana2rom
216
244
  #---------------------------------------------------------
217
245
  return s
218
246
  end
219
-
220
- def rom2kata
247
+
248
+ def to_katakana
221
249
  ## THIS LINE DOES NOT WORK IN RECENT RUBY VERSIONS!!! r=""; w=[]; chars=str.split(//e)
222
- result=""
250
+ result=""
223
251
  word_buffer=[]
224
252
  chars=self.each_char.collect{|c| c}
225
253
  loop do
226
254
  case word_buffer.size
227
- ##### When 0 characters in the buffer
255
+ ##### When 0 characters in the buffer
228
256
  when 0 then
229
257
  if chars.size > 0
230
- word_buffer.push(chars.shift)
258
+ word_buffer.push(chars.shift)
231
259
  else
232
260
  return result
233
261
  end
234
- ##### Patterns with 1 roman character
262
+ ##### Patterns with 1 roman character
235
263
  when 1 then
236
264
  if word_buffer[0] =~ /[aiueo-]/
237
265
  result += Rom2KataH1[word_buffer[0]]
@@ -239,14 +267,14 @@ module Kana2rom
239
267
  elsif word_buffer[0] =~ /[xkcgszjtdnhbpvfmyrlw']/
240
268
  if chars.size > 0
241
269
  word_buffer.push(chars.shift)
242
- else
243
- return result + (word_buffer[0].gsub(/n/,"ン"))
270
+ else
271
+ return result + (word_buffer[0].gsub(/n/,"ン"))
244
272
  end
245
- else
273
+ else
246
274
  result += word_buffer.shift
247
275
  end
248
- ##### Patterns with 2 roman characters
249
- when 2 then
276
+ ##### Patterns with 2 roman characters
277
+ when 2 then
250
278
  if Rom2KataH2.key?(word_buffer.join)
251
279
  result += Rom2KataH2[word_buffer.join]
252
280
  word_buffer = []
@@ -254,47 +282,47 @@ module Kana2rom
254
282
  if chars.size > 0
255
283
  # Consume next letter from source array
256
284
  word_buffer.push(chars.shift)
257
- else
285
+ else
258
286
  return result + (word_buffer.join.gsub(/n/,"ン"))
259
287
  end
260
288
  elsif word_buffer.join == "n'"
261
289
  result += "ン"
262
290
  word_buffer.shift(2) # n'--> ン
263
- elsif word_buffer[0] == "n"
291
+ elsif word_buffer[0] == "n"
264
292
  result += "ン"
265
293
  word_buffer.shift # nk-->ンk
266
294
  elsif word_buffer[0] == word_buffer[1]
267
295
  result += "ッ"
268
296
  word_buffer.shift # kk-->ッk
269
- else
297
+ else
270
298
  result += word_buffer.shift;
271
299
  end
272
- ##### Patterns with 3 roman characters
300
+ ##### Patterns with 3 roman characters
273
301
  when 3 then
274
302
  if Rom2KataH3.key?(word_buffer.join)
275
- result += Rom2KataH3[word_buffer.join]
303
+ result += Rom2KataH3[word_buffer.join]
276
304
  word_buffer=[]
277
- elsif word_buffer[0] == "n"
305
+ elsif word_buffer[0] == "n"
278
306
  result += "ン"
279
307
  word_buffer.shift
280
- else
308
+ else
281
309
  result += word_buffer.shift
282
310
  end
283
311
  end
284
312
  end
285
313
  end
286
-
287
- def kata2hira(str)
314
+
315
+ def kata_to_hira(str)
288
316
  s=""; str.each_char{|c| s+=( Kata2hiraH.key?(c) ? Kata2hiraH[c] : c )}
289
317
  s.normalize_double_n!
290
318
  return s
291
319
  end
292
320
 
293
- def hira2kata(str)
321
+ def hira_to_kata(str)
294
322
  s=""; str.each_char{|c|if(Hira2kataH.key?(c))then s+=Hira2kataH[c];else s+=c; end}
295
323
  return s
296
324
  end
297
-
325
+
298
326
  def normalize_double_n
299
327
  self.gsub(/n\'(?=[^aiueoyn]|$)/, "n")
300
328
  end
@@ -307,24 +335,51 @@ module Kana2rom
307
335
  # Added by Paul 2009-05-12 22:31
308
336
  def kana2kana(str1)
309
337
  result = []
310
- str2 = Kana2rom::hira2kata(str1)
311
- str3 = Kana2rom::kata2hira(str1)
338
+ str2 = Kana2rom::hira_to_kata(str1)
339
+ str3 = Kana2rom::kata_to_hira(str1)
312
340
  result << str1
313
341
  result << str2 if str2.length > 0 and str1 !=str2
314
342
  result << str3 if str3.length > 0 and str2 !=str3 and str3 != str1
315
343
  return result
316
344
  end
317
-
318
- def rom2hira
319
- return kata2hira(rom2kata)
345
+
346
+ def to_hiragana
347
+ return kata_to_hira(to_katakana)
348
+ end
349
+
350
+ def is_kana?
351
+ if HiraganaCharacters.include?(self) || !KatakanaCharacters.include?(self)
352
+ return true
353
+ end
354
+ return false
355
+ end
356
+
357
+ def is_kanji?
358
+ if !HiraganaCharacters.include?(self) && !KatakanaCharacters.include?(self) && !NotKanaCharacters.include?(self)
359
+ return true
360
+ end
361
+ return false
362
+ end
363
+
364
+ def is_only_kana?
365
+ self.each_char do |character|
366
+ if !HiraganaCharacters.include?(character) && !KatakanaCharacters.include?(character)
367
+ return false
368
+ end
369
+ end
370
+ return true
320
371
  end
321
-
322
- alias :to_hiragana :rom2hira
323
- alias :to_katakana :rom2kata
324
- alias :to_romaji :kana2rom
325
372
 
373
+ def contains_kana?
374
+ self.each_char do |character|
375
+ if HiraganaCharacters.include?(character) || KatakanaCharacters.include?(character)
376
+ return true
377
+ end
378
+ end
379
+ return false
380
+ end
326
381
  end
327
382
 
328
383
  class String
329
384
  include Kana2rom
330
- end
385
+ end
data/romajinizer.gemspec CHANGED
@@ -2,19 +2,21 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: romajinizer 0.6.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = %q{romajinizer}
8
- s.version = "0.1.0"
8
+ s.name = "romajinizer".freeze
9
+ s.version = "0.6.0"
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Joe Ellis"]
12
- s.date = %q{2011-07-22}
13
- s.description = %q{A gem for converting between hiragana, katakana, and romaji}
14
- s.email = %q{joe@squarefour.net}
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Joe Ellis".freeze]
14
+ s.date = "2021-03-09"
15
+ s.description = "A gem for converting between hiragana, katakana, and romaji".freeze
16
+ s.email = "joe@squarefour.net".freeze
15
17
  s.extra_rdoc_files = [
16
18
  "LICENSE.txt",
17
- "README.rdoc"
19
+ "README.markdown"
18
20
  ]
19
21
  s.files = [
20
22
  ".document",
@@ -22,7 +24,7 @@ Gem::Specification.new do |s|
22
24
  "Gemfile",
23
25
  "Gemfile.lock",
24
26
  "LICENSE.txt",
25
- "README.rdoc",
27
+ "README.markdown",
26
28
  "Rakefile",
27
29
  "VERSION",
28
30
  "lib/romajinizer.rb",
@@ -30,35 +32,24 @@ Gem::Specification.new do |s|
30
32
  "spec/romajinizer_spec.rb",
31
33
  "spec/spec_helper.rb"
32
34
  ]
33
- s.homepage = %q{http://github.com/joeellis/romajinizer}
34
- s.licenses = ["MIT"]
35
- s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.6.2}
37
- s.summary = %q{A gem for converting between hiragana, katakana, and romaji}
38
- s.test_files = [
39
- "spec/romajinizer_spec.rb",
40
- "spec/spec_helper.rb"
41
- ]
35
+ s.homepage = "http://github.com/joeellis/romajinizer".freeze
36
+ s.licenses = ["MIT".freeze]
37
+ s.rubygems_version = "2.7.6.2".freeze
38
+ s.summary = "A gem for converting between hiragana, katakana, and romaji".freeze
42
39
 
43
40
  if s.respond_to? :specification_version then
44
- s.specification_version = 3
41
+ s.specification_version = 4
45
42
 
46
43
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
48
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
50
- s.add_development_dependency(%q<rcov>, [">= 0"])
44
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
45
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
51
46
  else
52
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
53
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
55
- s.add_dependency(%q<rcov>, [">= 0"])
47
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
48
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
56
49
  end
57
50
  else
58
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
59
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
61
- s.add_dependency(%q<rcov>, [">= 0"])
51
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
52
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
62
53
  end
63
54
  end
64
55
 
@@ -3,26 +3,47 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
4
  describe "Romajinizer" do
5
5
  it "should convert romaji to hiragana properly" do
6
- "tsukue".to_hiragana.should == "つくえ"
7
- "kinnyoubi".to_hiragana.should == "きんようび"
8
- "kin'youbi".to_hiragana.should == "きんようび"
9
- "konnya".to_hiragana.should == "こんや"
10
- "konnnichi".to_hiragana.should == "こんにち"
11
- "kaetta".to_hiragana.should == "かえった"
12
- end
13
-
6
+ expect("tsukue".to_hiragana).to eq("つくえ")
7
+ expect("kinnyoubi".to_hiragana).to eq("きんようび")
8
+ expect("kin'youbi".to_hiragana).to eq("きんようび")
9
+ expect("konnya".to_hiragana).to eq("こんや")
10
+ expect("konnnichi".to_hiragana).to eq("こんにち")
11
+ expect("kaetta".to_hiragana).to eq("かえった")
12
+ end
13
+
14
14
  it "should convert romaji to katakana properly" do
15
- "tsukue".to_katakana.should == "ツクエ"
15
+ expect("tsukue".to_katakana).to eq("ツクエ")
16
16
  end
17
-
17
+
18
18
  it "should convert kana to romaji properly" do
19
- "つくえ".to_romaji.should == "tsukue"
20
- "きんようび".to_romaji.should == "kinyoubi"
21
- "こんや".to_romaji.should == "konya"
22
- "こんにち".to_romaji.should == "konnichi"
19
+ expect("つくえ".to_romaji).to eq("tsukue")
20
+ expect("きんようび".to_romaji).to eq("kinyoubi")
21
+ expect("こんや".to_romaji).to eq("konya")
22
+ expect("こんにち".to_romaji).to eq("konnichi")
23
23
  end
24
-
24
+
25
25
  it "should convert kana to kana" do
26
- "こんばn".to_hiragana.should == "こんばん"
26
+ expect("こんばn".to_hiragana).to eq("こんばん")
27
+ end
28
+
29
+ it "should be able to tell if a word contains anything else but kana" do
30
+ expect("行きます".is_only_kana?).to eq(false)
31
+ expect("いきます".is_only_kana?).to eq(true)
32
+ end
33
+
34
+ it "should be able to tell if a word contains kana" do
35
+ expect("行きます".contains_kana?).to eq(true)
36
+ expect("abcdefg".contains_kana?).to eq(false)
37
+ end
38
+
39
+ it "should be able to tell if a character is a kana character" do
40
+ expect("す".is_kana?).to eq(true)
41
+ end
42
+
43
+ it "should be able to tell if a character is a kanji character" do
44
+ expect("行".is_kanji?).to eq(true)
45
+ expect("あ".is_kanji?).to eq(false)
46
+ expect("ア".is_kanji?).to eq(false)
47
+ expect("〜".is_kanji?).to eq(false)
27
48
  end
28
49
  end
metadata CHANGED
@@ -1,110 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: romajinizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Joe Ellis
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-07-22 00:00:00.000000000 -05:00
13
- default_executable:
11
+ date: 2021-03-09 00:00:00.000000000 Z
14
12
  dependencies:
15
13
  - !ruby/object:Gem::Dependency
16
14
  name: rspec
17
- requirement: &2151943680 !ruby/object:Gem::Requirement
18
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
19
16
  requirements:
20
- - - ~>
17
+ - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 2.3.0
19
+ version: '0'
23
20
  type: :development
24
21
  prerelease: false
25
- version_requirements: *2151943680
26
- - !ruby/object:Gem::Dependency
27
- name: bundler
28
- requirement: &2151942060 !ruby/object:Gem::Requirement
29
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
- - - ~>
24
+ - - ">="
32
25
  - !ruby/object:Gem::Version
33
- version: 1.0.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: *2151942060
26
+ version: '0'
37
27
  - !ruby/object:Gem::Dependency
38
28
  name: jeweler
39
- requirement: &2151940200 !ruby/object:Gem::Requirement
40
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
41
30
  requirements:
42
- - - ~>
31
+ - - ">="
43
32
  - !ruby/object:Gem::Version
44
- version: 1.5.2
33
+ version: '0'
45
34
  type: :development
46
35
  prerelease: false
47
- version_requirements: *2151940200
48
- - !ruby/object:Gem::Dependency
49
- name: rcov
50
- requirement: &2151938300 !ruby/object:Gem::Requirement
51
- none: false
36
+ version_requirements: !ruby/object:Gem::Requirement
52
37
  requirements:
53
- - - ! '>='
38
+ - - ">="
54
39
  - !ruby/object:Gem::Version
55
40
  version: '0'
56
- type: :development
57
- prerelease: false
58
- version_requirements: *2151938300
59
41
  description: A gem for converting between hiragana, katakana, and romaji
60
42
  email: joe@squarefour.net
61
43
  executables: []
62
44
  extensions: []
63
45
  extra_rdoc_files:
64
46
  - LICENSE.txt
65
- - README.rdoc
47
+ - README.markdown
66
48
  files:
67
- - .document
68
- - .rspec
49
+ - ".document"
50
+ - ".rspec"
69
51
  - Gemfile
70
52
  - Gemfile.lock
71
53
  - LICENSE.txt
72
- - README.rdoc
54
+ - README.markdown
73
55
  - Rakefile
74
56
  - VERSION
75
57
  - lib/romajinizer.rb
76
58
  - romajinizer.gemspec
77
59
  - spec/romajinizer_spec.rb
78
60
  - spec/spec_helper.rb
79
- has_rdoc: true
80
61
  homepage: http://github.com/joeellis/romajinizer
81
62
  licenses:
82
63
  - MIT
83
- post_install_message:
64
+ metadata: {}
65
+ post_install_message:
84
66
  rdoc_options: []
85
67
  require_paths:
86
68
  - lib
87
69
  required_ruby_version: !ruby/object:Gem::Requirement
88
- none: false
89
70
  requirements:
90
- - - ! '>='
71
+ - - ">="
91
72
  - !ruby/object:Gem::Version
92
73
  version: '0'
93
- segments:
94
- - 0
95
- hash: 1829960584384631724
96
74
  required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
75
  requirements:
99
- - - ! '>='
76
+ - - ">="
100
77
  - !ruby/object:Gem::Version
101
78
  version: '0'
102
79
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 1.6.2
105
- signing_key:
106
- specification_version: 3
80
+ rubyforge_project:
81
+ rubygems_version: 2.7.6.2
82
+ signing_key:
83
+ specification_version: 4
107
84
  summary: A gem for converting between hiragana, katakana, and romaji
108
- test_files:
109
- - spec/romajinizer_spec.rb
110
- - spec/spec_helper.rb
85
+ test_files: []