japanese_address_parser 2.2.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 713a2974b9ccf061e4c834969e879e37918ffc49c8b312a63daf42b91abc98a1
4
- data.tar.gz: a3e41f696082da17e49b29ddec7a52228c8526fd8f74a9929f88aac9ba9b90a6
3
+ metadata.gz: 0a042febb9a10f78adeadbd23f6e99a97c69817546479ecbd2dc1cd1fe6f5f50
4
+ data.tar.gz: ed7d82baf90223493a3cb0e33b21afb2a61779cd57718e18f63358ddc963d66f
5
5
  SHA512:
6
- metadata.gz: e77067fd81c5347bfbe5af1d87f2da12de8814024c08bc79cfbdcd0c0eae2282b5a55a4cb62d789024b5fe028e62b39432c16bf5ab85dd29a9d2b845677640b8
7
- data.tar.gz: 3d92174c193a17f0eb7566d7bec1ea54cddb22dca403dcd1c8e365a3c34c164404ce09ce00ed4f3cb9ff3bbd9243363ded73eca87c7ea80128dc776c8d5fba29
6
+ metadata.gz: fbfe12bdc50a1eaacba31ad237a6034a3d1db4961d2f50b061ab862961753d4a62dc9515cc0d96373d1f432599906a49617687b5ed3b1f89ebf032c6110a0709
7
+ data.tar.gz: 00f949e850de4bd327af851ed3ff4d046423a73473b2a847f5b316fc91cb0dccc4ae06ebd36c7567b75bef8f690a8e48a13ba1c0464ca1ab4b655e874ec558c3
data/.rubocop.yml CHANGED
@@ -6,6 +6,7 @@ require:
6
6
 
7
7
  AllCops:
8
8
  EnabledByDefault: true
9
+ TargetRubyVersion: 2.7
9
10
 
10
11
  Metrics/BlockLength:
11
12
  Exclude:
@@ -35,3 +36,6 @@ Style/StringHashKeys:
35
36
  # elseがない場合にはcase文ではなくif文を許容する。
36
37
  Style/MissingElse:
37
38
  EnforcedStyle: case
