mojinizer 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/README.md +14 -5
- data/lib/mojinizer/conversion.rb +4 -0
- data/lib/mojinizer/detection.rb +8 -0
- data/lib/mojinizer/version.rb +1 -1
- data/spec/mojinizer_spec.rb +47 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad4aece11dbbfd367bb0985c0288db2162829a5c
|
4
|
+
data.tar.gz: 10acaec7b37906f9941e6b3565df134d8b6bba7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa59d5ef7804148ed5e2c6bdaca305244667e5f6ef65339c10d42062294d200b2c2ebd09e947db608022f3b02b16d98db730be437a458275fbfe00cd3adeaa8c
|
7
|
+
data.tar.gz: 48c3a5bf8232b0d066c76e6096696f6e464bd2961e201eb0651c75275af9c55886f909d0fa235f12119a916de803cd8371cf3bf7384ab400549fa8ff188e4741
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p195
|
data/README.md
CHANGED
@@ -66,14 +66,17 @@ Japanese string conversion and detection methods are added to the `String` class
|
|
66
66
|
"ツクエ".kata_to_hira #=> "つくえ"
|
67
67
|
```
|
68
68
|
|
69
|
-
* Zenkaku --> hankaku conversion (全角 --> 半角 文字種変換)
|
70
69
|
* Hankaku --> zenkaku conversion (半角 --> 全角 文字種変換)
|
70
|
+
* Zenkaku --> hankaku conversion (全角 --> 半角 文字種変換)
|
71
|
+
* ASCII zenkaku --> hankaku conversion (ASCII全角 --> 半角 文字種変換)
|
71
72
|
|
72
73
|
```ruby
|
73
|
-
"アロハ".zen_to_han #=> "アロハ"
|
74
|
-
"Aloha!".zen_to_han.should == "Aloha!"
|
75
74
|
"アロハ".han_to_zen #=> "アロハ"
|
76
|
-
"Aloha!".han_to_zen #=> "Aloha!"
|
75
|
+
"Aloha!".han_to_zen #=> "Aloha!"
|
76
|
+
"アロハ".zen_to_han #=> "アロハ"
|
77
|
+
"Aloha!".zen_to_han #=> "Aloha!"
|
78
|
+
"アロハ".ascii_zen_to_han #=> "アロハ"
|
79
|
+
"Aloha!".ascii_zen_to_han #=> "Aloha!"
|
77
80
|
```
|
78
81
|
|
79
82
|
* Chaining conversion methods
|
@@ -126,12 +129,15 @@ If you need to detect other types of Japanese characters such as symbols or just
|
|
126
129
|
|
127
130
|
* Is the entire string hankaku? (半角・文字種判定)
|
128
131
|
* Is the entire string zenkaku? (全角・文字種判定)
|
132
|
+
* Is the entire string ASCII zenkaku? (ASCII全角・文字種判定)
|
129
133
|
|
130
134
|
```ruby
|
131
135
|
"アロハ".hankaku? #=> true
|
132
136
|
"アロハ".hankaku? #=> false
|
133
137
|
"アロハ".zenkaku? #=> false
|
134
|
-
"アロハ".zenkaku? #=> true
|
138
|
+
"アロハ everybody".zenkaku? #=> true
|
139
|
+
"アロハ everybody".ascii_zenkaku? #=> false
|
140
|
+
"Aloha".ascii_zenkaku? #=> true
|
135
141
|
```
|
136
142
|
|
137
143
|
* Is the entire string Japanese? (日本語・文字種判定)
|
@@ -168,12 +174,15 @@ If you need to detect other types of Japanese characters such as symbols or just
|
|
168
174
|
|
169
175
|
* Does the string contain hankaku? (半角・文字種判定)
|
170
176
|
* Does the string contain zenkaku? (全角・文字種判定)
|
177
|
+
* Does the string contain ASCII zenkaku? (ASCII全角・文字種判定)
|
171
178
|
|
172
179
|
```ruby
|
173
180
|
"アロハ everybody".contains_hankaku? #=> true
|
174
181
|
"Let's eat すし".contains_hankaku? #=> false
|
175
182
|
"アロハ everybody".contains_zenkaku? #=> false
|
176
183
|
"Let's eat すし".contains_zenkaku? #=> true
|
184
|
+
"アロハ everybody".contains_ascii_zenkaku? #=> false
|
185
|
+
"Let's eat sushi".contains_ascii_zenkaku? #=> true
|
177
186
|
```
|
178
187
|
|
179
188
|
* Does the string contain Japanese? (日本語・文字種判定)
|
data/lib/mojinizer/conversion.rb
CHANGED
data/lib/mojinizer/detection.rb
CHANGED
@@ -24,6 +24,10 @@ module Mojinizer
|
|
24
24
|
moji_type?(Moji::ZEN)
|
25
25
|
end
|
26
26
|
|
27
|
+
def ascii_zenkaku?
|
28
|
+
moji_type?(Moji::ZEN_ALNUM | Moji::ZEN_ASYMBOL)
|
29
|
+
end
|
30
|
+
|
27
31
|
def japanese?
|
28
32
|
moji_type?(Moji::ZEN | Moji::JSYMBOL | Moji::HAN_KATA)
|
29
33
|
end
|
@@ -57,6 +61,10 @@ module Mojinizer
|
|
57
61
|
contains_moji_type?(Moji::ZEN)
|
58
62
|
end
|
59
63
|
|
64
|
+
def contains_ascii_zenkaku?
|
65
|
+
contains_moji_type?(Moji::ZEN_ALNUM | Moji::ZEN_ASYMBOL)
|
66
|
+
end
|
67
|
+
|
60
68
|
def contains_japanese?
|
61
69
|
contains_moji_type?(Moji::ZEN | Moji::JSYMBOL | Moji::HAN_KATA)
|
62
70
|
end
|
data/lib/mojinizer/version.rb
CHANGED
data/spec/mojinizer_spec.rb
CHANGED
@@ -55,6 +55,14 @@ describe Mojinizer do
|
|
55
55
|
"".zen_to_han.should == ""
|
56
56
|
end
|
57
57
|
|
58
|
+
it "ASCII zenkaku to hankaku properly" do
|
59
|
+
"あろは".ascii_zen_to_han.should == "あろは"
|
60
|
+
"「アロハ!」".ascii_zen_to_han.should == "「アロハ!」"
|
61
|
+
"@lo ha!".ascii_zen_to_han.should == "@lo ha!"
|
62
|
+
"ALOHA!".ascii_zen_to_han.should == "ALOHA!"
|
63
|
+
"".ascii_zen_to_han.should == ""
|
64
|
+
end
|
65
|
+
|
58
66
|
it "romaji or kana to zenkaku properly" do
|
59
67
|
"アロハ!".han_to_zen.should == "アロハ!"
|
60
68
|
"あろは!".han_to_zen.should == "あろは!"
|
@@ -123,6 +131,21 @@ describe Mojinizer do
|
|
123
131
|
"アロハeverybody".contains_zenkaku?.should == false
|
124
132
|
end
|
125
133
|
|
134
|
+
it "ASCII zenkaku" do
|
135
|
+
"あ".contains_ascii_zenkaku?.should == false
|
136
|
+
"ア".contains_ascii_zenkaku?.should == false
|
137
|
+
"アA".contains_ascii_zenkaku?.should == true
|
138
|
+
"a".contains_ascii_zenkaku?.should == false
|
139
|
+
"A".contains_ascii_zenkaku?.should == true
|
140
|
+
"ALOHA".contains_ascii_zenkaku?.should == true
|
141
|
+
"アろは".contains_ascii_zenkaku?.should == false
|
142
|
+
"aloha".contains_ascii_zenkaku?.should == false
|
143
|
+
"aloは".contains_ascii_zenkaku?.should == false
|
144
|
+
"ア".contains_ascii_zenkaku?.should == false
|
145
|
+
"アロハ".contains_ascii_zenkaku?.should == false
|
146
|
+
"アロハeverybody".contains_ascii_zenkaku?.should == false
|
147
|
+
end
|
148
|
+
|
126
149
|
it "Japanese characters" do
|
127
150
|
"行きます".contains_japanese?.should == true
|
128
151
|
"abcdefg!".contains_japanese?.should == false
|
@@ -185,6 +208,9 @@ describe Mojinizer do
|
|
185
208
|
"ア".hankaku?.should == true
|
186
209
|
"アロハ".hankaku?.should == true
|
187
210
|
"。".hankaku?.should == true
|
211
|
+
"@?!".hankaku?.should == false
|
212
|
+
"@?!".hankaku?.should == false
|
213
|
+
"。「」、".hankaku?.should == false
|
188
214
|
end
|
189
215
|
|
190
216
|
it "zenkaku" do
|
@@ -199,6 +225,27 @@ describe Mojinizer do
|
|
199
225
|
"aloは".zenkaku?.should == false
|
200
226
|
"ア".zenkaku?.should == false
|
201
227
|
"アロハ".zenkaku?.should == false
|
228
|
+
"@?!".zenkaku?.should == false
|
229
|
+
"@?!".zenkaku?.should == true
|
230
|
+
"。「」、".zenkaku?.should == true
|
231
|
+
end
|
232
|
+
|
233
|
+
it "ASCII zenkaku" do
|
234
|
+
"あ".ascii_zenkaku?.should == false
|
235
|
+
"ア".ascii_zenkaku?.should == false
|
236
|
+
"アA".ascii_zenkaku?.should == false
|
237
|
+
"a".ascii_zenkaku?.should == false
|
238
|
+
"A".ascii_zenkaku?.should == true
|
239
|
+
"ALOHA".ascii_zenkaku?.should == true
|
240
|
+
"アろは".ascii_zenkaku?.should == false
|
241
|
+
"アロハ".ascii_zenkaku?.should == false
|
242
|
+
"aloha".ascii_zenkaku?.should == false
|
243
|
+
"aloは".ascii_zenkaku?.should == false
|
244
|
+
"ア".ascii_zenkaku?.should == false
|
245
|
+
"アロハ".ascii_zenkaku?.should == false
|
246
|
+
"@?!".ascii_zenkaku?.should == false
|
247
|
+
"@?!".ascii_zenkaku?.should == true
|
248
|
+
"。「」、".ascii_zenkaku?.should == false
|
202
249
|
end
|
203
250
|
|
204
251
|
it "Japanese characters" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojinizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ikayzo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: moji
|
@@ -90,6 +90,7 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- .gitignore
|
92
92
|
- .rspec
|
93
|
+
- .ruby-version
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.md
|