gimei 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +20 -31
- data/CHANGELOG.md +2 -0
- data/Gemfile +1 -0
- data/README.md +2 -2
- data/Steepfile +13 -0
- data/lib/gimei/address.rb +3 -3
- data/lib/gimei/name.rb +9 -6
- data/lib/gimei/version.rb +1 -1
- data/lib/gimei.rb +7 -5
- data/sig/gimei/address.rbs +42 -0
- data/sig/gimei/config.rbs +6 -0
- data/sig/gimei/name.rbs +58 -0
- data/sig/gimei/romaji.rbs +4 -0
- data/sig/gimei/unique_generator.rbs +23 -0
- data/sig/gimei/version.rbs +3 -0
- data/sig/gimei.rbs +30 -0
- data/steep_expectations.yml +23 -0
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5790029efdd49745df0cae0618b7be59b722ca1fd3041ec0d16458677f176f90
|
4
|
+
data.tar.gz: a6751528cd6333057e08b0bd39cda08cc59a91b768a4f0eff1707087b6c1c0ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9228724dd0f8bb2695b6555a13d2f338ef331497dd93140d932a3033a4830544b7e5d2ba05525714d2fb70a764377b1e0b397cb60df5627dbffb13fcd4b15044
|
7
|
+
data.tar.gz: 819cfbcbdd87a6219595a109b1d16e41a7f21e45b4b939cbdda944752148c89d593ab3e2d8500c3459a8fd6bd935abaa56903b661692aa64a0626ca54cc19075
|
data/.github/workflows/test.yml
CHANGED
@@ -20,41 +20,18 @@ jobs:
|
|
20
20
|
fail-fast: false
|
21
21
|
|
22
22
|
matrix:
|
23
|
-
ruby:
|
24
|
-
- ruby:2.2
|
25
|
-
- ruby:2.3
|
26
|
-
- ruby:2.4
|
27
|
-
- ruby:2.5
|
28
|
-
- ruby:2.6
|
29
|
-
- ruby:2.7
|
30
|
-
- ruby:3.0
|
31
|
-
- ruby:3.1
|
32
|
-
- ruby:3.2
|
33
|
-
- rubylang/ruby:master-jammy
|
23
|
+
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', 'head']
|
34
24
|
include:
|
35
|
-
- ruby:
|
36
|
-
allow_failures:
|
25
|
+
- ruby-version: 'head'
|
26
|
+
allow_failures: 'true'
|
37
27
|
|
38
28
|
steps:
|
39
|
-
- uses: actions/checkout@
|
40
|
-
|
41
|
-
|
42
|
-
uses: actions/cache@v3
|
43
|
-
id: cache_gem
|
29
|
+
- uses: actions/checkout@v4
|
30
|
+
- name: Set up Ruby
|
31
|
+
uses: ruby/setup-ruby@v1
|
44
32
|
with:
|
45
|
-
|
46
|
-
|
47
|
-
restore-keys: |
|
48
|
-
v1-gem-${{ runner.os }}-${{ matrix.ruby }}-
|
49
|
-
continue-on-error: ${{ matrix.allow_failures == 'true' }}
|
50
|
-
|
51
|
-
- name: bundle update
|
52
|
-
run: |
|
53
|
-
set -xe
|
54
|
-
bundle config path vendor/bundle
|
55
|
-
bundle update --jobs $(nproc) --retry 3
|
56
|
-
continue-on-error: ${{ matrix.allow_failures == 'true' }}
|
57
|
-
|
33
|
+
ruby-version: ${{ matrix.ruby-version }}
|
34
|
+
bundler-cache: true
|
58
35
|
- name: Run test
|
59
36
|
run: |
|
60
37
|
set -xe
|
@@ -63,3 +40,15 @@ jobs:
|
|
63
40
|
|
64
41
|
- name: Coveralls
|
65
42
|
uses: coverallsapp/github-action@v2
|
43
|
+
|
44
|
+
type-check:
|
45
|
+
runs-on: ubuntu-latest
|
46
|
+
steps:
|
47
|
+
- uses: actions/checkout@v4
|
48
|
+
- name: Set up Ruby
|
49
|
+
uses: ruby/setup-ruby@v1
|
50
|
+
with:
|
51
|
+
ruby-version: 3.3
|
52
|
+
bundler-cache: true
|
53
|
+
- name: Run type check
|
54
|
+
run: bundle exec steep check --with-expectations
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -238,7 +238,6 @@ Gimei.address.kanji #=> "熊本県日進市東場内"
|
|
238
238
|
|
239
239
|
## Supported versions
|
240
240
|
|
241
|
-
- 2.2.x
|
242
241
|
- 2.3.x
|
243
242
|
- 2.4.x
|
244
243
|
- 2.5.x
|
@@ -247,6 +246,7 @@ Gimei.address.kanji #=> "熊本県日進市東場内"
|
|
247
246
|
- 3.0.x
|
248
247
|
- 3.1.x
|
249
248
|
- 3.2.x
|
249
|
+
- 3.3.x
|
250
250
|
|
251
251
|
## 他言語による実装
|
252
252
|
|
@@ -255,7 +255,7 @@ Gimei.address.kanji #=> "熊本県日進市東場内"
|
|
255
255
|
- Emacs Lisp [gongo/emacs-gimei](https://github.com/gongo/emacs-gimei)
|
256
256
|
- Go [mattn/go-gimei](https://github.com/mattn/go-gimei)
|
257
257
|
- Java [moznion/gimei-java](https://github.com/moznion/gimei-java)
|
258
|
-
- Node.js [
|
258
|
+
- Node.js [sabakan404/node-gimei](https://github.com/sabakan404/node-gimei)
|
259
259
|
- Perl [youpong/Data-Gimei](https://github.com/youpong/Data-Gimei)
|
260
260
|
- Python [nabetama/gimei](https://github.com/nabetama/gimei)
|
261
261
|
- TypeScript [abcb2/type-gimei](https://github.com/abcb2/type-gimei)
|
data/Steepfile
ADDED
data/lib/gimei/address.rb
CHANGED
@@ -43,7 +43,7 @@ class Gimei::Address
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def initialize
|
46
|
-
@prefectures = Gimei.addresses['addresses']['prefecture'].sample(random: Gimei.config.rng)
|
46
|
+
@prefectures = Gimei.addresses['addresses']['prefecture'].sample(random: Gimei.config.rng) #: [String, String, String]
|
47
47
|
end
|
48
48
|
|
49
49
|
alias_method :to_s, :kanji
|
@@ -67,7 +67,7 @@ class Gimei::Address
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def initialize
|
70
|
-
@cities = Gimei.addresses['addresses']['city'].sample(random: Gimei.config.rng)
|
70
|
+
@cities = Gimei.addresses['addresses']['city'].sample(random: Gimei.config.rng) #: [String, String, String]
|
71
71
|
end
|
72
72
|
|
73
73
|
alias_method :to_s, :kanji
|
@@ -91,7 +91,7 @@ class Gimei::Address
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def initialize
|
94
|
-
@towns = Gimei.addresses['addresses']['town'].sample(random: Gimei.config.rng)
|
94
|
+
@towns = Gimei.addresses['addresses']['town'].sample(random: Gimei.config.rng) #: [String, String, String]
|
95
95
|
end
|
96
96
|
|
97
97
|
alias_method :to_s, :kanji
|
data/lib/gimei/name.rb
CHANGED
@@ -15,14 +15,16 @@ class Gimei::Name
|
|
15
15
|
end
|
16
16
|
|
17
17
|
%i[kanji hiragana katakana romaji first last family given].each do |method_name|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
class_eval(<<~METHOD, __FILE__, __LINE__ + 1)
|
19
|
+
def #{method_name}(gender = nil)
|
20
|
+
new(gender).#{method_name}
|
21
|
+
end
|
22
|
+
METHOD
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
def initialize(gender = nil)
|
25
|
-
@gender = gender || Gimei::GENDERS.sample(random: Gimei.config.rng)
|
27
|
+
@gender = gender || Gimei::GENDERS.sample(random: Gimei.config.rng) #: :male | :female
|
26
28
|
@first = First.new @gender
|
27
29
|
@last = Last.new
|
28
30
|
end
|
@@ -71,7 +73,7 @@ class Gimei::Name
|
|
71
73
|
def_delegators :@name, :kanji, :hiragana, :katakana, :to_s, :romaji
|
72
74
|
|
73
75
|
def initialize(gender = nil)
|
74
|
-
@gender = gender || Gimei::GENDERS.sample(random: Gimei.config.rng)
|
76
|
+
@gender = gender || Gimei::GENDERS.sample(random: Gimei.config.rng) #: :male | :female
|
75
77
|
@name = NameWord.new(Gimei.names['first_name'][@gender.to_s].sample(random: Gimei.config.rng))
|
76
78
|
end
|
77
79
|
|
@@ -89,7 +91,8 @@ class Gimei::Name
|
|
89
91
|
def_delegators :@name, :kanji, :hiragana, :katakana, :to_s, :romaji
|
90
92
|
|
91
93
|
def initialize
|
92
|
-
|
94
|
+
name = Gimei.names['last_name'].sample(random: Gimei.config.rng) #: [String, String, String]
|
95
|
+
@name = NameWord.new(name)
|
93
96
|
end
|
94
97
|
end
|
95
98
|
|
data/lib/gimei/version.rb
CHANGED
data/lib/gimei.rb
CHANGED
@@ -9,7 +9,7 @@ require 'gimei/config'
|
|
9
9
|
class Gimei
|
10
10
|
extend Forwardable
|
11
11
|
|
12
|
-
GENDERS = [:male, :female].freeze
|
12
|
+
GENDERS = [:male, :female].freeze #: [:male, :female]
|
13
13
|
|
14
14
|
def_delegators :@name,
|
15
15
|
:first, :last, :gender,
|
@@ -24,7 +24,7 @@ class Gimei
|
|
24
24
|
class << self
|
25
25
|
extend Forwardable
|
26
26
|
|
27
|
-
def_delegators Gimei::Name, :male, :female
|
27
|
+
def_delegators 'Gimei::Name', :male, :female
|
28
28
|
def_delegators :address, :prefecture, :city, :town
|
29
29
|
|
30
30
|
def name(gender = nil)
|
@@ -40,9 +40,11 @@ class Gimei
|
|
40
40
|
end
|
41
41
|
|
42
42
|
%i[kanji hiragana katakana romaji first last family given].each do |method_name|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
class_eval(<<~METHOD, __FILE__, __LINE__ + 1)
|
44
|
+
def #{method_name}(gender = nil)
|
45
|
+
new(gender).#{method_name}
|
46
|
+
end
|
47
|
+
METHOD
|
46
48
|
end
|
47
49
|
|
48
50
|
def address
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Gimei
|
2
|
+
class Address
|
3
|
+
attr_reader prefecture: Prefecture
|
4
|
+
attr_reader city: City
|
5
|
+
attr_reader town: Town
|
6
|
+
def initialize: -> void
|
7
|
+
def kanji: -> String
|
8
|
+
def hiragana: -> String
|
9
|
+
def katakana: -> String
|
10
|
+
def romaji: -> String
|
11
|
+
|
12
|
+
class Prefecture
|
13
|
+
@prefectures: [String, String, String]
|
14
|
+
|
15
|
+
def kanji: -> String
|
16
|
+
def hiragana: -> String
|
17
|
+
def katakana: -> String
|
18
|
+
def romaji: -> String
|
19
|
+
def initialize: -> void
|
20
|
+
end
|
21
|
+
|
22
|
+
class City
|
23
|
+
@cities: [String, String, String]
|
24
|
+
|
25
|
+
def kanji: -> String
|
26
|
+
def hiragana: -> String
|
27
|
+
def katakana: -> String
|
28
|
+
def romaji: -> String
|
29
|
+
def initialize: -> void
|
30
|
+
end
|
31
|
+
|
32
|
+
class Town
|
33
|
+
@towns: [String, String, String]
|
34
|
+
|
35
|
+
def kanji: -> String
|
36
|
+
def hiragana: -> String
|
37
|
+
def katakana: -> String
|
38
|
+
def romaji: -> String
|
39
|
+
def initialize: -> void
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/sig/gimei/name.rbs
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
class Gimei
|
2
|
+
class Name
|
3
|
+
attr_reader first: First
|
4
|
+
attr_reader last: Last
|
5
|
+
attr_reader gender: gender_type
|
6
|
+
def self.male: -> Name
|
7
|
+
def self.female: -> Name
|
8
|
+
def initialize: (?(gender_type)? gender) -> void
|
9
|
+
def kanji: -> String
|
10
|
+
def hiragana: -> String
|
11
|
+
def katakana: -> String
|
12
|
+
def romaji: -> String
|
13
|
+
def male?: -> bool
|
14
|
+
def female?: -> bool
|
15
|
+
alias family last
|
16
|
+
alias given first
|
17
|
+
|
18
|
+
class First
|
19
|
+
extend Forwardable
|
20
|
+
@gender: gender_type
|
21
|
+
@name: NameWord
|
22
|
+
|
23
|
+
def self.male: -> First
|
24
|
+
def self.female: -> First
|
25
|
+
def initialize: (?(gender_type)? gender) -> void
|
26
|
+
def kanji: -> String
|
27
|
+
def hiragana: -> String
|
28
|
+
def katakana: -> String
|
29
|
+
def to_s: -> String
|
30
|
+
def romaji: -> String
|
31
|
+
def male?: -> bool
|
32
|
+
def female?: -> bool
|
33
|
+
end
|
34
|
+
|
35
|
+
class Last
|
36
|
+
extend Forwardable
|
37
|
+
@gender: gender_type
|
38
|
+
@name: NameWord
|
39
|
+
|
40
|
+
def initialize: -> void
|
41
|
+
def kanji: -> String
|
42
|
+
def hiragana: -> String
|
43
|
+
def katakana: -> String
|
44
|
+
def to_s: -> String
|
45
|
+
def romaji: -> String
|
46
|
+
end
|
47
|
+
|
48
|
+
class NameWord
|
49
|
+
@name: [String, String, String]
|
50
|
+
|
51
|
+
def initialize: ([String, String, String] name) -> void
|
52
|
+
def kanji: -> String
|
53
|
+
def hiragana: -> String
|
54
|
+
def katakana: -> String
|
55
|
+
def romaji: -> String
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Gimei
|
2
|
+
class RetryLimitExceeded < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
class UniqueGenerator
|
6
|
+
self.@previous_results: Hash[Symbol, Set[String]]
|
7
|
+
|
8
|
+
def self.previous_results: -> Hash[Symbol, Set[String]]
|
9
|
+
def initialize: (Class klass, Integer max_retries) -> void
|
10
|
+
def previous_results: -> Hash[Symbol, Set[String]]
|
11
|
+
def clear: (?Symbol? key) -> void
|
12
|
+
def define_unique_method: (Symbol method_name, ?Symbol previous_result_key) -> Symbol
|
13
|
+
def name: -> Name
|
14
|
+
def first: -> Name::First
|
15
|
+
def last: -> Name::Last
|
16
|
+
alias family last
|
17
|
+
alias given first
|
18
|
+
|
19
|
+
private
|
20
|
+
attr_reader klass: Class
|
21
|
+
attr_reader max_retries: Integer
|
22
|
+
end
|
23
|
+
end
|
data/sig/gimei.rbs
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class Gimei
|
2
|
+
type gender_type = :female | :male
|
3
|
+
|
4
|
+
GENDERS: [:male, :female]
|
5
|
+
extend Forwardable
|
6
|
+
self.@names: untyped # (Hash['first_name', Hash[('male' | 'female'), Array[[String, String, String]]]] | Hash['last_name', Array[[String, String, String]]])
|
7
|
+
self.@addresses: Hash['addresses', Hash[('prefecture' | 'city' | 'town'), [String, String, String]]]
|
8
|
+
self.@unique: UniqueGenerator
|
9
|
+
self.@config: Config
|
10
|
+
|
11
|
+
attr_reader name: Name
|
12
|
+
attr_reader address: Address
|
13
|
+
def self.male: -> Name
|
14
|
+
def self.female: -> Name
|
15
|
+
def self.name: (?gender_type? gender) -> Name
|
16
|
+
def self.names: -> untyped # (Hash['first_name', Hash[('male' | 'female'), Array[[String, String, String]]]] | Hash['last_name', Array[[String, String, String]]])
|
17
|
+
def self.addresses: -> Hash['addresses', Hash[('prefecture' | 'city' | 'town'), Array[[String, String, String]]]]
|
18
|
+
def self.kanji: -> String
|
19
|
+
def self.hiragana: -> String
|
20
|
+
def self.katakana: -> String
|
21
|
+
def self.romaji: -> String
|
22
|
+
def self.first: -> Name::First
|
23
|
+
def self.last: -> Name::Last
|
24
|
+
def self.address: -> Address
|
25
|
+
def self.unique: (?Integer max_retries) -> UniqueGenerator
|
26
|
+
def self.config: -> Config
|
27
|
+
def initialize: (?gender_type? gender) -> void
|
28
|
+
alias self.family self.last
|
29
|
+
alias self.given self.first
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
- file: lib/gimei.rb
|
3
|
+
diagnostics:
|
4
|
+
- range:
|
5
|
+
start:
|
6
|
+
line: 27
|
7
|
+
character: 4
|
8
|
+
end:
|
9
|
+
line: 27
|
10
|
+
character: 18
|
11
|
+
severity: ERROR
|
12
|
+
message: Type `singleton(::Class)` does not have method `def_delegators`
|
13
|
+
code: Ruby::NoMethod
|
14
|
+
- range:
|
15
|
+
start:
|
16
|
+
line: 28
|
17
|
+
character: 4
|
18
|
+
end:
|
19
|
+
line: 28
|
20
|
+
character: 18
|
21
|
+
severity: ERROR
|
22
|
+
message: Type `singleton(::Class)` does not have method `def_delegators`
|
23
|
+
code: Ruby::NoMethod
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gimei
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.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: 2024-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: romaji
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- LICENSE.txt
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
|
+
- Steepfile
|
70
71
|
- _config.yml
|
71
72
|
- gimei.gemspec
|
72
73
|
- lib/data/addresses.yml
|
@@ -77,11 +78,19 @@ files:
|
|
77
78
|
- lib/gimei/name.rb
|
78
79
|
- lib/gimei/unique_generator.rb
|
79
80
|
- lib/gimei/version.rb
|
81
|
+
- sig/gimei.rbs
|
82
|
+
- sig/gimei/address.rbs
|
83
|
+
- sig/gimei/config.rbs
|
84
|
+
- sig/gimei/name.rbs
|
85
|
+
- sig/gimei/romaji.rbs
|
86
|
+
- sig/gimei/unique_generator.rbs
|
87
|
+
- sig/gimei/version.rbs
|
80
88
|
- spec/address_spec.rb
|
81
89
|
- spec/gimei_spec.rb
|
82
90
|
- spec/name_spec.rb
|
83
91
|
- spec/spec_helper.rb
|
84
92
|
- spec/unique_spec.rb
|
93
|
+
- steep_expectations.yml
|
85
94
|
homepage: https://github.com/willnet/gimei
|
86
95
|
licenses:
|
87
96
|
- MIT
|
@@ -101,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
110
|
- !ruby/object:Gem::Version
|
102
111
|
version: '0'
|
103
112
|
requirements: []
|
104
|
-
rubygems_version: 3.4.
|
113
|
+
rubygems_version: 3.4.22
|
105
114
|
signing_key:
|
106
115
|
specification_version: 4
|
107
116
|
summary: random Japanese name and address generator. support kanji, hiragana, and
|