gimei 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/CHANGELOG.md +5 -1
- data/README.md +55 -24
- data/_config.yml +1 -0
- data/gimei.gemspec +1 -0
- data/lib/gimei.rb +2 -2
- data/lib/gimei/address.rb +16 -0
- data/lib/gimei/name.rb +24 -16
- data/lib/gimei/version.rb +1 -1
- data/spec/address_spec.rb +50 -32
- data/spec/gimei_spec.rb +12 -0
- data/spec/name_spec.rb +38 -14
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1605b3bfbb543f4f1a38f3400377fe855ea2bc0d
|
4
|
+
data.tar.gz: c1781dab9fe9506476f85a9254796f00b042d912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47f890c91bfc8b1b9a73a7fbe4d9d1b39880da1d7dca12c44e87676ddcfd7b0b0acca8dc2b507929154a4baae87c6288c42723db67204c3cdfdc23f87eb95c43
|
7
|
+
data.tar.gz: e113e8752c3a5c2def53b8c3bc0530b30efbdc705f79f01e385937eb7438156aaedc9c46fe77c420f6d9f77801b51cafcd1cb851005a238a736cb857d39cc7a7
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
|
3
|
+
* ローマ字対応 - [@takkanm](https://github.com/takkanm)
|
4
|
+
|
1
5
|
## 0.2.0
|
2
6
|
|
3
7
|
* 住所対応 - [@miyohide](https://github.com/miyohide)
|
@@ -5,7 +9,7 @@
|
|
5
9
|
## 0.1.0
|
6
10
|
|
7
11
|
* サンプルデータの拡充 - [@2celeb](https://github.com/2celeb)
|
8
|
-
* `Gimei.male`, `Gimei.female` 等の男女指定用のメソッドを追加 -
|
12
|
+
* `Gimei.male`, `Gimei.female` 等の男女指定用のメソッドを追加 - [@2celeb](https://github.com/2celeb)
|
9
13
|
|
10
14
|
```ruby
|
11
15
|
gimei = Gimei.male
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Gimei
|
2
2
|
|
3
|
-
[![
|
4
|
-
[![
|
5
|
-
[![
|
6
|
-
[![
|
3
|
+
[![Travis](https://img.shields.io/travis/willnet/gimei.svg)](https://travis-ci.org/willnet/gimei)
|
4
|
+
[![Coveralls](https://coveralls.io/repos/willnet/gimei/badge.svg)](https://coveralls.io/r/willnet/gimei)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/willnet/gimei/badges/gpa.svg)](https://codeclimate.com/github/willnet/gimei)
|
6
|
+
[![Gem](https://img.shields.io/gem/v/gimei.svg)](https://rubygems.org/gems/gimei)
|
7
7
|
|
8
|
-
gimei は、日本人の名前や、日本の住所をランダムに返すライブラリです。テストの時などに使います。似たようなライブラリに[faker](https://github.com/stympy/faker)があります。[faker](https://github.com/stympy/faker)はとても優れたライブラリで、多言語対応もしていますが、ふりがな(フリガナ)は流石に対応していません。gimei
|
8
|
+
gimei は、日本人の名前や、日本の住所をランダムに返すライブラリです。テストの時などに使います。似たようなライブラリに[faker](https://github.com/stympy/faker)があります。[faker](https://github.com/stympy/faker)はとても優れたライブラリで、多言語対応もしていますが、ふりがな(フリガナ)は流石に対応していません。gimei はふりがな(及びフリガナ)に対応しています。
|
9
9
|
|
10
10
|
|
11
11
|
## 使い方
|
@@ -16,43 +16,49 @@ gimei は、日本人の名前や、日本の住所をランダムに返すラ
|
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
gimei = Gimei.name
|
19
|
-
gimei.kanji
|
20
|
-
gimei.hiragana
|
21
|
-
gimei.katakana
|
22
|
-
gimei.
|
23
|
-
gimei.last.
|
24
|
-
gimei.last.
|
25
|
-
gimei.
|
19
|
+
gimei.kanji #=> "斎藤 陽菜"
|
20
|
+
gimei.hiragana #=> "さいとう はるな"
|
21
|
+
gimei.katakana #=> "サイトウ ハルナ"
|
22
|
+
gimei.romaji #=> "Haruna Saitou"
|
23
|
+
gimei.last.kanji #=> "斎藤"
|
24
|
+
gimei.last.hiragana #=> "さいとう"
|
25
|
+
gimei.last.katakana #=> "サイトウ"
|
26
|
+
gimei.last.romaji #=> "Saitou"
|
27
|
+
gimei.first.kanji #=> "陽菜"
|
26
28
|
gimei.first.hiragana #=> "はるな"
|
27
29
|
gimei.first.katakana #=> "ハルナ"
|
30
|
+
gimei.first.romaji #=> "Haruna"
|
28
31
|
```
|
29
32
|
|
30
33
|
下記のように男性/女性の名前を返すことを明示的に指定できます。`Gimei.name` の場合は男女の名前を等確率で返します。
|
31
34
|
|
32
35
|
```ruby
|
33
36
|
gimei = Gimei.male
|
34
|
-
gimei.male?
|
37
|
+
gimei.male? #=> true
|
35
38
|
gimei.female? #=> false
|
36
|
-
gimei.kanji
|
39
|
+
gimei.kanji #=> "小林 顕士"
|
37
40
|
|
38
41
|
gimei = Gimei.female
|
39
|
-
gimei.male?
|
42
|
+
gimei.male? #=> false
|
40
43
|
gimei.female? #=> true
|
41
|
-
gimei.kanji
|
44
|
+
gimei.kanji #=> "根本 彩世"
|
42
45
|
```
|
43
46
|
|
44
|
-
|
47
|
+
漢字、ひらがな、カタカナ、ローマ字どれか一種類だけ取得できればよい場合には、下記のように短縮して書くことも出来ます。
|
45
48
|
|
46
49
|
```ruby
|
47
|
-
Gimei.kanji
|
48
|
-
Gimei.hiragana
|
49
|
-
Gimei.katakana
|
50
|
-
Gimei.
|
51
|
-
Gimei.last.
|
52
|
-
Gimei.last.
|
53
|
-
Gimei.
|
50
|
+
Gimei.kanji #=> "伊藤 結衣"
|
51
|
+
Gimei.hiragana #=> "いとう みさき"
|
52
|
+
Gimei.katakana #=> "タカハシ ユイナ"
|
53
|
+
Gimei.romaji #=> "Miki Obara"
|
54
|
+
Gimei.last.kanji #=> "清水"
|
55
|
+
Gimei.last.hiragana #=> "いとう"
|
56
|
+
Gimei.last.katakana #=> "コバヤシ"
|
57
|
+
Gimei.last.romaji #=> "Wakabayashi"
|
58
|
+
Gimei.first.kanji #=> "結菜"
|
54
59
|
Gimei.first.hiragana #=> "ここあ"
|
55
60
|
Gimei.first.katakana #=> "ヤマト"
|
61
|
+
Gimei.first.romaji #=> "Noriyuki"
|
56
62
|
```
|
57
63
|
|
58
64
|
出力される名前の候補となるデータは `lib/data/names.yml` にあるので、必要であればファイルを修正してください。
|
@@ -67,21 +73,25 @@ address.kanji # => 岡山県大島郡大和村稲木町
|
|
67
73
|
address.to_s # => 岡山県大島郡大和村稲木町
|
68
74
|
address.hiragana # => おかやまけんおおしまぐんやまとそんいなぎちょう
|
69
75
|
address.katakana # => オカヤマケンオオシマグンヤマトソンイナギチョウ
|
76
|
+
address.romaji # => Okayamaken Ooshimagunyamatoson Inagicho
|
70
77
|
|
71
78
|
address.prefecture.kanji # => 岡山県
|
72
79
|
address.prefecture.to_s # => 岡山県
|
73
80
|
address.prefecture.hiragana # => おかやまけん
|
74
81
|
address.prefecture.katakana # => オカヤマケン
|
82
|
+
address.prefecture.romaji # => Okayamaken
|
75
83
|
|
76
84
|
address.city.kanji # => 大島郡大和村
|
77
85
|
address.city.to_s # => 大島郡大和村
|
78
86
|
address.city.hiragana # => おおしまぐんやまとそん
|
79
87
|
address.city.katakana # => オオシマグンヤマトソン
|
88
|
+
address.city.romaji # => Ooshimagunyamatoson
|
80
89
|
|
81
90
|
address.town.kanji # => 稲木町
|
82
91
|
address.town.to_s # => 稲木町
|
83
92
|
address.town.hiragana # => いなぎちょう
|
84
93
|
address.town.katakana # => イナギチョウ
|
94
|
+
address.town.romaji # => Inagicho
|
85
95
|
```
|
86
96
|
|
87
97
|
省略形も用意しています。
|
@@ -91,19 +101,40 @@ Gimei.prefecture.kanji # => 青森県
|
|
91
101
|
Gimei.prefecture.to_s # => 滋賀県
|
92
102
|
Gimei.prefecture.hiragana # => やまがたけん
|
93
103
|
Gimei.prefecture.katakana # => チバケン
|
104
|
+
Gimei.prefecture.romaji # => Wakayamaken
|
94
105
|
|
95
106
|
Gimei.city.kanji # => 利根郡昭和村
|
96
107
|
Gimei.city.hiragana # => うべし
|
97
108
|
Gimei.city.katakana # => カモグンヤオツチョウ
|
109
|
+
Gimei.city.romaji # => Itanogunaizumichou
|
98
110
|
|
99
111
|
Gimei.town.kanji # => 竹野
|
100
112
|
Gimei.town.to_s # => 富久山町南小泉
|
101
113
|
Gimei.town.hiragana # => じょうしんでん
|
102
114
|
Gimei.town.katakana # => イケナイ
|
115
|
+
Gimei.town.romaji # => Heisei
|
103
116
|
```
|
104
117
|
|
105
118
|
出力される住所の候補となるデータは `lib/data/addresses.yml` にあるので、必要であればファイルを修正してください。
|
106
119
|
|
120
|
+
## Supported versions
|
121
|
+
|
122
|
+
- 1.9.3
|
123
|
+
- 2.0.0
|
124
|
+
- 2.1.x
|
125
|
+
- 2.2.x
|
126
|
+
- 2.3.x
|
127
|
+
- 2.4.x
|
128
|
+
|
129
|
+
## 他言語による実装
|
130
|
+
|
131
|
+
- [mattn/go-gimei](https://github.com/mattn/go-gimei)
|
132
|
+
- [moznion/gimei-java](https://github.com/moznion/gimei-java)
|
133
|
+
- [nabetama/gimei](https://github.com/nabetama/gimei)
|
134
|
+
- [gongo/emacs-gimei](https://github.com/gongo/emacs-gimei)
|
135
|
+
- [ma2gedev/gimei_ex](https://github.com/ma2gedev/gimei_ex)
|
136
|
+
- [demiglacesource/node-gimei](https://github.com/demiglacesource/node-gimei)
|
137
|
+
|
107
138
|
## Installation
|
108
139
|
|
109
140
|
Add this line to your application's Gemfile:
|
data/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-cayman
|
data/gimei.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
|
+
gem.add_dependency('romaji')
|
20
21
|
gem.add_development_dependency('rake')
|
21
22
|
gem.add_development_dependency('moji')
|
22
23
|
gem.add_development_dependency('minitest')
|
data/lib/gimei.rb
CHANGED
@@ -11,7 +11,7 @@ class Gimei
|
|
11
11
|
ADDRESSES = YAML.load_file(File.expand_path(File.join('..', 'data', 'addresses.yml'), __FILE__))
|
12
12
|
GENDER = [:male, :female].freeze
|
13
13
|
|
14
|
-
def_delegators :@name, :kanji, :hiragana, :katakana, :first, :last, :male?, :female
|
14
|
+
def_delegators :@name, :kanji, :hiragana, :katakana, :first, :last, :male?, :female?, :romaji
|
15
15
|
def_delegators :@address, :prefecture, :city, :town
|
16
16
|
alias_method :to_s, :kanji
|
17
17
|
|
@@ -20,7 +20,7 @@ class Gimei
|
|
20
20
|
class << self
|
21
21
|
extend Forwardable
|
22
22
|
|
23
|
-
def_delegators :name, :kanji, :hiragana, :katakana, :first, :last
|
23
|
+
def_delegators :name, :kanji, :hiragana, :katakana, :first, :last, :romaji
|
24
24
|
def_delegators Gimei::Name, :male, :female
|
25
25
|
def_delegators :address, :prefecture, :city, :town
|
26
26
|
|
data/lib/gimei/address.rb
CHANGED
@@ -19,6 +19,10 @@ class Gimei::Address
|
|
19
19
|
"#{prefecture.katakana}#{city.katakana}#{town.katakana}"
|
20
20
|
end
|
21
21
|
|
22
|
+
def romaji
|
23
|
+
"#{prefecture.romaji} #{city.romaji} #{town.romaji}"
|
24
|
+
end
|
25
|
+
|
22
26
|
alias_method :to_s, :kanji
|
23
27
|
|
24
28
|
class Prefecture
|
@@ -34,6 +38,10 @@ class Gimei::Address
|
|
34
38
|
@prefectures[2]
|
35
39
|
end
|
36
40
|
|
41
|
+
def romaji
|
42
|
+
Romaji.kana2romaji(hiragana).capitalize
|
43
|
+
end
|
44
|
+
|
37
45
|
def initialize
|
38
46
|
@prefectures = Gimei::ADDRESSES['addresses']['prefecture'].sample
|
39
47
|
end
|
@@ -54,6 +62,10 @@ class Gimei::Address
|
|
54
62
|
@cities[2]
|
55
63
|
end
|
56
64
|
|
65
|
+
def romaji
|
66
|
+
Romaji.kana2romaji(hiragana).capitalize
|
67
|
+
end
|
68
|
+
|
57
69
|
def initialize
|
58
70
|
@cities = Gimei::ADDRESSES['addresses']['city'].sample
|
59
71
|
end
|
@@ -74,6 +86,10 @@ class Gimei::Address
|
|
74
86
|
@towns[2]
|
75
87
|
end
|
76
88
|
|
89
|
+
def romaji
|
90
|
+
Romaji.kana2romaji(hiragana).capitalize
|
91
|
+
end
|
92
|
+
|
77
93
|
def initialize
|
78
94
|
@towns = Gimei::ADDRESSES['addresses']['town'].sample
|
79
95
|
end
|
data/lib/gimei/name.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
require 'romaji'
|
2
|
+
|
1
3
|
class Gimei::Name
|
2
4
|
attr_reader :first, :last
|
3
5
|
|
4
6
|
class << self
|
5
7
|
extend Forwardable
|
6
|
-
def_delegators :new, :kanji, :hiragana, :katakana, :first, :last
|
8
|
+
def_delegators :new, :kanji, :hiragana, :katakana, :first, :last, :romaji
|
7
9
|
|
8
10
|
def male
|
9
11
|
new(:male)
|
@@ -32,6 +34,10 @@ class Gimei::Name
|
|
32
34
|
"#{last.katakana} #{first.katakana}"
|
33
35
|
end
|
34
36
|
|
37
|
+
def romaji
|
38
|
+
"#{first.romaji} #{last.romaji}"
|
39
|
+
end
|
40
|
+
|
35
41
|
def male?
|
36
42
|
@gender == :male
|
37
43
|
end
|
@@ -53,9 +59,12 @@ class Gimei::Name
|
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
62
|
+
extend Forwardable
|
63
|
+
def_delegators :@name, :kanji, :hiragana, :katakana, :to_s, :romaji
|
64
|
+
|
56
65
|
def initialize(gender = nil)
|
57
66
|
@gender = gender || Gimei::GENDER.sample
|
58
|
-
@name = Gimei::NAMES['first_name'][@gender.to_s].sample
|
67
|
+
@name = NameWord.new(Gimei::NAMES['first_name'][@gender.to_s].sample)
|
59
68
|
end
|
60
69
|
|
61
70
|
def male?
|
@@ -65,25 +74,20 @@ class Gimei::Name
|
|
65
74
|
def female?
|
66
75
|
@gender == :female
|
67
76
|
end
|
77
|
+
end
|
68
78
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
def hiragana
|
74
|
-
@name[1]
|
75
|
-
end
|
79
|
+
class Last
|
80
|
+
extend Forwardable
|
81
|
+
def_delegators :@name, :kanji, :hiragana, :katakana, :to_s, :romaji
|
76
82
|
|
77
|
-
def
|
78
|
-
@name[
|
83
|
+
def initialize
|
84
|
+
@name = NameWord.new(Gimei::NAMES['last_name'].sample)
|
79
85
|
end
|
80
|
-
|
81
|
-
alias_method :to_s, :kanji
|
82
86
|
end
|
83
87
|
|
84
|
-
class
|
85
|
-
def initialize
|
86
|
-
@name =
|
88
|
+
class NameWord
|
89
|
+
def initialize(name)
|
90
|
+
@name = name
|
87
91
|
end
|
88
92
|
|
89
93
|
def kanji
|
@@ -98,6 +102,10 @@ class Gimei::Name
|
|
98
102
|
@name[2]
|
99
103
|
end
|
100
104
|
|
105
|
+
def romaji
|
106
|
+
Romaji.kana2romaji(hiragana).capitalize
|
107
|
+
end
|
108
|
+
|
101
109
|
alias_method :to_s, :kanji
|
102
110
|
end
|
103
111
|
end
|
data/lib/gimei/version.rb
CHANGED
data/spec/address_spec.rb
CHANGED
@@ -2,45 +2,63 @@
|
|
2
2
|
require_relative 'spec_helper'
|
3
3
|
|
4
4
|
describe Gimei do
|
5
|
+
describe '#kanji and #to_s' do
|
6
|
+
it '全角文字が返ること' do
|
7
|
+
Gimei.address.kanji.must_match(/\A[#{Moji.zen}]+\z/)
|
8
|
+
Gimei.address.to_s.must_match(/\A[#{Moji.zen}]+\z/)
|
9
|
+
Gimei.address.prefecture.kanji.must_match(/\A[#{Moji.zen}]+\z/)
|
10
|
+
Gimei.address.prefecture.to_s.must_match(/\A[#{Moji.zen}]+\z/)
|
11
|
+
Gimei.address.city.kanji.must_match(/\A[#{Moji.zen}]+\z/)
|
12
|
+
Gimei.address.city.to_s.must_match(/\A[#{Moji.zen}]+\z/)
|
13
|
+
Gimei.address.town.kanji.must_match(/\A[#{Moji.zen}]+\z/)
|
14
|
+
Gimei.address.town.to_s.must_match(/\A[#{Moji.zen}]+\z/)
|
5
15
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Gimei.address.town.kanji.must_match /\A[#{Moji.zen}]+\z/
|
14
|
-
Gimei.address.town.to_s.must_match /\A[#{Moji.zen}]+\z/
|
15
|
-
|
16
|
-
Gimei.prefecture.kanji.must_match /\A[#{Moji.zen}]+\z/
|
17
|
-
Gimei.prefecture.to_s.must_match /\A[#{Moji.zen}]+\z/
|
18
|
-
Gimei.city.kanji.must_match /\A[#{Moji.zen}]+\z/
|
19
|
-
Gimei.city.to_s.must_match /\A[#{Moji.zen}]+\z/
|
20
|
-
Gimei.town.kanji.must_match /\A[#{Moji.zen}]+\z/
|
21
|
-
Gimei.town.to_s.must_match /\A[#{Moji.zen}]+\z/
|
16
|
+
Gimei.prefecture.kanji.must_match(/\A[#{Moji.zen}]+\z/)
|
17
|
+
Gimei.prefecture.to_s.must_match(/\A[#{Moji.zen}]+\z/)
|
18
|
+
Gimei.city.kanji.must_match(/\A[#{Moji.zen}]+\z/)
|
19
|
+
Gimei.city.to_s.must_match(/\A[#{Moji.zen}]+\z/)
|
20
|
+
Gimei.town.kanji.must_match(/\A[#{Moji.zen}]+\z/)
|
21
|
+
Gimei.town.to_s.must_match(/\A[#{Moji.zen}]+\z/)
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
describe '#hiragana' do
|
26
|
+
it 'ひらがなが返ること' do
|
27
|
+
Gimei.address.hiragana.must_match(/\A[\p{hiragana}]+\z/)
|
28
|
+
Gimei.address.prefecture.hiragana.must_match(/\A[\p{hiragana}]+\z/)
|
29
|
+
Gimei.address.city.hiragana.must_match(/\A[\p{hiragana}]+\z/)
|
30
|
+
Gimei.address.town.hiragana.must_match(/\A[\p{hiragana}]+\z/)
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
Gimei.prefecture.hiragana.must_match(/\A[\p{hiragana}]+\z/)
|
33
|
+
Gimei.city.hiragana.must_match(/\A[\p{hiragana}]+\z/)
|
34
|
+
Gimei.town.hiragana.must_match(/\A[\p{hiragana}]+\z/)
|
35
|
+
end
|
33
36
|
end
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
describe '#katakana' do
|
39
|
+
it 'カタカナが返ること' do
|
40
|
+
Gimei.address.katakana.must_match(/\A[\p{katakana}]+\z/)
|
41
|
+
Gimei.address.prefecture.katakana.must_match(/\A[\p{katakana}]+\z/)
|
42
|
+
Gimei.address.city.katakana.must_match(/\A[\p{katakana}]+\z/)
|
43
|
+
Gimei.address.town.katakana.must_match(/\A[\p{katakana}]+\z/)
|
40
44
|
|
41
|
-
|
42
|
-
|
43
|
-
|
45
|
+
Gimei.prefecture.katakana.must_match(/\A[\p{katakana}]+\z/)
|
46
|
+
Gimei.city.katakana.must_match(/\A[\p{katakana}]+\z/)
|
47
|
+
Gimei.town.katakana.must_match(/\A[\p{katakana}]+\z/)
|
48
|
+
end
|
44
49
|
end
|
45
50
|
|
51
|
+
describe '#romaji' do
|
52
|
+
it 'ローマ字が返ること' do
|
53
|
+
Gimei.address.romaji.must_match(/\A[a-zA-Z\s]+\z/)
|
54
|
+
|
55
|
+
Gimei.address.prefecture.romaji.must_match(/\A[a-zA-Z]+\z/)
|
56
|
+
Gimei.address.city.romaji.must_match(/\A[a-zA-Z]+\z/)
|
57
|
+
Gimei.address.town.romaji.must_match(/\A[a-zA-Z]+\z/)
|
58
|
+
|
59
|
+
Gimei.prefecture.romaji.must_match(/\A[a-zA-Z]+\z/)
|
60
|
+
Gimei.city.romaji.must_match(/\A[a-zA-Z]+\z/)
|
61
|
+
Gimei.town.romaji.must_match(/\A[a-zA-Z]+\z/)
|
62
|
+
end
|
63
|
+
end
|
46
64
|
end
|
data/spec/gimei_spec.rb
CHANGED
@@ -104,6 +104,18 @@ describe Gimei do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
+
describe '.romaji' do
|
108
|
+
it 'ローマ字とスペースが返ること' do
|
109
|
+
Gimei.romaji.must_match(/\A[a-zA-Z\s]+\z/)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#romaji' do
|
114
|
+
it 'ローマ字とスペースが返ること' do
|
115
|
+
Gimei.new.romaji.must_match(/\A[a-zA-Z\s]+\z/)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
107
119
|
describe '.address' do
|
108
120
|
it 'Gimei::Address オブジェクトが返ること' do
|
109
121
|
Gimei.address.must_be_instance_of Gimei::Address
|
data/spec/name_spec.rb
CHANGED
@@ -28,37 +28,43 @@ describe Gimei::Name do
|
|
28
28
|
|
29
29
|
describe '.kanji' do
|
30
30
|
it '全角文字とスペースが返ること' do
|
31
|
-
Gimei::Name.kanji.must_match
|
31
|
+
Gimei::Name.kanji.must_match(/\A[#{Moji.zen}\s]+\z/)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe '.hiragana' do
|
36
36
|
it 'ひらがなとスペースが返ること' do
|
37
|
-
Gimei::Name.hiragana.must_match
|
37
|
+
Gimei::Name.hiragana.must_match(/\A[\p{hiragana}\s]+\z/)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe '.katakana' do
|
42
42
|
it 'カタカナとスペースが返ること' do
|
43
|
-
Gimei::Name.katakana.must_match
|
43
|
+
Gimei::Name.katakana.must_match(/\A[\p{katakana}\s]+\z/)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.romaji' do
|
48
|
+
it 'ローマ字とスペースが返ること' do
|
49
|
+
Gimei::Name.romaji.must_match(/\A[a-zA-Z\s]+\z/)
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
47
53
|
describe '#kanji' do
|
48
54
|
it '全角文字とスペースが返ること' do
|
49
|
-
Gimei::Name.new.kanji.must_match
|
55
|
+
Gimei::Name.new.kanji.must_match(/\A[#{Moji.zen}\s]+\z/)
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
53
59
|
describe '#hiragana' do
|
54
60
|
it 'ひらがなとスペースが返ること' do
|
55
|
-
Gimei::Name.new.hiragana.must_match
|
61
|
+
Gimei::Name.new.hiragana.must_match(/\A[\p{hiragana}\s]+\z/)
|
56
62
|
end
|
57
63
|
end
|
58
64
|
|
59
65
|
describe '#katakana' do
|
60
66
|
it 'カタカナとスペースが返ること' do
|
61
|
-
Gimei::Name.new.katakana.must_match
|
67
|
+
Gimei::Name.new.katakana.must_match(/\A[\p{katakana}\s]+\z/)
|
62
68
|
end
|
63
69
|
end
|
64
70
|
|
@@ -73,6 +79,12 @@ describe Gimei::Name do
|
|
73
79
|
Gimei::Name.new.last.must_be_instance_of Gimei::Name::Last
|
74
80
|
end
|
75
81
|
end
|
82
|
+
|
83
|
+
describe '.romaji' do
|
84
|
+
it 'ローマ字とスペースが返ること' do
|
85
|
+
Gimei::Name.new.romaji.must_match(/\A[a-zA-Z\s]+\z/)
|
86
|
+
end
|
87
|
+
end
|
76
88
|
end
|
77
89
|
|
78
90
|
describe Gimei::Name::First do
|
@@ -102,25 +114,31 @@ describe Gimei::Name::First do
|
|
102
114
|
|
103
115
|
describe '#kanji' do
|
104
116
|
it '全角文字が返ること' do
|
105
|
-
Gimei::Name::First.new.kanji.must_match
|
117
|
+
Gimei::Name::First.new.kanji.must_match(/\A#{Moji.zen}+\z/)
|
106
118
|
end
|
107
119
|
end
|
108
120
|
|
109
121
|
describe '#hiragana' do
|
110
122
|
it 'ひらがなが返ること' do
|
111
|
-
Gimei::Name::First.new.hiragana.must_match
|
123
|
+
Gimei::Name::First.new.hiragana.must_match(/\A\p{hiragana}+\z/)
|
112
124
|
end
|
113
125
|
end
|
114
126
|
|
115
127
|
describe '#katakana' do
|
116
128
|
it 'カタカナが返ること' do
|
117
|
-
Gimei::Name::First.new.katakana.must_match
|
129
|
+
Gimei::Name::First.new.katakana.must_match(/\A\p{katakana}+\z/)
|
118
130
|
end
|
119
131
|
end
|
120
132
|
|
121
133
|
describe '#to_s' do
|
122
134
|
it '全角文字が返ること' do
|
123
|
-
Gimei::Name::First.new.to_s.must_match
|
135
|
+
Gimei::Name::First.new.to_s.must_match(/\A#{Moji.zen}+\z/)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#romaji' do
|
140
|
+
it 'アルファベットで返ること' do
|
141
|
+
Gimei::Name::First.new.romaji.must_match(/\A[a-zA-Z]+\z/)
|
124
142
|
end
|
125
143
|
end
|
126
144
|
end
|
@@ -130,25 +148,31 @@ describe Gimei::Name::Last do
|
|
130
148
|
|
131
149
|
describe '#kanji' do
|
132
150
|
it '全角文字が返ること' do
|
133
|
-
@name.kanji.must_match
|
151
|
+
@name.kanji.must_match(/\A#{Moji.zen}+\z/)
|
134
152
|
end
|
135
153
|
end
|
136
154
|
|
137
155
|
describe '#hiragana' do
|
138
156
|
it 'ひらがなが返ること' do
|
139
|
-
@name.hiragana.must_match
|
157
|
+
@name.hiragana.must_match(/\A\p{hiragana}+\z/)
|
140
158
|
end
|
141
159
|
end
|
142
160
|
|
143
161
|
describe '#katakana' do
|
144
162
|
it 'カタカナが返ること' do
|
145
|
-
@name.katakana.must_match
|
163
|
+
@name.katakana.must_match(/\A\p{katakana}+\z/)
|
146
164
|
end
|
147
165
|
end
|
148
166
|
|
149
167
|
describe '#to_s' do
|
150
168
|
it '全角文字が返ること' do
|
151
|
-
@name.to_s.must_match
|
169
|
+
@name.to_s.must_match(/\A#{Moji.zen}+\z/)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '#romaji' do
|
174
|
+
it 'アルファベットで返ること' do
|
175
|
+
Gimei::Name::First.new.romaji.must_match(/\A[a-z|A-Z]+\z/)
|
152
176
|
end
|
153
177
|
end
|
154
178
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gimei
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willnet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: romaji
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,6 +95,7 @@ files:
|
|
81
95
|
- LICENSE.txt
|
82
96
|
- README.md
|
83
97
|
- Rakefile
|
98
|
+
- _config.yml
|
84
99
|
- gimei.gemspec
|
85
100
|
- lib/data/addresses.yml
|
86
101
|
- lib/data/names.yml
|
@@ -112,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
127
|
version: '0'
|
113
128
|
requirements: []
|
114
129
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.6.13
|
116
131
|
signing_key:
|
117
132
|
specification_version: 4
|
118
133
|
summary: random Japanese name and address generator. support kanji, hiragana, and
|