39
+
40
+ Gemspec/DependencyVersion:
41
+ EnforcedStyle: forbidden
data/CHANGELOG.md CHANGED
@@ -17,6 +17,20 @@ Change Log の形式は [Keep a Changelog](http://keepachangelog.com/) に従い
17
17
 
18
18
  ### Security
19
19
 
20
+ ## [3.0.1] - 2022-09-25
21
+ ### Added
22
+
23
+ - [#53](https://github.com/yamat47/japanese_address_parser/pull/53) Steepでの型検査の仕組みを導入した。([@yamat47](https://github.com/yamat47))
24
+
25
+ ## [3.0.0] - 2022-09-25
26
+ ### Added
27
+
28
+ - [#49](https://github.com/yamat47/japanese_address_parser/pull/49) Dockerを使って開発環境の準備をできるようにした。([@yamat47](https://github.com/yamat47))
29
+
30
+ ### Security
31
+
32
+ - [#51](https://github.com/yamat47/japanese_address_parser/pull/51) Ruby 2.6 のサポートを切った。([@yamat47](https://github.com/yamat47))
33
+
20
34
  ## [2.2.1] - 2022-07-16
21
35
  ### Changed
22
36
 
data/Dockerfile ADDED
@@ -0,0 +1,17 @@
1
+ FROM ruby:3.1.2-alpine
2
+
3
+ ENV LANG=C.UTF-8 \
4
+ APP_HOME=/gemsrc
5
+
6
+ # `japanese_address_parser.gemspec` needs git.
7
+ RUN apk update && \
8
+ apk add --virtual build-dependencies --no-cache git nodejs make gcc musl-dev
9
+
10
+ RUN mkdir $APP_HOME
11
+ WORKDIR $APP_HOME
12
+
13
+ COPY . $APP_HOME
14
+
15
+ RUN bundle install
16
+
17
+ CMD sh -c "/bin/sh"
data/Gemfile.lock CHANGED
@@ -1,32 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- japanese_address_parser (2.2.1)
4
+ japanese_address_parser (3.0.1)
5
5
  schmooze
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.1.4.6)
10
+ activesupport (7.0.4)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
- zeitwerk (~> 2.3)
16
15
  ast (2.4.2)
17
- concurrent-ruby (1.1.9)
16
+ concurrent-ruby (1.1.10)
18
17
  diff-lcs (1.5.0)
19
- factory_bot (6.2.0)
18
+ factory_bot (6.2.1)
20
19
  activesupport (>= 5.0.0)
21
- i18n (1.10.0)
20
+ ffi (1.15.5)
21
+ i18n (1.12.0)
22
22
  concurrent-ruby (~> 1.0)
23
- minitest (5.15.0)
24
- parallel (1.21.0)
25
- parser (3.1.1.0)
23
+ json (2.6.2)
24
+ language_server-protocol (3.17.0.1)
25
+ listen (3.7.1)
26
+ rb-fsevent (~> 0.10, >= 0.10.3)
27
+ rb-inotify (~> 0.9, >= 0.9.10)
28
+ minitest (5.16.3)
29
+ parallel (1.22.1)
30
+ parser (3.1.2.1)
26
31
  ast (~> 2.4.1)
27
32
  rainbow (3.1.1)
28
33
  rake (13.0.6)
29
- regexp_parser (2.2.1)
34
+ rb-fsevent (0.11.2)
35
+ rb-inotify (0.10.1)
36
+ ffi (~> 1.0)
37
+ rbs (2.6.0)
38
+ regexp_parser (2.5.0)
30
39
  rexml (3.2.5)
31
40
  rspec (3.11.0)
32
41
  rspec-core (~> 3.11.0)
@@ -34,42 +43,56 @@ GEM
34
43
  rspec-mocks (~> 3.11.0)
35
44
  rspec-core (3.11.0)
36
45
  rspec-support (~> 3.11.0)
37
- rspec-expectations (3.11.0)
46
+ rspec-expectations (3.11.1)
38
47
  diff-lcs (>= 1.2.0, < 2.0)
39
48
  rspec-support (~> 3.11.0)
40
- rspec-mocks (3.11.0)
49
+ rspec-mocks (3.11.1)
41
50
  diff-lcs (>= 1.2.0, < 2.0)
42
51
  rspec-support (~> 3.11.0)
43
- rspec-support (3.11.0)
44
- rubocop (1.25.1)
52
+ rspec-support (3.11.1)
53
+ rubocop (1.36.0)
54
+ json (~> 2.3)
45
55
  parallel (~> 1.10)
46
- parser (>= 3.1.0.0)
56
+ parser (>= 3.1.2.1)
47
57
  rainbow (>= 2.2.2, < 4.0)
48
58
  regexp_parser (>= 1.8, < 3.0)
49
- rexml
50
- rubocop-ast (>= 1.15.1, < 2.0)
59
+ rexml (>= 3.2.5, < 4.0)
60
+ rubocop-ast (>= 1.20.1, < 2.0)
51
61
  ruby-progressbar (~> 1.7)
52
62
  unicode-display_width (>= 1.4.0, < 3.0)
53
- rubocop-ast (1.16.0)
63
+ rubocop-ast (1.21.0)
54
64
  parser (>= 3.1.1.0)
55
65
  rubocop-rake (0.6.0)
56
66
  rubocop (~> 1.0)
57
- rubocop-rspec (2.9.0)
58
- rubocop (~> 1.19)
67
+ rubocop-rspec (2.13.2)
68
+ rubocop (~> 1.33)
59
69
  ruby-progressbar (1.11.0)
60
70
  schmooze (0.2.0)
61
- tzinfo (2.0.4)
71
+ steep (1.1.1)
72
+ activesupport (>= 5.1)
73
+ language_server-protocol (>= 3.15, < 4.0)
74
+ listen (~> 3.0)
75
+ parallel (>= 1.0.0)
76
+ parser (>= 3.1)
77
+ rainbow (>= 2.2.2, < 4.0)
78
+ rbs (>= 2.3.2)
79
+ terminal-table (>= 2, < 4)
80
+ terminal-table (3.0.2)
81
+ unicode-display_width (>= 1.1.1, < 3)
82
+ typeprof (0.21.3)
83
+ rbs (>= 1.8.1)
84
+ tzinfo (2.0.5)
62
85
  concurrent-ruby (~> 1.0)
63
- unicode-display_width (2.1.0)
64
- zeitwerk (2.5.4)
86
+ unicode-display_width (2.3.0)
65
87
 
66
88
  PLATFORMS
89
+ aarch64-linux-musl
67
90
  arm64-darwin-21
68
91
  x86_64-darwin-21
69
92
  x86_64-linux
70
93
 
71
94
  DEPENDENCIES
72
- activesupport (< 7)
95
+ activesupport
73
96
  factory_bot
74
97
  japanese_address_parser!
75
98
  rake
@@ -77,6 +100,8 @@ DEPENDENCIES
77
100
  rubocop
78
101
  rubocop-rake
79
102
  rubocop-rspec
103
+ steep
104
+ typeprof
80
105
 
81
106
  BUNDLED WITH
82
107
  2.3.3
data/README.md CHANGED
@@ -111,6 +111,14 @@ address.furigana #=> "トウキョウトミナトクシバコウエン 4"
111
111
  bin/setup
112
112
  ```
113
113
 
114
+ 開発環境の構築は Docker を使ってもできます。
115
+ MacOS でしか試していないので、他プラットフォームで動かなかったら issue でご報告ください。
116
+
117
+ ```
118
+ docker compose build
119
+ docker compose run --rm gemsrc sh
120
+ ```
121
+
114
122
  自動テストやリンターを実行するには、このコマンドを実行してください:
115
123
 
116
124
  ```
data/Steepfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ target :lib do
4
+ signature 'sig'
5
+
6
+ check 'lib'
7
+ ignore 'lib/japanese_address_parser/csv_parser.rb'
8
+
9
+ configure_code_diagnostics(::Steep::Diagnostic::Ruby.strict)
10
+ end
11
+
12
+ target :test do
13
+ signature 'sig'
14
+
15
+ check 'spec'
16
+
17
+ configure_code_diagnostics(::Steep::Diagnostic::Ruby.strict)
18
+ end
@@ -0,0 +1,7 @@
1
+ version: "3"
2
+ services:
3
+ gemsrc:
4
+ build: .
5
+ tty: true
6
+ volumes:
7
+ - .:/gemsrc
@@ -12,7 +12,7 @@ require_relative 'lib/japanese_address_parser/version'
12
12
  spec.description = 'JapaneseAddressParser is a Ruby gem that parses Japanese address. To detect the address, it uses geolonia/japanese-addresses (https://github.com/geolonia/japanese-addresses) CSV data.'
13
13
  spec.homepage = 'https://github.com/yamat47/japanese_address_parser'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = '>= 2.6.0'
15
+ spec.required_ruby_version = '>= 2.7.0'
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = 'https://github.com/yamat47/japanese_address_parser'
@@ -31,12 +31,14 @@ require_relative 'lib/japanese_address_parser/version'
31
31
  spec.require_paths = ['lib']
32
32
 
33
33
  spec.add_dependency('schmooze')
34
- spec.add_development_dependency('activesupport', '< 7')
34
+ spec.add_development_dependency('activesupport')
35
35
  spec.add_development_dependency('factory_bot')
36
36
  spec.add_development_dependency('rake')
37
37
  spec.add_development_dependency('rspec')
38
38
  spec.add_development_dependency('rubocop')
39
39
  spec.add_development_dependency('rubocop-rake')
40
40
  spec.add_development_dependency('rubocop-rspec')
41
+ spec.add_development_dependency('steep')
42
+ spec.add_development_dependency('typeprof')
41
43
  spec.metadata['rubygems_mfa_required'] = 'true'
42
44
  end
@@ -5,10 +5,12 @@ require 'schmooze'
5
5
  module JapaneseAddressParser
6
6
  module AddressNormalizer
7
7
  class NormalizeJapaneseAddressesSchmoozer < ::Schmooze::Base
8
- JS_PACKAGE_PATH = ::File.expand_path('../../../js', __dir__)
8
+ current_dir = __dir__ || ''
9
+
10
+ JS_PACKAGE_PATH = ::File.expand_path('../../../js', current_dir)
9
11
  public_constant :JS_PACKAGE_PATH
10
12
 
11
- JAPANESE_API_PATH = "file://#{::File.expand_path('../data/geolonia-japanese-addresses/api/ja', __dir__)}"
13
+ JAPANESE_API_PATH = "file://#{::File.expand_path('../data/geolonia-japanese-addresses/api/ja', current_dir)}"
12
14
  public_constant :JAPANESE_API_PATH
13
15
 
14
16
  dependencies normalize_japanese_addresses: '@geolonia/normalize-japanese-addresses'
@@ -12,12 +12,7 @@ module JapaneseAddressParser
12
12
  def self.all
13
13
  filepath = Pathname(__FILE__).dirname.join('../data/prefectures.csv')
14
14
  ::CSV.table(filepath, converters: nil).map do |prefecture|
15
- new(
16
- code: prefecture[:code],
17
- name: prefecture[:name],
18
- name_kana: prefecture[:name_kana],
19
- name_romaji: prefecture[:name_romaji]
20
- )
15
+ new(code: prefecture[:code], name: prefecture[:name], name_kana: prefecture[:name_kana], name_romaji: prefecture[:name_romaji])
21
16
  end
22
17
  end
23
18
 
@@ -35,13 +30,7 @@ module JapaneseAddressParser
35
30
  def cities
36
31
  filepath = Pathname(__FILE__).dirname.join("../data/#{code}.csv")
37
32
  ::CSV.table(filepath, converters: nil).map do |city|
38
- ::JapaneseAddressParser::Models::City.new(
39
- code: city[:code],
40
- prefecture_code: city[:prefecture_code],
41
- name: city[:name],
42
- name_kana: city[:name_kana],
43
- name_romaji: city[:name_romaji]
44
- )
33
+ ::JapaneseAddressParser::Models::City.new(code: city[:code], prefecture_code: city[:prefecture_code], name: city[:name], name_kana: city[:name_kana], name_romaji: city[:name_romaji])
45
34
  end
46
35
  end
47
36
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JapaneseAddressParser
4
- VERSION = '2.2.1'
4
+ VERSION = '3.0.1'
5
5
  public_constant :VERSION
6
6
  end
@@ -1,4 +1,81 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
1
4
  module JapaneseAddressParser
2
5
  VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
6
+
7
+ def self.call: (String full_address) -> Models::Address?
8
+ def self.call!: (String full_address) -> Models::Address
9
+ def self._call: (String full_address) -> Models::Address
10
+
11
+ module AddressNormalizer
12
+ def self.call: (String full_address) -> String
13
+
14
+ class NormalizeJapaneseAddressesSchmoozer < Schmooze::Base
15
+ JS_PACKAGE_PATH: String
16
+ JAPANESE_API_PATH: String
17
+
18
+ def self.call: (String full_address) -> String
19
+ end
20
+ end
21
+
22
+ module Models
23
+ class Address
24
+ def initialize: (full_address: String, prefecture: String, city: String, town: String) -> void
25
+ def furigana: -> String
26
+ attr_reader full_address: String
27
+ attr_reader prefecture: String
28
+ attr_reader city: String
29
+ attr_reader town: String
30
+ end
31
+
32
+ class Town
33
+ def initialize: (name: String, name_kana: String, name_romaji: String, nickname: String, latitude: String, longitude: String) -> void
34
+ def attributes: -> {name: String, name_kana: String, name_romaji: String, nickname: String, latitude: String, longitude: String}
35
+ attr_reader name: String
36
+ attr_reader name_kana: String
37
+ attr_reader name_romaji: String
38
+ attr_reader nickname: String
39
+ attr_reader latitude: String
40
+ attr_reader longitude: String
41
+ end
42
+
43
+ class City
44
+ def initialize: (code: String, prefecture_code: String, name: String, name_kana: String, name_romaji: String) -> void
45
+ def formatted_code: -> String
46
+ def attributes: -> {code: String, prefecture_code: String, name: String, name_kana: String, name_romaji: String}
47
+ def prefecture: -> Models::Prefecture?
48
+ def towns: -> Array[Models::Town]
49
+ attr_reader code: String
50
+ attr_reader prefecture_code: String
51
+ attr_reader name: String
52
+ attr_reader name_kana: String
53
+ attr_reader name_romaji: String
54
+ end
55
+
56
+ class Prefecture
57
+ def self.all: -> Array[Models::Prefecture]
58
+ def initialize: (code: String, name: String, name_kana: String, name_romaji: String) -> void
59
+ def attributes: -> {code: String, name: String, name_kana: String, name_romaji: String}
60
+ def cities: -> Array[Models::City]
61
+ attr_reader code: String
62
+ attr_reader name: String
63
+ attr_reader name_kana: String
64
+ attr_reader name_romaji: String
65
+ end
66
+ end
67
+
68
+ module CsvParser
69
+ HEADER_MAP: Hash[String, Symbol]
70
+
71
+ def self.call: -> Hash[untyped, untyped]
72
+ def self._find_or_build_prefecture: (Array[untyped] prefectures, untyped row) -> Models::Prefecture
73
+ def self._find_or_build_city: (Array[untyped] cities, Models::Prefecture current_prefecture, untyped row) -> Models::City
74
+ def self._find_town: (Array[untyped] towns, untyped row) -> nil
75
+ def self._build_town: (untyped row) -> Models::Town
76
+ def self._write_csv: (Hash[untyped, untyped] prefectures) -> Hash[untyped, untyped]
77
+ def self._write_prefectures_csv: (Array[untyped] prefectures) -> Array[untyped]
78
+ def self._write_cities_csv: (bot prefecture, untyped cities) -> untyped
79
+ def self._write_towns_csv: (untyped prefecture, untyped city, untyped towns) -> untyped
80
+ end
4
81
  end
@@ -0,0 +1,25 @@
1
+ module Schmooze
2
+ class Base
3
+ def self.dependencies: (untyped deps) -> untyped
4
+
5
+ def self.finalize: (untyped stdin, untyped stdout, untyped stderr, untyped process_thread) -> untyped
6
+
7
+ def self.method: (untyped name, untyped code) -> untyped
8
+
9
+ public
10
+
11
+ def pid: () -> untyped
12
+
13
+ private
14
+
15
+ def call_js_method: (untyped method, untyped args) -> untyped
16
+
17
+ def ensure_packages_are_initiated: (untyped stdin, untyped stdout, untyped stderr, untyped process_thread) -> untyped
18
+
19
+ def ensure_process_is_spawned: () -> untyped
20
+
21
+ def initialize: (untyped root, ?untyped env) -> void
22
+
23
+ def spawn_process: () -> untyped
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: japanese_address_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yamaguchi Takuya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-16 00:00:00.000000000 Z
11
+ date: 2022-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: schmooze
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "<"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '7'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "<"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '7'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: factory_bot
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,34 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: steep
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: typeprof
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  description: JapaneseAddressParser is a Ruby gem that parses Japanese address. To
126
154
  detect the address, it uses geolonia/japanese-addresses (https://github.com/geolonia/japanese-addresses)
127
155
  CSV data.
@@ -136,13 +164,16 @@ files:
136
164
  - ".rubocop_todo.yml"
137
165
  - CHANGELOG.md
138
166
  - CODE_OF_CONDUCT.md
167
+ - Dockerfile
139
168
  - Gemfile
140
169
  - Gemfile.lock
141
170
  - LICENSE.txt
142
171
  - README.md
143
172
  - Rakefile
173
+ - Steepfile
144
174
  - bin/console
145
175
  - bin/setup
176
+ - docker-compose.yml
146
177
  - japanese_address_parser.gemspec
147
178
  - js/.gitignore
148
179
  - js/node_modules/.package-lock.json
@@ -4101,6 +4132,7 @@ files:
4101
4132
  - lib/japanese_address_parser/models/town.rb
4102
4133
  - lib/japanese_address_parser/version.rb
4103
4134
  - sig/japanese_address_parser.rbs
4135
+ - sig/schmooze_base.rbs
4104
4136
  homepage: https://github.com/yamat47/japanese_address_parser
4105
4137
  licenses:
4106
4138
  - MIT
@@ -4117,7 +4149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
4117
4149
  requirements:
4118
4150
  - - ">="
4119
4151
  - !ruby/object:Gem::Version
4120
- version: 2.6.0
4152
+ version: 2.7.0
4121
4153
  required_rubygems_version: !ruby/object:Gem::Requirement
4122
4154
  requirements:
4123
4155
  - - ">="