gimei 1.6.0 → 1.7.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 +4 -4
- data/.github/workflows/push_gem.yml +32 -0
- data/.github/workflows/test.yml +6 -9
- data/Gemfile +1 -1
- data/README.ja.md +272 -0
- data/README.md +41 -40
- data/lib/gimei/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ab4689e87f0372609b915aeed97ea542e38a4012db2d2845584d2a8e12d40fa
|
|
4
|
+
data.tar.gz: 71fc37b2f53df357f0bb182d5f3f140e9251052d4493a81435f4567138b19c42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f61e4081f6f57915bd3db5f9f647a108390a245a0df6f768b0a360546f27281b3e67c68f699b38d4e626ae59fa32ae8558880bab6605ea4961905ad3c38f23c7
|
|
7
|
+
data.tar.gz: 2668d750c28c343796ebaff9581fa860d0de84aa14dda978e0c6fd3aa451913138daf2fb7563c96ecc7ba63f0c63918d61ff7342b90afade3f7381e310e9c62d
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Release new version to RubyGems.org
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
push:
|
|
8
|
+
name: Push gem to RubyGems.org
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
contents: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v6
|
|
17
|
+
with:
|
|
18
|
+
persist-credentials: false
|
|
19
|
+
- name: Set up Ruby
|
|
20
|
+
uses: ruby/setup-ruby@v1
|
|
21
|
+
with:
|
|
22
|
+
bundler-cache: true
|
|
23
|
+
ruby-version: ruby
|
|
24
|
+
|
|
25
|
+
- uses: rubygems/release-gem@v1
|
|
26
|
+
|
|
27
|
+
- name: Create GitHub release
|
|
28
|
+
run: |
|
|
29
|
+
tag_name="$(git describe --tags --abbrev=0)"
|
|
30
|
+
gh release create "${tag_name}" --verify-tag --generate-notes
|
|
31
|
+
env:
|
|
32
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
data/.github/workflows/test.yml
CHANGED
|
@@ -14,28 +14,25 @@ jobs:
|
|
|
14
14
|
test:
|
|
15
15
|
runs-on: ubuntu-latest
|
|
16
16
|
|
|
17
|
-
container: ${{ matrix.ruby }}
|
|
18
|
-
|
|
19
17
|
strategy:
|
|
20
18
|
fail-fast: false
|
|
21
19
|
|
|
22
20
|
matrix:
|
|
23
|
-
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', 'head']
|
|
21
|
+
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0', 'head']
|
|
24
22
|
include:
|
|
25
23
|
- ruby-version: 'head'
|
|
26
24
|
allow_failures: 'true'
|
|
27
25
|
|
|
28
26
|
steps:
|
|
29
|
-
- uses: actions/checkout@
|
|
27
|
+
- uses: actions/checkout@v6
|
|
30
28
|
- name: Set up Ruby
|
|
31
29
|
uses: ruby/setup-ruby@v1
|
|
32
30
|
with:
|
|
33
31
|
ruby-version: ${{ matrix.ruby-version }}
|
|
34
32
|
bundler-cache: true
|
|
33
|
+
|
|
35
34
|
- name: Run test
|
|
36
|
-
run:
|
|
37
|
-
set -xe
|
|
38
|
-
bundle exec rake
|
|
35
|
+
run: bundle exec rake
|
|
39
36
|
continue-on-error: ${{ matrix.allow_failures == 'true' }}
|
|
40
37
|
|
|
41
38
|
- name: Coveralls
|
|
@@ -44,11 +41,11 @@ jobs:
|
|
|
44
41
|
type-check:
|
|
45
42
|
runs-on: ubuntu-latest
|
|
46
43
|
steps:
|
|
47
|
-
- uses: actions/checkout@
|
|
44
|
+
- uses: actions/checkout@v6
|
|
48
45
|
- name: Set up Ruby
|
|
49
46
|
uses: ruby/setup-ruby@v1
|
|
50
47
|
with:
|
|
51
|
-
ruby-version:
|
|
48
|
+
ruby-version: ruby
|
|
52
49
|
bundler-cache: true
|
|
53
50
|
- name: Run type check
|
|
54
51
|
run: bundle exec steep check --with-expectations
|
data/Gemfile
CHANGED
data/README.ja.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Gimei
|
|
2
|
+
|
|
3
|
+
[](https://coveralls.io/r/willnet/gimei)
|
|
4
|
+
[](https://codeclimate.com/github/willnet/gimei)
|
|
5
|
+
[](https://rubygems.org/gems/gimei)
|
|
6
|
+
|
|
7
|
+
gimei は、日本人の名前や、日本の住所をランダムに返すライブラリです。テストの時などに使います。似たようなライブラリに[faker](https://github.com/stympy/faker)があります。[faker](https://github.com/stympy/faker)はとても優れたライブラリで、多言語対応もしていますが、ふりがな(フリガナ)は流石に対応していません。gimei はふりがな(及びフリガナ)に対応しています。
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 使い方
|
|
11
|
+
|
|
12
|
+
### 名前をランダムで返す
|
|
13
|
+
|
|
14
|
+
下記のように使います。
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
gimei = Gimei.name
|
|
18
|
+
gimei.kanji #=> "斎藤 陽菜"
|
|
19
|
+
gimei.hiragana #=> "さいとう はるな"
|
|
20
|
+
gimei.katakana #=> "サイトウ ハルナ"
|
|
21
|
+
gimei.romaji #=> "Haruna Saitou"
|
|
22
|
+
gimei.gender #=> :female
|
|
23
|
+
gimei.male? #=> false
|
|
24
|
+
gimei.female? #=> true
|
|
25
|
+
gimei.last.kanji #=> "斎藤"
|
|
26
|
+
gimei.last.hiragana #=> "さいとう"
|
|
27
|
+
gimei.last.katakana #=> "サイトウ"
|
|
28
|
+
gimei.last.romaji #=> "Saitou"
|
|
29
|
+
gimei.first.kanji #=> "陽菜"
|
|
30
|
+
gimei.first.hiragana #=> "はるな"
|
|
31
|
+
gimei.first.katakana #=> "ハルナ"
|
|
32
|
+
gimei.first.romaji #=> "Haruna"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`gimei.last`, `gimei.first` の代わりに、`gimei.family`, `gimei.given` を用いることもできます。
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
gimei.family.kanji #=> "斎藤"
|
|
39
|
+
gimei.family.hiragana #=> "さいとう"
|
|
40
|
+
gimei.family.katakana #=> "サイトウ"
|
|
41
|
+
gimei.family.romaji #=> "Saitou"
|
|
42
|
+
|
|
43
|
+
gimei.given.kanji #=> "陽菜"
|
|
44
|
+
gimei.given.hiragana #=> "はるな"
|
|
45
|
+
gimei.given.katakana #=> "ハルナ"
|
|
46
|
+
gimei.given.romaji #=> "Haruna"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
下記のように男性/女性の名前を返すことを明示的に指定できます。`Gimei.name` の場合は男女の名前を等確率で返します。
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
gimei = Gimei.male
|
|
53
|
+
gimei.male? #=> true
|
|
54
|
+
gimei.female? #=> false
|
|
55
|
+
gimei.gender #=> :male
|
|
56
|
+
gimei.kanji #=> "小林 顕士"
|
|
57
|
+
|
|
58
|
+
gimei = Gimei.female
|
|
59
|
+
gimei.male? #=> false
|
|
60
|
+
gimei.female? #=> true
|
|
61
|
+
gimei.gender #=> :female
|
|
62
|
+
gimei.kanji #=> "根本 彩世"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
漢字、ひらがな、カタカナ、ローマ字どれか一種類だけ取得できればよい場合には、下記のように短縮して書くことも出来ます。
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
Gimei.kanji #=> "伊藤 結衣"
|
|
69
|
+
Gimei.hiragana #=> "いとう みさき"
|
|
70
|
+
Gimei.katakana #=> "タカハシ ユイナ"
|
|
71
|
+
Gimei.romaji #=> "Miki Obara"
|
|
72
|
+
Gimei.last.kanji #=> "清水"
|
|
73
|
+
Gimei.last.hiragana #=> "いとう"
|
|
74
|
+
Gimei.last.katakana #=> "コバヤシ"
|
|
75
|
+
Gimei.last.romaji #=> "Wakabayashi"
|
|
76
|
+
Gimei.first.kanji #=> "結菜"
|
|
77
|
+
Gimei.first.hiragana #=> "ここあ"
|
|
78
|
+
Gimei.first.katakana #=> "ヤマト"
|
|
79
|
+
Gimei.first.romaji #=> "Noriyuki"
|
|
80
|
+
|
|
81
|
+
Gimei.family.kanji #=> "黒沢"
|
|
82
|
+
Gimei.family.hiragana #=> "いずみ"
|
|
83
|
+
Gimei.family.katakana #=> "エノモト"
|
|
84
|
+
Gimei.family.romaji #=> "Okada"
|
|
85
|
+
|
|
86
|
+
Gimei.given.kanji #=> "航"
|
|
87
|
+
Gimei.given.hiragana #=> "まさみつ"
|
|
88
|
+
Gimei.given.katakana #=> "ユカ"
|
|
89
|
+
Gimei.given.romaji #=> "Haruto"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
同じ名前を二度取得したくない場合には、以下のように`unique`を挟みます。次のようにすると、利用した名前をGimei内で保持することで必ず一意な名前を返すようにできます。
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
Gimei.unique.name
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
上記の場合は、フルネームの漢字が一意であることを保証します。つまり、次のように姓や名の単位では重複することもありえます。
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
Gimei.unique.name.kanji #=> "前島 真一"
|
|
102
|
+
Gimei.unique.name.kanji #=> "神谷 真一"
|
|
103
|
+
Gimei.unique.name.kanji #=> "前島 太郎"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
これを避けたいときは次のように`last`や`first`を利用してください。これは姓や名の単位で一意な名前を返します。
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
Gimei.unique.last
|
|
110
|
+
Gimei.unique.first
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
この場合でも、ふりがな(フリガナ)の単位では重複することがあります。
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
Gimei.unique.first.hiragana #=> "しんいち"
|
|
117
|
+
Gimei.unique.first.hiragana #=> "しんいち"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
もし名前の候補が枯渇するなど、一意な名前を返せない場合はエラーになります。
|
|
121
|
+
|
|
122
|
+
これまで利用した名前のリストを消去したい場合は、次のようにします。
|
|
123
|
+
|
|
124
|
+
```ruby
|
|
125
|
+
Gimei.unique.clear # 全体を消去
|
|
126
|
+
Gimei.unique.clear(:name) # Gimei.unique.name の結果を消去
|
|
127
|
+
Gimei.unique.clear(:first) # Gimei.unique.first の結果を消去
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
次のメソッドで生成された名前は`Gimei.unique.clear(:name)`で消去します。
|
|
131
|
+
|
|
132
|
+
- `Gimei.unique.male`
|
|
133
|
+
- `Gimei.unique.female`
|
|
134
|
+
- `Gimei.unique.kanji`
|
|
135
|
+
|
|
136
|
+
出力される名前の候補となるデータは `lib/data/names.yml` にあるので、必要であればファイルを修正してください。
|
|
137
|
+
|
|
138
|
+
### 住所をランダムで返す
|
|
139
|
+
|
|
140
|
+
バージョン0.2.0からは、住所情報も取得できるようになりました。都道府県、区、市、町を組み合わせた住所情報を漢字、ひらがな、カタカナで取得することができます。
|
|
141
|
+
|
|
142
|
+
```ruby
|
|
143
|
+
address = Gimei.address
|
|
144
|
+
address.kanji # => 岡山県大島郡大和村稲木町
|
|
145
|
+
address.to_s # => 岡山県大島郡大和村稲木町
|
|
146
|
+
address.hiragana # => おかやまけんおおしまぐんやまとそんいなぎちょう
|
|
147
|
+
address.katakana # => オカヤマケンオオシマグンヤマトソンイナギチョウ
|
|
148
|
+
address.romaji # => Okayamaken Ooshimagunyamatoson Inagicho
|
|
149
|
+
|
|
150
|
+
address.prefecture.kanji # => 岡山県
|
|
151
|
+
address.prefecture.to_s # => 岡山県
|
|
152
|
+
address.prefecture.hiragana # => おかやまけん
|
|
153
|
+
address.prefecture.katakana # => オカヤマケン
|
|
154
|
+
address.prefecture.romaji # => Okayamaken
|
|
155
|
+
|
|
156
|
+
address.city.kanji # => 大島郡大和村
|
|
157
|
+
address.city.to_s # => 大島郡大和村
|
|
158
|
+
address.city.hiragana # => おおしまぐんやまとそん
|
|
159
|
+
address.city.katakana # => オオシマグンヤマトソン
|
|
160
|
+
address.city.romaji # => Ooshimagunyamatoson
|
|
161
|
+
|
|
162
|
+
address.town.kanji # => 稲木町
|
|
163
|
+
address.town.to_s # => 稲木町
|
|
164
|
+
address.town.hiragana # => いなぎちょう
|
|
165
|
+
address.town.katakana # => イナギチョウ
|
|
166
|
+
address.town.romaji # => Inagicho
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
省略形も用意しています。
|
|
170
|
+
|
|
171
|
+
```ruby
|
|
172
|
+
Gimei.prefecture.kanji # => 青森県
|
|
173
|
+
Gimei.prefecture.to_s # => 滋賀県
|
|
174
|
+
Gimei.prefecture.hiragana # => やまがたけん
|
|
175
|
+
Gimei.prefecture.katakana # => チバケン
|
|
176
|
+
Gimei.prefecture.romaji # => Wakayamaken
|
|
177
|
+
|
|
178
|
+
Gimei.city.kanji # => 利根郡昭和村
|
|
179
|
+
Gimei.city.hiragana # => うべし
|
|
180
|
+
Gimei.city.katakana # => カモグンヤオツチョウ
|
|
181
|
+
Gimei.city.romaji # => Itanogunaizumichou
|
|
182
|
+
|
|
183
|
+
Gimei.town.kanji # => 竹野
|
|
184
|
+
Gimei.town.to_s # => 富久山町南小泉
|
|
185
|
+
Gimei.town.hiragana # => じょうしんでん
|
|
186
|
+
Gimei.town.katakana # => イケナイ
|
|
187
|
+
Gimei.town.romaji # => Heisei
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
同じ住所を二度取得したくない場合には、以下のように`unique`を挟みます。次のようにすると、利用した住所をGimei内で保持することで必ず一意な名前を返すようにできます。
|
|
191
|
+
|
|
192
|
+
```ruby
|
|
193
|
+
address = Gimei.unique.address
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
上記の場合は、住所全体が一意であることを保証します。つまり、次のように県や市町村の単位では重複することもありえます。
|
|
197
|
+
|
|
198
|
+
```ruby
|
|
199
|
+
Gimei.unique.address.prefecture.kanji #=> 東京都
|
|
200
|
+
Gimei.unique.address.prefecture.kanji #=> 東京都
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
もし県や市町村の単位で一意であることを保証したいのであれば、次のように短縮形を使います。
|
|
204
|
+
|
|
205
|
+
```ruby
|
|
206
|
+
Gimei.unique.prefecture.kanji #=> 東京都
|
|
207
|
+
Gimei.unique.prefecture.kanji #=> 神奈川県
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
もし住所の候補が枯渇するなど、一意な名前を返せない場合はエラーになります。
|
|
211
|
+
|
|
212
|
+
これまで利用した住所のリストを消去したい場合は、次のようにします。
|
|
213
|
+
|
|
214
|
+
```ruby
|
|
215
|
+
Gimei.unique.clear # 全体を消去
|
|
216
|
+
Gimei.unique.clear(:address) # Gimei.unique.address の結果を消去
|
|
217
|
+
Gimei.unique.clear(:prefecture) # Gimei.unique.prefecture の結果を消去
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
出力される住所の候補となるデータは `lib/data/addresses.yml` にあるので、必要であればファイルを修正してください。
|
|
221
|
+
|
|
222
|
+
### 再現可能なランダムデータ
|
|
223
|
+
|
|
224
|
+
下記のように乱数生成器を設定することで、再現性のあるランダムデータを生成できます。
|
|
225
|
+
|
|
226
|
+
```ruby
|
|
227
|
+
Gimei.config.rng = Random.new(42)
|
|
228
|
+
Gimei.name.kanji #=> "飯島 誠吾"
|
|
229
|
+
Gimei.address.kanji #=> "熊本県日進市東場内"
|
|
230
|
+
|
|
231
|
+
Gimei.config.rng = Random.new(42)
|
|
232
|
+
Gimei.name.kanji #=> "飯島 誠吾"
|
|
233
|
+
Gimei.address.kanji #=> "熊本県日進市東場内"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Supported versions
|
|
237
|
+
|
|
238
|
+
Ruby 2.3以上
|
|
239
|
+
|
|
240
|
+
## 他言語による実装
|
|
241
|
+
|
|
242
|
+
- .NET [matarillo/dot-gimei](https://github.com/matarillo/dot-gimei)
|
|
243
|
+
- Elixir [ma2gedev/gimei_ex](https://github.com/ma2gedev/gimei_ex)
|
|
244
|
+
- Emacs Lisp [gongo/emacs-gimei](https://github.com/gongo/emacs-gimei)
|
|
245
|
+
- Go [mattn/go-gimei](https://github.com/mattn/go-gimei)
|
|
246
|
+
- Java [moznion/gimei-java](https://github.com/moznion/gimei-java)
|
|
247
|
+
- Node.js [sabakan404/node-gimei](https://github.com/sabakan404/node-gimei)
|
|
248
|
+
- Perl [youpong/Data-Gimei](https://github.com/youpong/Data-Gimei)
|
|
249
|
+
- Python [nabetama/gimei](https://github.com/nabetama/gimei)
|
|
250
|
+
- TypeScript [abcb2/type-gimei](https://github.com/abcb2/type-gimei)
|
|
251
|
+
|
|
252
|
+
## Installation
|
|
253
|
+
|
|
254
|
+
Add this line to your application's Gemfile:
|
|
255
|
+
|
|
256
|
+
gem 'gimei'
|
|
257
|
+
|
|
258
|
+
And then execute:
|
|
259
|
+
|
|
260
|
+
$ bundle
|
|
261
|
+
|
|
262
|
+
Or install it yourself as:
|
|
263
|
+
|
|
264
|
+
$ gem install gimei
|
|
265
|
+
|
|
266
|
+
## Contributing
|
|
267
|
+
|
|
268
|
+
1. Fork it
|
|
269
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
270
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
271
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
272
|
+
5. Create new Pull Request
|
data/README.md
CHANGED
|
@@ -4,35 +4,36 @@
|
|
|
4
4
|
[](https://codeclimate.com/github/willnet/gimei)
|
|
5
5
|
[](https://rubygems.org/gems/gimei)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[日本語のドキュメントはこちら(Japanese README)](README.ja.md)
|
|
8
8
|
|
|
9
|
+
gimei is a library that generates random Japanese names and addresses. It is useful for testing purposes. A similar library is [faker](https://github.com/stympy/faker). [faker](https://github.com/stympy/faker) is an excellent library with multilingual support, but naturally does not support furigana (reading of Japanese characters). gimei supports furigana.
|
|
9
10
|
|
|
10
|
-
##
|
|
11
|
+
## Usage
|
|
11
12
|
|
|
12
|
-
###
|
|
13
|
+
### Generate random names
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
You can use it as follows:
|
|
15
16
|
|
|
16
17
|
```ruby
|
|
17
18
|
gimei = Gimei.name
|
|
18
|
-
gimei.kanji #=> "斎藤 陽菜"
|
|
19
|
+
gimei.kanji #=> "斎藤 陽菜" (Saitou Haruna)
|
|
19
20
|
gimei.hiragana #=> "さいとう はるな"
|
|
20
21
|
gimei.katakana #=> "サイトウ ハルナ"
|
|
21
22
|
gimei.romaji #=> "Haruna Saitou"
|
|
22
23
|
gimei.gender #=> :female
|
|
23
24
|
gimei.male? #=> false
|
|
24
25
|
gimei.female? #=> true
|
|
25
|
-
gimei.last.kanji #=> "斎藤"
|
|
26
|
+
gimei.last.kanji #=> "斎藤" (Saitou)
|
|
26
27
|
gimei.last.hiragana #=> "さいとう"
|
|
27
28
|
gimei.last.katakana #=> "サイトウ"
|
|
28
29
|
gimei.last.romaji #=> "Saitou"
|
|
29
|
-
gimei.first.kanji #=> "陽菜"
|
|
30
|
+
gimei.first.kanji #=> "陽菜" (Haruna)
|
|
30
31
|
gimei.first.hiragana #=> "はるな"
|
|
31
32
|
gimei.first.katakana #=> "ハルナ"
|
|
32
33
|
gimei.first.romaji #=> "Haruna"
|
|
33
34
|
```
|
|
34
35
|
|
|
35
|
-
`gimei.
|
|
36
|
+
You can also use `gimei.family` and `gimei.given` instead of `gimei.last` and `gimei.first`.
|
|
36
37
|
|
|
37
38
|
```ruby
|
|
38
39
|
gimei.family.kanji #=> "斎藤"
|
|
@@ -46,23 +47,23 @@ gimei.given.katakana #=> "ハルナ"
|
|
|
46
47
|
gimei.given.romaji #=> "Haruna"
|
|
47
48
|
```
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
You can explicitly specify whether to return a male or female name as shown below. `Gimei.name` returns male and female names with equal probability.
|
|
50
51
|
|
|
51
52
|
```ruby
|
|
52
53
|
gimei = Gimei.male
|
|
53
54
|
gimei.male? #=> true
|
|
54
55
|
gimei.female? #=> false
|
|
55
56
|
gimei.gender #=> :male
|
|
56
|
-
gimei.kanji #=> "小林 顕士"
|
|
57
|
+
gimei.kanji #=> "小林 顕士" (Kobayashi Kenji)
|
|
57
58
|
|
|
58
59
|
gimei = Gimei.female
|
|
59
60
|
gimei.male? #=> false
|
|
60
61
|
gimei.female? #=> true
|
|
61
62
|
gimei.gender #=> :female
|
|
62
|
-
gimei.kanji #=> "根本 彩世"
|
|
63
|
+
gimei.kanji #=> "根本 彩世" (Nemoto Ayase)
|
|
63
64
|
```
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
If you only need one type of script (Kanji, Hiragana, Katakana, or Romaji), you can write it in a shortened form as follows:
|
|
66
67
|
|
|
67
68
|
```ruby
|
|
68
69
|
Gimei.kanji #=> "伊藤 結衣"
|
|
@@ -89,13 +90,13 @@ Gimei.given.katakana #=> "ユカ"
|
|
|
89
90
|
Gimei.given.romaji #=> "Haruto"
|
|
90
91
|
```
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
If you do not want to retrieve the same name twice, you can use `unique`. By doing so, Gimei will keep track of the names used and ensure that a unique name is returned.
|
|
93
94
|
|
|
94
95
|
```ruby
|
|
95
96
|
Gimei.unique.name
|
|
96
97
|
```
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
In the above case, the full name in Kanji is guaranteed to be unique. That is, there may be duplicates in terms of surname or given name, as shown below.
|
|
99
100
|
|
|
100
101
|
```ruby
|
|
101
102
|
Gimei.unique.name.kanji #=> "前島 真一"
|
|
@@ -103,41 +104,41 @@ Gimei.unique.name.kanji #=> "神谷 真一"
|
|
|
103
104
|
Gimei.unique.name.kanji #=> "前島 太郎"
|
|
104
105
|
```
|
|
105
106
|
|
|
106
|
-
|
|
107
|
+
If you want to avoid this, use `last` or `first` as follows. This returns a unique name for the surname or given name.
|
|
107
108
|
|
|
108
109
|
```ruby
|
|
109
110
|
Gimei.unique.last
|
|
110
111
|
Gimei.unique.first
|
|
111
112
|
```
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
Even in this case, there may be duplicates in terms of furigana.
|
|
114
115
|
|
|
115
116
|
```ruby
|
|
116
117
|
Gimei.unique.first.hiragana #=> "しんいち"
|
|
117
118
|
Gimei.unique.first.hiragana #=> "しんいち"
|
|
118
119
|
```
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
If unique names cannot be returned (e.g., if the list of candidates is exhausted), an error will be raised.
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
If you want to clear the list of names used so far, do the following:
|
|
123
124
|
|
|
124
125
|
```ruby
|
|
125
|
-
Gimei.unique.clear #
|
|
126
|
-
Gimei.unique.clear(:name) # Gimei.unique.name
|
|
127
|
-
Gimei.unique.clear(:first) # Gimei.unique.first
|
|
126
|
+
Gimei.unique.clear # Clear all
|
|
127
|
+
Gimei.unique.clear(:name) # Clear results of Gimei.unique.name
|
|
128
|
+
Gimei.unique.clear(:first) # Clear results of Gimei.unique.first
|
|
128
129
|
```
|
|
129
130
|
|
|
130
|
-
|
|
131
|
+
Names generated by the following methods are cleared with `Gimei.unique.clear(:name)`.
|
|
131
132
|
|
|
132
133
|
- `Gimei.unique.male`
|
|
133
134
|
- `Gimei.unique.female`
|
|
134
135
|
- `Gimei.unique.kanji`
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
The candidate data for names is located in `lib/data/names.yml`. Modify the file if necessary.
|
|
137
138
|
|
|
138
|
-
###
|
|
139
|
+
### Generate random addresses
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
From version 0.2.0, you can also retrieve address information. You can get address information combining prefecture, city/ward, and town in Kanji, Hiragana, and Katakana.
|
|
141
142
|
|
|
142
143
|
```ruby
|
|
143
144
|
address = Gimei.address
|
|
@@ -166,7 +167,7 @@ address.town.katakana # => イナギチョウ
|
|
|
166
167
|
address.town.romaji # => Inagicho
|
|
167
168
|
```
|
|
168
169
|
|
|
169
|
-
|
|
170
|
+
Abbreviations are also available.
|
|
170
171
|
|
|
171
172
|
```ruby
|
|
172
173
|
Gimei.prefecture.kanji # => 青森県
|
|
@@ -187,41 +188,41 @@ Gimei.town.katakana # => イケナイ
|
|
|
187
188
|
Gimei.town.romaji # => Heisei
|
|
188
189
|
```
|
|
189
190
|
|
|
190
|
-
|
|
191
|
+
If you do not want to retrieve the same address twice, use `unique` as follows. By doing so, Gimei will keep track of the addresses used and ensure that a unique address is returned.
|
|
191
192
|
|
|
192
193
|
```ruby
|
|
193
194
|
address = Gimei.unique.address
|
|
194
195
|
```
|
|
195
196
|
|
|
196
|
-
|
|
197
|
+
In the above case, the entire address is guaranteed to be unique. That is, duplicates may occur at the prefecture or municipality level as shown below.
|
|
197
198
|
|
|
198
199
|
```ruby
|
|
199
200
|
Gimei.unique.address.prefecture.kanji #=> 東京都
|
|
200
201
|
Gimei.unique.address.prefecture.kanji #=> 東京都
|
|
201
202
|
```
|
|
202
203
|
|
|
203
|
-
|
|
204
|
+
If you want to ensure uniqueness at the prefecture or municipality level, use the abbreviated forms as follows.
|
|
204
205
|
|
|
205
206
|
```ruby
|
|
206
207
|
Gimei.unique.prefecture.kanji #=> 東京都
|
|
207
208
|
Gimei.unique.prefecture.kanji #=> 神奈川県
|
|
208
209
|
```
|
|
209
210
|
|
|
210
|
-
|
|
211
|
+
If unique names cannot be returned (e.g., if the list of candidates is exhausted), an error will be raised.
|
|
211
212
|
|
|
212
|
-
|
|
213
|
+
If you want to clear the list of addresses used so far, do the following:
|
|
213
214
|
|
|
214
215
|
```ruby
|
|
215
|
-
Gimei.unique.clear #
|
|
216
|
-
Gimei.unique.clear(:address) # Gimei.unique.address
|
|
217
|
-
Gimei.unique.clear(:prefecture) # Gimei.unique.prefecture
|
|
216
|
+
Gimei.unique.clear # Clear all
|
|
217
|
+
Gimei.unique.clear(:address) # Clear results of Gimei.unique.address
|
|
218
|
+
Gimei.unique.clear(:prefecture) # Clear results of Gimei.unique.prefecture
|
|
218
219
|
```
|
|
219
220
|
|
|
220
|
-
|
|
221
|
+
The candidate data for addresses is located in `lib/data/addresses.yml`. Modify the file if necessary.
|
|
221
222
|
|
|
222
|
-
###
|
|
223
|
+
### Reproducible random data
|
|
223
224
|
|
|
224
|
-
|
|
225
|
+
You can generate reproducible random data by setting a random number generator as follows.
|
|
225
226
|
|
|
226
227
|
```ruby
|
|
227
228
|
Gimei.config.rng = Random.new(42)
|
|
@@ -235,9 +236,9 @@ Gimei.address.kanji #=> "熊本県日進市東場内"
|
|
|
235
236
|
|
|
236
237
|
## Supported versions
|
|
237
238
|
|
|
238
|
-
Ruby 2.3
|
|
239
|
+
Ruby 2.3 or higher
|
|
239
240
|
|
|
240
|
-
##
|
|
241
|
+
## Implementations in other languages
|
|
241
242
|
|
|
242
243
|
- .NET [matarillo/dot-gimei](https://github.com/matarillo/dot-gimei)
|
|
243
244
|
- Elixir [ma2gedev/gimei_ex](https://github.com/ma2gedev/gimei_ex)
|
|
@@ -269,4 +270,4 @@ Or install it yourself as:
|
|
|
269
270
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
270
271
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
271
272
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
272
|
-
5. Create new Pull Request
|
|
273
|
+
5. Create new Pull Request
|
data/lib/gimei/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -6,6 +6,7 @@ require 'simplecov'
|
|
|
6
6
|
SimpleCov.start
|
|
7
7
|
require 'gimei'
|
|
8
8
|
require 'minitest/autorun'
|
|
9
|
+
require 'minitest/mock'
|
|
9
10
|
|
|
10
11
|
def zenkaku_regexp
|
|
11
12
|
/\p{Hiragana}|\p{Katakana}|[一-龠々]/
|
|
@@ -14,4 +15,3 @@ end
|
|
|
14
15
|
def zenkaku_or_space_regexp
|
|
15
16
|
/\p{Hiragana}|\p{Katakana}|[一-龠々]|\s/
|
|
16
17
|
end
|
|
17
|
-
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gimei
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- willnet
|
|
@@ -45,11 +45,13 @@ extensions: []
|
|
|
45
45
|
extra_rdoc_files: []
|
|
46
46
|
files:
|
|
47
47
|
- ".github/dependabot.yml"
|
|
48
|
+
- ".github/workflows/push_gem.yml"
|
|
48
49
|
- ".github/workflows/test.yml"
|
|
49
50
|
- ".gitignore"
|
|
50
51
|
- CHANGELOG.md
|
|
51
52
|
- Gemfile
|
|
52
53
|
- LICENSE.txt
|
|
54
|
+
- README.ja.md
|
|
53
55
|
- README.md
|
|
54
56
|
- Rakefile
|
|
55
57
|
- Steepfile
|
|
@@ -93,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
93
95
|
- !ruby/object:Gem::Version
|
|
94
96
|
version: '0'
|
|
95
97
|
requirements: []
|
|
96
|
-
rubygems_version:
|
|
98
|
+
rubygems_version: 4.0.3
|
|
97
99
|
specification_version: 4
|
|
98
100
|
summary: random Japanese name and address generator. support kanji, hiragana, and
|
|
99
101
|
katakana
|