jp_prefecture 1.1.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d18ddf910428b89314b870b8ee905cdca9c2609da53d2f58602bea071669c6d
4
- data.tar.gz: 03b7e5b6710129ac6d32deee505f9dac2116ae5362cf064f229395612f36a136
3
+ metadata.gz: be694d4725ff39c6ce23218d76bd061eb7a3d84ea07d1c59f646d20f90297d72
4
+ data.tar.gz: a82aa74c001b12b7becb27e59c59c708e416aa4d3d4d6a4ea974998dc6627f67
5
5
  SHA512:
6
- metadata.gz: e2c57e99f3270f05589c01a979eb3bb298f2413c680ba068fc1601785a69c992af7811c7122e2b7ab6426b5cd0daca3914dfd019ecaf74b7f1d86fe448d16337
7
- data.tar.gz: 65b92823bcc248b5a311cb18b2be545e38be6b4f619d0cad680ad3171b4b198c40f524effa4900cdbfcb889064e43dc05ae931fc548ebb05459c15283534c4f0
6
+ metadata.gz: aa29d152ffdfc4fb84e53067ff7b5841f4d96bad356edf74cc91a71afd93b161212fbf0c809f0ed0e4332c3376fc7b358091ece0fa20e7f3a83b45d87d972763
7
+ data.tar.gz: 54cfed45404672136b45280c9deb61f4076016593c10519b68c9e9fc1b6159a89ed073a01c2db969239c6dd0bad77d9a89a84dc54bd88f648e91f3535a7219aa
data/CHANGELOG.md CHANGED
@@ -1,130 +1,208 @@
1
- ## Unreleased
1
+ # Changelog
2
2
 
3
- ## 1.1.1 (2022-03-25)
3
+ ## [Unreleased]
4
4
 
5
- ### Bug fix
5
+ ## [1.2.0] - 2026-08-11
6
6
 
7
- * マッピングに項目が存在しない場合にエラーが発生する問題を修正 (PR [#59](https://github.com/chocoby/jp_prefecture/pull/59)/[@chocoby](https://github.com/chocoby))
7
+ ### Added
8
8
 
9
- ## 1.1.0 (2022-03-17)
9
+ - Rails 8.1 をサポートに追加 ([#78](https://github.com/chocoby/jp_prefecture/pull/78), [@chocoby](https://github.com/chocoby))
10
+ - Ruby 4.0 をサポートに追加 ([#80](https://github.com/chocoby/jp_prefecture/pull/80), [@chocoby](https://github.com/chocoby))
11
+ - 前方一致するすべての都道府県を返す `JpPrefecture::Prefecture.where` を追加 ([#90](https://github.com/chocoby/jp_prefecture/pull/90), [@chocoby](https://github.com/chocoby))
10
12
 
11
- ### Features
13
+ ### Changed
12
14
 
13
- * 都道府県情報にローマ字表記を追加 (PR [#57](https://github.com/chocoby/jp_prefecture/pull/57)/[@sondh5](https://github.com/sondh5))
14
- * Ruby 3.1 をサポートに追加 (PR [#54](https://github.com/chocoby/jp_prefecture/pull/54)/[@chocoby](https://github.com/chocoby))
15
- * Rails 7.0 をサポート (PR [#55](https://github.com/chocoby/jp_prefecture/pull/55)/[@chocoby](https://github.com/chocoby))
15
+ - RuboCop の `TargetRubyVersion` を RuboCop がサポートする Ruby 2.7 に変更 ([#75](https://github.com/chocoby/jp_prefecture/pull/75), [@chocoby](https://github.com/chocoby))
16
+ - Dependabot GitHub Actions を更新する ([#76](https://github.com/chocoby/jp_prefecture/pull/76), [@chocoby](https://github.com/chocoby))
17
+ - テストする Ruby/Rails の組み合わせを代表的なものに絞る ([#82](https://github.com/chocoby/jp_prefecture/pull/82), [@chocoby](https://github.com/chocoby))
18
+ - 郵便番号データを毎月更新するワークフローを追加 ([#85](https://github.com/chocoby/jp_prefecture/pull/85), [#93](https://github.com/chocoby/jp_prefecture/pull/93), [@chocoby](https://github.com/chocoby))
19
+ - リリース時に RubyGems へ gem を自動公開する ([#88](https://github.com/chocoby/jp_prefecture/pull/88), [@chocoby](https://github.com/chocoby))
20
+ - CHANGELOG を Keep a Changelog 形式に変更 ([#91](https://github.com/chocoby/jp_prefecture/pull/91), [@chocoby](https://github.com/chocoby))
21
+ - Pull Request テンプレートを追加 ([#92](https://github.com/chocoby/jp_prefecture/pull/92), [@chocoby](https://github.com/chocoby))
22
+ - 開発用の対話コンソール `bin/console` を追加し、CONTRIBUTING.md の開発手順を整備 ([#96](https://github.com/chocoby/jp_prefecture/pull/96), [@chocoby](https://github.com/chocoby))
23
+ - RuboCop の `.rubocop_todo.yml` を削除し、`rubocop-performance` と `rubocop-rake` を有効化 ([#97](https://github.com/chocoby/jp_prefecture/pull/97), [@chocoby](https://github.com/chocoby))
16
24
 
17
- ## 1.0.0 (2021-02-24)
25
+ ### Deprecated
18
26
 
19
- ### Misc
27
+ - `JpPrefecture::Prefecture.find` に対応していない引数を渡した場合に非推奨の警告を表示 ([#94](https://github.com/chocoby/jp_prefecture/pull/94), [@chocoby](https://github.com/chocoby))
20
28
 
21
- * 毎週月曜日の 09:00 (JST) にテストを実行する (PR [#52](https://github.com/chocoby/jp_prefecture/pull/52)/[@chocoby](https://github.com/chocoby))
29
+ 未知のフィールド名、複数キー、空の Hash、`nil` キーを渡した場合が対象です。v2.0.0 以降は `ArgumentError` を発生させる予定です。
22
30
 
23
- ## 1.0.0.rc1 (2021-02-10)
31
+ ### Fixed
24
32
 
25
- ### Breaking changes
33
+ - カスタムの `zip_mapping_data` で範囲検索が動作しない問題を修正 ([#83](https://github.com/chocoby/jp_prefecture/pull/83), [@chocoby](https://github.com/chocoby))
34
+ - `ken_all.zip` のダウンロード URL を修正/郵便番号データ更新 ([#84](https://github.com/chocoby/jp_prefecture/pull/84), [#86](https://github.com/chocoby/jp_prefecture/pull/86), [@chocoby](https://github.com/chocoby))
35
+ - 都道府県名の検索で String 以外の値を渡すとエラーになる問題を修正 ([#89](https://github.com/chocoby/jp_prefecture/pull/89), [@chocoby](https://github.com/chocoby))
26
36
 
27
- * Ruby 1.9.3 - 2.3/Rails 3.2 - 4.2 のサポートを終了 (PR [#39](https://github.com/chocoby/jp_prefecture/pull/39)/[@chocoby](https://github.com/chocoby))
37
+ ## [1.1.2] - 2025-02-24
28
38
 
29
- 古い Ruby/Rails のサポートを終了しました。今後も大きな不具合が見つかった場合、可能な限りは対応する予定です。
39
+ ### Added
30
40
 
31
- サポートするバージョンの範囲は Ruby/Rails のメンテナンスポリシーに則るのがシンプルですが、この Gem では厳しくする必要はないと考えています。
32
- Ruby/Rails のメンテナンスポリシーで決められているバージョンは最低限サポートし、実装やテストのメンテナンスが困難になったバージョンからサポートを終了する方針で検討しています。ご意見があればください。
41
+ - Ruby 3.2 をサポートに追加 ([#61](https://github.com/chocoby/jp_prefecture/pull/61), [@chocoby](https://github.com/chocoby))
42
+ - Rails 7.1 をサポートに追加 ([#63](https://github.com/chocoby/jp_prefecture/pull/63), [@chocoby](https://github.com/chocoby))
43
+ - Ruby 3.3 をサポートに追加 ([#64](https://github.com/chocoby/jp_prefecture/pull/64), [@chocoby](https://github.com/chocoby))
44
+ - Rails 7.2 をサポートに追加 ([#65](https://github.com/chocoby/jp_prefecture/pull/65), [@y-yagi](https://github.com/y-yagi))
45
+ - Ruby 3.4 をサポートに追加 ([#67](https://github.com/chocoby/jp_prefecture/pull/67), [@chocoby](https://github.com/chocoby))
46
+ - Rails 8.0 をサポートに追加 ([#68](https://github.com/chocoby/jp_prefecture/pull/68), [@chocoby](https://github.com/chocoby))
33
47
 
34
- * 文字列による検索は項目を指定して検索する (Issue [#24](https://github.com/chocoby/jp_prefecture/issues/24), [#27](https://github.com/chocoby/jp_prefecture/issues/27)/PR [#43](https://github.com/chocoby/jp_prefecture/pull/43)/[@chocoby](https://github.com/chocoby))
48
+ ### Changed
35
49
 
36
- `JpPrefecture::Prefecture.find(name: '東')` を実行すると、青森県が取得されていた問題への対応です。これはマッピングのすべての項目を検索していたためです。
37
- 対応として、`name` を指定した場合は漢字表記、`name_e` は英語表記など、指定した項目のみを検索するように変更しました。詳しい使い方は README を参照してください。
38
- 以前のように、すべての項目から検索したい場合は `JpPrefecture::Prefecture.find(all_fields: 'string')` を使用してください。
50
+ - 郵便番号データの更新 ([#74](https://github.com/chocoby/jp_prefecture/pull/74), [@chocoby](https://github.com/chocoby))
51
+ - 都道府県コードの参照先を `JIS X 0401` に修正 ([#71](https://github.com/chocoby/jp_prefecture/pull/71), [@ydah](https://github.com/ydah))
52
+ - RuboCop の警告を修正 ([#69](https://github.com/chocoby/jp_prefecture/pull/69), [@ydah](https://github.com/ydah))
53
+ - appraisal gem の依存を削除 ([#73](https://github.com/chocoby/jp_prefecture/pull/73), [@chocoby](https://github.com/chocoby))
54
+
55
+ ### Fixed
56
+
57
+ - `bundle exec rake create_zip_code_data` 実行時のランタイムエラーを修正/郵便番号データ更新 ([#70](https://github.com/chocoby/jp_prefecture/pull/70), [@ydah](https://github.com/ydah))
58
+ - concurrent-ruby gem v1.3.5 で `logger` の依存が削除されたことへの対応 ([#72](https://github.com/chocoby/jp_prefecture/pull/72), [@chocoby](https://github.com/chocoby))
59
+
60
+ ## [1.1.1] - 2022-03-25
61
+
62
+ ### Fixed
63
+
64
+ - マッピングに項目が存在しない場合にエラーが発生する問題を修正 ([#59](https://github.com/chocoby/jp_prefecture/pull/59), [@chocoby](https://github.com/chocoby))
65
+
66
+ ## [1.1.0] - 2022-03-17
67
+
68
+ ### Added
69
+
70
+ - 都道府県情報にローマ字表記を追加 ([#57](https://github.com/chocoby/jp_prefecture/pull/57), [@sondh5](https://github.com/sondh5))
71
+ - Ruby 3.1 をサポートに追加 ([#54](https://github.com/chocoby/jp_prefecture/pull/54), [@chocoby](https://github.com/chocoby))
72
+ - Rails 7.0 をサポート ([#55](https://github.com/chocoby/jp_prefecture/pull/55), [@chocoby](https://github.com/chocoby))
73
+
74
+ ## [1.0.0] - 2021-02-24
39
75
 
40
- ### Features
76
+ ### Changed
41
77
 
42
- * Ruby 3.0 をサポートに追加 (PR [#42](https://github.com/chocoby/jp_prefecture/pull/42)/[@chocoby](https://github.com/chocoby))
43
- * 郵便番号データを更新 (PR [#46](https://github.com/chocoby/jp_prefecture/pull/46)/[@chocoby](https://github.com/chocoby))
44
- * `JpPrefecture::Prefecture` クラスに都道府県コードから都道府県インスタンスを作成する `build_by_code` メソッドを追加 (PR [#44](https://github.com/chocoby/jp_prefecture/pull/44)/[@chocoby](https://github.com/chocoby))
78
+ - 毎週月曜日の 09:00 (JST) にテストを実行する ([#52](https://github.com/chocoby/jp_prefecture/pull/52), [@chocoby](https://github.com/chocoby))
79
+
80
+ ## [1.0.0.rc1] - 2021-02-10
81
+
82
+ ### Added
83
+
84
+ - Ruby 3.0 をサポートに追加 ([#42](https://github.com/chocoby/jp_prefecture/pull/42), [@chocoby](https://github.com/chocoby))
85
+ - `JpPrefecture::Prefecture` クラスに都道府県コードから都道府県インスタンスを作成する `build_by_code` メソッドを追加 ([#44](https://github.com/chocoby/jp_prefecture/pull/44), [@chocoby](https://github.com/chocoby))
45
86
 
46
87
  都道府県コードを指定すると、それに対応した都道府県の `JpPrefecture::Prefecture` インスタンスを取得するメソッドを追加しました。
47
88
  `JpPrefecture::Prefecture.build` メソッドは参照している処理がなくなったため、削除しました。
48
89
 
49
- ### Documentation
90
+ ### Changed
91
+
92
+ - 文字列による検索は項目を指定して検索する ([#43](https://github.com/chocoby/jp_prefecture/pull/43), [#24](https://github.com/chocoby/jp_prefecture/issues/24), [#27](https://github.com/chocoby/jp_prefecture/issues/27), [@chocoby](https://github.com/chocoby))
93
+
94
+ `JpPrefecture::Prefecture.find(name: '東')` を実行すると、青森県が取得されていた問題への対応です。これはマッピングのすべての項目を検索していたためです。
95
+ 対応として、`name` を指定した場合は漢字表記、`name_e` は英語表記など、指定した項目のみを検索するように変更しました。詳しい使い方は README を参照してください。
96
+ 以前のように、すべての項目から検索したい場合は `JpPrefecture::Prefecture.find(all_fields: 'string')` を使用してください。
97
+
98
+ - 郵便番号データを更新 ([#46](https://github.com/chocoby/jp_prefecture/pull/46), [@chocoby](https://github.com/chocoby))
99
+ - CONTRIBUTING.md を追加 ([#41](https://github.com/chocoby/jp_prefecture/pull/41), [@chocoby](https://github.com/chocoby))
100
+ - RuboCop を導入 ([#40](https://github.com/chocoby/jp_prefecture/pull/40), [@chocoby](https://github.com/chocoby))
101
+ - Gem に含めるファイルを最低限のものにする ([#48](https://github.com/chocoby/jp_prefecture/pull/48), [@chocoby](https://github.com/chocoby))
50
102
 
51
- * CONTRIBUTING.md を追加 (PR [#41](https://github.com/chocoby/jp_prefecture/pull/41)/[@chocoby](https://github.com/chocoby))
103
+ ### Removed
52
104
 
53
- ### Misc
105
+ - Ruby 1.9.3 - 2.3/Rails 3.2 - 4.2 のサポートを終了 ([#39](https://github.com/chocoby/jp_prefecture/pull/39), [@chocoby](https://github.com/chocoby))
106
+
107
+ 古い Ruby/Rails のサポートを終了しました。今後も大きな不具合が見つかった場合、可能な限りは対応する予定です。
108
+
109
+ サポートするバージョンの範囲は Ruby/Rails のメンテナンスポリシーに則るのがシンプルですが、この Gem では厳しくする必要はないと考えています。
110
+ Ruby/Rails のメンテナンスポリシーで決められているバージョンは最低限サポートし、実装やテストのメンテナンスが困難になったバージョンからサポートを終了する方針で検討しています。ご意見があればください。
54
111
 
55
- * RuboCop を導入 (PR [#40](https://github.com/chocoby/jp_prefecture/pull/40)/[@chocoby](https://github.com/chocoby))
56
- * Gem に含めるファイルを最低限のものにする (PR [#48](https://github.com/chocoby/jp_prefecture/pull/48)/[@chocoby](https://github.com/chocoby))
112
+ ## [0.11.0] - 2020-12-18
57
113
 
58
- ## 0.11.0 (2020-12-18)
114
+ - Rails 6.1 をサポート ([#37](https://github.com/chocoby/jp_prefecture/pull/37), [@chocoby](https://github.com/chocoby))
115
+ - GitHub Actions でビルドを実行するようにした ([#34](https://github.com/chocoby/jp_prefecture/pull/34), [@chocoby](https://github.com/chocoby))
59
116
 
60
- * Rails 6.1 をサポート (PR [#37](https://github.com/chocoby/jp_prefecture/pull/37)/[@chocoby](https://github.com/chocoby))
61
- * GitHub Actions でビルドを実行するようにした (PR [#34](https://github.com/chocoby/jp_prefecture/pull/34)/[@chocoby](https://github.com/chocoby))
117
+ ## [0.10.0] - 2019-08-19
62
118
 
63
- ## 0.10.0 (2019-08-19)
119
+ - Rails 6.0 をサポート ([#33](https://github.com/chocoby/jp_prefecture/pull/33), [@chocoby](https://github.com/chocoby))
64
120
 
65
- * Rails 6.0 をサポート (PR [#33](https://github.com/chocoby/jp_prefecture/pull/33)/[@chocoby](https://github.com/chocoby))
121
+ ## [0.9.0] - 2017-01-15
66
122
 
67
- ## 0.9.0 (2017-01-15)
123
+ - Add English Readme ([#22](https://github.com/chocoby/jp_prefecture/pull/22), [#21](https://github.com/chocoby/jp_prefecture/issues/21), [@PeterTeng](https://github.com/PeterTeng))
124
+ - 都道府県情報に種類を追加 ([#23](https://github.com/chocoby/jp_prefecture/pull/23), [@gazayas](https://github.com/gazayas))
68
125
 
69
- * Add English Readme (Issue [#21](https://github.com/chocoby/jp_prefecture/issues/21)/PR [#22](https://github.com/chocoby/jp_prefecture/pull/22)/[@PeterTeng](https://github.com/PeterTeng))
70
- * 都道府県情報に種類を追加 (PR [#23](https://github.com/chocoby/jp_prefecture/pull/23)/[@gazayas](https://github.com/gazayas))
126
+ ## [0.8.1] - 2016-03-30
71
127
 
72
- ## 0.8.1 (2016-03-30)
128
+ - `JpPrefecture::Prefecture.find(name: name)` に `nil` や空文字を渡した時に `nil` を返す ([#19](https://github.com/chocoby/jp_prefecture/pull/19), [#18](https://github.com/chocoby/jp_prefecture/issues/18), [@k-motoyan](https://github.com/k-motoyan))
73
129
 
74
- * `JpPrefecture::Prefecture.find(name: name)` に `nil` や空文字を渡した時に `nil` を返す (Issue [#18](https://github.com/chocoby/jp_prefecture/issues/18)/PR [#19](https://github.com/chocoby/jp_prefecture/pull/19)/[@k-motoyan](https://github.com/k-motoyan))
130
+ ## [0.8.0] - 2014-09-07
75
131
 
76
- ## 0.8.0 (2014-09-07)
132
+ - 都道府県情報に八地方区分情報を追加 ([#14](https://github.com/chocoby/jp_prefecture/pull/14), [@kkosuge](https://github.com/kkosuge))
77
133
 
78
- * 都道府県情報に八地方区分情報を追加 (PR [#14](https://github.com/chocoby/jp_prefecture/pull/14)/[@kkosuge](https://github.com/kkosuge))
134
+ ## [0.7.0] - 2014-06-18
79
135
 
80
- ## 0.7.0 (2014-06-18)
136
+ - 都道府県名にひらがな、カタカナを追加 ([#12](https://github.com/chocoby/jp_prefecture/pull/12), [@yukihr](https://github.com/yukihr))
81
137
 
82
- * 都道府県名にひらがな、カタカナを追加 (PR [#12](https://github.com/chocoby/jp_prefecture/pull/12)/[@yukihr](https://github.com/yukihr))
138
+ ## [0.6.0] - 2014-03-10
83
139
 
84
- ## 0.6.0 (2014-03-10)
140
+ - 都道府県名を前方一致で検索できるようにした ([#11](https://github.com/chocoby/jp_prefecture/pull/11), [@yuuna](https://github.com/yuuna))
141
+ - 都道府県名の検索ロジックを高速化
85
142
 
86
- * 都道府県名を前方一致で検索できるようにした (PR [#11](https://github.com/chocoby/jp_prefecture/pull/11)/[@yuuna](https://github.com/yuuna))
87
- * 都道府県名の検索ロジックを高速化
143
+ ## [0.5.0] - 2013-11-30
88
144
 
89
- ## 0.5.0 (2013-11-30)
145
+ - 郵便番号から都道府県を検索する機能の追加 ([#9](https://github.com/chocoby/jp_prefecture/pull/9), [@fruwe](https://github.com/fruwe))
90
146
 
91
- * 郵便番号から都道府県を検索する機能の追加 (PR [#9](https://github.com/chocoby/jp_prefecture/pull/9)/[@fruwe](https://github.com/fruwe))
147
+ ## [0.4.0] - 2013-07-08
92
148
 
93
- ## 0.4.0 (2013-07-08)
149
+ - 都道府県のマッピングを変更する機能の追加 ([#8](https://github.com/chocoby/jp_prefecture/pull/8), [@mizoR](https://github.com/mizoR))
94
150
 
95
- * 都道府県のマッピングを変更する機能の追加 (PR [#8](https://github.com/chocoby/jp_prefecture/pull/8)/[@mizoR](https://github.com/mizoR))
151
+ ## [0.3.2] - 2013-06-12
96
152
 
97
- ## 0.3.2 (2013-06-12)
153
+ - 文字列を downcase してから都道府県の検索を行うようにした
98
154
 
99
- * 文字列を downcase してから都道府県の検索を行うようにした
155
+ ## [0.3.1] - 2013-06-11
100
156
 
101
- ## 0.3.1 (2013-06-11)
157
+ - name で渡した文字列が変更されるバグを修正
102
158
 
103
- * name で渡した文字列が変更されるバグを修正
159
+ ## [0.3.0] - 2013-06-11
104
160
 
105
- ## 0.3.0 (2013-06-11)
161
+ - 都道府県名(英語表記含む)から都道府県を検索できるようにした
162
+ - 都道府県名からの検索と同様の方法で、都道府県コードを検索できるようにした
163
+ - String 型の都道府県コードに対応
106
164
 
107
- * 都道府県名(英語表記含む)から都道府県を検索できるようにした
108
- * 都道府県名からの検索と同様の方法で、都道府県コードを検索できるようにした
109
- * String 型の都道府県コードに対応
165
+ ## [0.2.0] - 2013-06-09
110
166
 
111
- ## 0.2.0 (2013-06-09)
167
+ - 英語表記を追加
168
+ - Ruby 1.8.7 のサポートを終了
112
169
 
113
- * 英語表記を追加
114
- * Ruby 1.8.7 のサポートを終了
170
+ ## [0.1.1] - 2013-03-01
115
171
 
116
- ## 0.1.1 (2013-03-01)
172
+ - モデルで使用する時に、生成するメソッド名を指定できるようにした
173
+ - Configuration モデル/Model モジュールを廃止
174
+ - extend による使用を廃止
175
+ - Travis CI によるテストを行うようにした
117
176
 
118
- * モデルで使用する時に、生成するメソッド名を指定できるようにした
119
- * Configuration モデル/Model モジュールを廃止
120
- * extend による使用を廃止
121
- * Travis CI によるテストを行うようにした
177
+ ## [0.1.0] - 2013-02-17
122
178
 
123
- ## 0.1.0 (2013-02-17)
179
+ - モデルで使用する時に、対象のカラム名を指定するようにした
124
180
 
125
- * モデルで使用する時に、対象のカラム名を指定するようにした
181
+ ## [0.0.1] - 2013-02-14
126
182
 
127
- ## 0.0.1 (2013-02-14)
183
+ - 都道府県の変換
184
+ - 簡単な Rails サポート
128
185
 
129
- * 都道府県の変換
130
- * 簡単な Rails サポート
186
+ [Unreleased]: https://github.com/chocoby/jp_prefecture/compare/v1.2.0...HEAD
187
+ [1.2.0]: https://github.com/chocoby/jp_prefecture/compare/v1.1.2...v1.2.0
188
+ [1.1.2]: https://github.com/chocoby/jp_prefecture/compare/v1.1.1...v1.1.2
189
+ [1.1.1]: https://github.com/chocoby/jp_prefecture/compare/v1.1.0...v1.1.1
190
+ [1.1.0]: https://github.com/chocoby/jp_prefecture/compare/v1.0.0...v1.1.0
191
+ [1.0.0]: https://github.com/chocoby/jp_prefecture/compare/v1.0.0.rc1...v1.0.0
192
+ [1.0.0.rc1]: https://github.com/chocoby/jp_prefecture/compare/v0.11.0...v1.0.0.rc1
193
+ [0.11.0]: https://github.com/chocoby/jp_prefecture/compare/v0.10.0...v0.11.0
194
+ [0.10.0]: https://github.com/chocoby/jp_prefecture/compare/v0.9.0...v0.10.0
195
+ [0.9.0]: https://github.com/chocoby/jp_prefecture/compare/v0.8.1...v0.9.0
196
+ [0.8.1]: https://github.com/chocoby/jp_prefecture/compare/v0.8.0...v0.8.1
197
+ [0.8.0]: https://github.com/chocoby/jp_prefecture/compare/v0.7.0...v0.8.0
198
+ [0.7.0]: https://github.com/chocoby/jp_prefecture/compare/v0.6.0...v0.7.0
199
+ [0.6.0]: https://github.com/chocoby/jp_prefecture/compare/v0.5.0...v0.6.0
200
+ [0.5.0]: https://github.com/chocoby/jp_prefecture/compare/v0.4.0...v0.5.0
201
+ [0.4.0]: https://github.com/chocoby/jp_prefecture/compare/v0.3.2...v0.4.0
202
+ [0.3.2]: https://github.com/chocoby/jp_prefecture/compare/v0.3.1...v0.3.2
203
+ [0.3.1]: https://github.com/chocoby/jp_prefecture/compare/v0.3.0...v0.3.1
204
+ [0.3.0]: https://github.com/chocoby/jp_prefecture/compare/v0.2.0...v0.3.0
205
+ [0.2.0]: https://github.com/chocoby/jp_prefecture/compare/v0.1.1...v0.2.0
206
+ [0.1.1]: https://github.com/chocoby/jp_prefecture/compare/v0.1.0...v0.1.1
207
+ [0.1.0]: https://github.com/chocoby/jp_prefecture/compare/v0.0.1...v0.1.0
208
+ [0.0.1]: https://github.com/chocoby/jp_prefecture/releases/tag/v0.0.1
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [**English**](README_EN.md)
4
4
 
5
5
  [![Gem Version](http://img.shields.io/gem/v/jp_prefecture.svg?style=flat)](https://rubygems.org/gems/jp_prefecture)
6
- [![GitHub Actions](https://github.com/chocoby/jp_prefecture/workflows/Build/badge.svg)](https://github.com/chocoby/jp_prefecture)
6
+ [![GitHub Actions](https://github.com/chocoby/jp_prefecture/workflows/Build/badge.svg)](https://github.com/chocoby/jp_prefecture/actions)
7
7
  [![Coveralls](https://img.shields.io/coveralls/chocoby/jp_prefecture.svg)](https://coveralls.io/r/chocoby/jp_prefecture)
8
8
 
9
9
  https://rubygems.org/gems/jp_prefecture
@@ -12,7 +12,7 @@ https://rubygems.org/gems/jp_prefecture
12
12
 
13
13
  都道府県コードと都道府県名を変換するライブラリです。
14
14
 
15
- JIS X 0402 で定義されている都道府県コードをベースに、
15
+ JIS X 0401 で定義されている都道府県コードをベースに、
16
16
  ゼロから始まるものはゼロを削除して使用しています。
17
17
 
18
18
  ```
@@ -27,7 +27,6 @@ JIS X 0402 で定義されている都道府県コードをベースに、
27
27
 
28
28
  また、Rails のプラグインとして使用することもできます。
29
29
 
30
-
31
30
  ## 使い方
32
31
 
33
32
  ### ライブラリの読み込み
@@ -69,6 +68,8 @@ JpPrefecture::Prefecture.find(code: 13)
69
68
 
70
69
  ### 都道府県を検索
71
70
 
71
+ `find` は複数の都道府県に一致する場合、都道府県コード順で最初の 1 件を返します。
72
+
72
73
  前方一致で都道府県を検索します:
73
74
 
74
75
  ```ruby
@@ -97,6 +98,20 @@ JpPrefecture::Prefecture.find(name_k: "トウキョウト")
97
98
  JpPrefecture::Prefecture.find(all_fields: "東京")
98
99
  ```
99
100
 
101
+ `find` で検索できる項目は `name` / `name_e` / `name_r` / `name_h` / `name_k` / `code` / `zip` / `all_fields` です。対応していない項目を指定した場合、または項目がちょうど 1 つでない場合は非推奨の警告を出力します。jp_prefecture 2.0.0 では `ArgumentError` が発生する予定です。
102
+
103
+ 一致したすべての都道府県が必要な場合は `where` を使用します:
104
+
105
+ ```ruby
106
+ JpPrefecture::Prefecture.where(name: "山")
107
+ # => [山形県, 山梨県, 山口県]
108
+
109
+ JpPrefecture::Prefecture.where(name_e: "o")
110
+ # => [大阪府, 岡山県, 大分県, 沖縄県]
111
+ ```
112
+
113
+ `where` で検索できる項目は `name` / `name_e` / `name_r` / `name_h` / `name_k` です。対応していない項目を指定した場合は `ArgumentError` が発生します。
114
+
100
115
  ### 都道府県の一覧を取得
101
116
 
102
117
  ```ruby
@@ -192,7 +207,6 @@ end
192
207
 
193
208
  データのフォーマットについては [zip.yml](https://github.com/chocoby/jp_prefecture/blob/main/data/zip.yml) を参考にしてください。
194
209
 
195
-
196
210
  ## インストール
197
211
 
198
212
  以下の行を `Gemfile` に記述してから:
@@ -209,15 +223,14 @@ gem 'jp_prefecture'
209
223
  $ gem install jp_prefecture
210
224
  ```
211
225
 
212
-
213
226
  ## ドキュメント
214
227
 
215
- [http://rdoc.info/github/chocoby/jp_prefecture/main/frames/index](http://rdoc.info/github/chocoby/jp_prefecture/main/frames/index)
228
+ [https://rubydoc.info/gems/jp_prefecture](https://rubydoc.info/gems/jp_prefecture)
216
229
 
217
230
  ## サポートしているバージョン
218
231
 
219
- * Ruby: 2.4 - 3.1
220
- * Rails: 5.0 - 7.0
232
+ - Ruby: 2.4 - 4.0
233
+ - Rails: 5.0 - 8.1
221
234
 
222
235
  これより古い Ruby/Rails バージョンを使用する場合は、[`v0.11.0`](https://github.com/chocoby/jp_prefecture/tree/0.x) を利用してください。
223
236
 
data/README_EN.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [**Japanese**](README.md)
4
4
 
5
5
  [![Gem Version](http://img.shields.io/gem/v/jp_prefecture.svg?style=flat)](https://rubygems.org/gems/jp_prefecture)
6
- [![GitHub Actions](https://github.com/chocoby/jp_prefecture/workflows/Build/badge.svg)](https://github.com/chocoby/jp_prefecture)
6
+ [![GitHub Actions](https://github.com/chocoby/jp_prefecture/workflows/Build/badge.svg)](https://github.com/chocoby/jp_prefecture/actions)
7
7
  [![Coveralls](https://img.shields.io/coveralls/chocoby/jp_prefecture.svg)](https://coveralls.io/r/chocoby/jp_prefecture)
8
8
 
9
9
  https://rubygems.org/gems/jp_prefecture
@@ -12,7 +12,7 @@ https://rubygems.org/gems/jp_prefecture
12
12
 
13
13
  Convert prefecture code to prefecture name in Japan.
14
14
 
15
- Based on JIS X 0402. Remove 0 when prefecture code start with 0.
15
+ Based on JIS X 0401. Remove 0 when prefecture code start with 0.
16
16
 
17
17
  ```
18
18
  Hokkaido: 01 -> 1
@@ -66,6 +66,8 @@ JpPrefecture::Prefecture.find(code: 13)
66
66
 
67
67
  ### Search by Prefecture Name
68
68
 
69
+ `find` returns the first match in prefecture code order when multiple prefectures match.
70
+
69
71
  Search for a prefecture by forward match.
70
72
 
71
73
  ```ruby
@@ -94,6 +96,20 @@ Search all items in the mapping (not recommended).
94
96
  JpPrefecture::Prefecture.find(all_fields: "東京")
95
97
  ```
96
98
 
99
+ `find` supports `name` / `name_e` / `name_r` / `name_h` / `name_k` / `code` / `zip` / `all_fields`. Specifying any other item, or specifying a Hash that does not have exactly one key, prints a deprecation warning. It will raise `ArgumentError` in jp_prefecture 2.0.0.
100
+
101
+ Use `where` when you need all matching prefectures.
102
+
103
+ ```ruby
104
+ JpPrefecture::Prefecture.where(name: "山")
105
+ # => [山形県, 山梨県, 山口県]
106
+
107
+ JpPrefecture::Prefecture.where(name_e: "o")
108
+ # => [大阪府, 岡山県, 大分県, 沖縄県]
109
+ ```
110
+
111
+ `where` supports `name` / `name_e` / `name_r` / `name_h` / `name_k`. Specifying any other item raises `ArgumentError`.
112
+
97
113
  ### All Prefectures
98
114
 
99
115
  ```ruby
@@ -191,7 +207,6 @@ end
191
207
 
192
208
  Check out [zip.yml](https://github.com/chocoby/jp_prefecture/blob/main/data/zip.yml) for data format.
193
209
 
194
-
195
210
  ## Installation
196
211
 
197
212
  Add this line in Gemfile.
@@ -212,15 +227,14 @@ Or install gem with `gem install`
212
227
  $ gem install jp_prefecture
213
228
  ```
214
229
 
215
-
216
230
  ## Documentation
217
231
 
218
- [http://rdoc.info/github/chocoby/jp_prefecture/main/frames/index](http://rdoc.info/github/chocoby/jp_prefecture/main/frames/index)
232
+ [https://rubydoc.info/gems/jp_prefecture](https://rubydoc.info/gems/jp_prefecture)
219
233
 
220
234
  ## Supported versions
221
235
 
222
- * Ruby: 2.4 - 3.1
223
- * Rails: 5.0 - 7.0
236
+ - Ruby: 2.4 - 4.0
237
+ - Rails: 5.0 - 8.1
224
238
 
225
239
  If you are using an older Ruby/Rails version, please use [`v0.11.0`](https://github.com/chocoby/jp_prefecture/tree/0.x).
226
240
 
data/data/prefecture.yml CHANGED
@@ -1,5 +1,6 @@
1
- # JIS X 0402 で定義されている都道府県コードと都道府県名をベースに
1
+ # JIS X 0401 で定義されている都道府県コードと都道府県名をベースに
2
2
  # コードがゼロから始まるもの(09 など)を 1 ケタにしたもの
3
+ # https://www.jisc.go.jp/app/jis/general/GnrJISNumberNameSearchList?show&jisStdNo=X0401
3
4
  ---
4
5
  1:
5
6
  :name: 北海道
data/data/zip.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  # { prefecture_code: [[from_zip_1, to_zip_1], [from_zip_2, to_zip_2], ...], ... }
2
- # Last updated: 2022-03-07 01:11:32 UTC
2
+ # Last updated: 2026-07-22 09:48:04 UTC
3
3
  ---
4
4
  1:
5
5
  - - 10000
@@ -136,8 +136,6 @@
136
136
  - - 5200461
137
137
  - 5200465
138
138
  - - 6000000
139
- - 6170857
140
- - - 6180000
141
139
  - 6180000
142
140
  - - 6180071
143
141
  - 6293579
@@ -147,8 +145,6 @@
147
145
  - - 5640000
148
146
  - 5998276
149
147
  - - 6180000
150
- - 6180000
151
- - - 6180001
152
148
  - 6180024
153
149
  - - 6300271
154
150
  - 6300272
@@ -240,8 +236,8 @@
240
236
  - - 8391421
241
237
  - 8391421
242
238
  - - 8700001
243
- - 8710000
244
- - - 8710001
239
+ - 8701223
240
+ - - 8710000
245
241
  - 8710208
246
242
  - - 8710311
247
243
  - 8710716
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JpPrefecture
4
+ # モデルに変換メソッドを追加する
4
5
  module Base
5
6
  # モデル内で使用するための設定を行う
6
7
  #
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JpPrefecture
4
+ # 都道府県情報の設定
4
5
  class Config
5
6
  attr_accessor :mapping_data, :zip_mapping_data
6
7
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JpPrefecture
4
+ # 非推奨機能の告知
5
+ module Deprecation
6
+ PREFIX = '[jp_prefecture] DEPRECATION WARNING:'
7
+
8
+ # 非推奨の警告を標準エラー出力に出す
9
+ #
10
+ # Kernel#warn は $VERBOSE が nil のとき (ruby -W0, RUBYOPT=-W0) 何も出力しない。
11
+ # 破壊的変更の告知が届かなくなるため $stderr へ直接書き出す
12
+ #
13
+ # @param message [String] 警告の本文
14
+ # @return [void]
15
+ def self.warn(message)
16
+ $stderr.puts "#{PREFIX} #{message}" # rubocop:disable Style/StderrPuts
17
+ end
18
+ end
19
+ end
@@ -7,6 +7,12 @@ module JpPrefecture
7
7
  class Prefecture
8
8
  # 都道府県の検索を行うクラス
9
9
  class Finder
10
+ # 名前を前方一致で検索できる項目
11
+ NAME_FIELDS = %i[name name_e name_r name_h name_k].freeze
12
+
13
+ # find で検索できる項目
14
+ FIELDS = (NAME_FIELDS + %i[code zip all_fields]).freeze
15
+
10
16
  def initialize
11
17
  @mapping = Mapping.data
12
18
  end
@@ -22,20 +28,35 @@ module JpPrefecture
22
28
  JpPrefecture::Prefecture.build_by_code(code)
23
29
  end
24
30
 
31
+ # 指定した項目を前方一致で検索し、一致したすべての都道府県を返す
32
+ #
33
+ # @param field [Symbol] 検索する項目。NAME_FIELDS 以外を指定した場合は空配列
34
+ # @param value [String] 検索する内容
35
+ # @return [Array<JpPrefecture::Prefecture>] 一致した都道府県インスタンスの配列 (コード順)
36
+ def where(field:, value:)
37
+ return [] unless NAME_FIELDS.include?(field)
38
+
39
+ value = value.to_s.downcase
40
+ return [] if value.empty?
41
+
42
+ @mapping.select { |_code, names| names[field].start_with?(value) }
43
+ .map { |code, _names| JpPrefecture::Prefecture.build_by_code(code) }
44
+ end
45
+
25
46
  private
26
47
 
27
48
  # @param field [Symbol] 検索する項目
28
49
  # @param value [String, Integer] 検索する内容
29
50
  # @return [Integer] 見つかった場合は都道府県コード
30
51
  # @return [nil] 見つからない場合は nil
31
- def find_code(field, value)
52
+ def find_code(field, value) # rubocop:disable Metrics/MethodLength
32
53
  return value.to_i if field.nil?
33
54
 
34
55
  case field
35
56
  when :all_fields
36
- find_code_by_name_from_all_fields(value)
37
- when :name, :name_h, :name_k, :name_e, :name_r
38
- find_code_by_name(field, value)
57
+ find_code_by_name_from_all_fields(value.to_s)
58
+ when *NAME_FIELDS
59
+ find_code_by_name(field, value.to_s)
39
60
  when :code
40
61
  value.to_i
41
62
  when :zip
@@ -45,9 +66,8 @@ module JpPrefecture
45
66
 
46
67
  # すべての項目を前方一致で検索
47
68
  def find_code_by_name_from_all_fields(value)
48
- return if value.nil? || value.empty?
49
-
50
69
  value = value.downcase
70
+ return if value.empty?
51
71
 
52
72
  @mapping.each do |m|
53
73
  m[1].each_value do |v|
@@ -58,9 +78,8 @@ module JpPrefecture
58
78
 
59
79
  # 指定した項目を前方一致で検索
60
80
  def find_code_by_name(field, value)
61
- return if value.nil? || value.empty?
62
-
63
81
  value = value.downcase
82
+ return if value.empty?
64
83
 
65
84
  @mapping.each do |m|
66
85
  return m[0] if m[1][field].start_with?(value)
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'jp_prefecture/deprecation'
3
4
  require 'jp_prefecture/prefecture/finder'
4
5
  require 'jp_prefecture/mapping'
5
6
  require 'jp_prefecture/zip_mapping'
@@ -9,6 +10,10 @@ module JpPrefecture
9
10
  class Prefecture
10
11
  attr_accessor :code, :name, :name_e, :name_r, :name_h, :name_k, :zips, :area, :type
11
12
 
13
+ # 非推奨の警告の末尾に付ける、例外化の予告文
14
+ DEPRECATION_SUFFIX = 'This will raise ArgumentError in jp_prefecture 2.0.0.'
15
+ private_constant :DEPRECATION_SUFFIX
16
+
12
17
  # 都道府県コードから都道府県インスタンスを作成
13
18
  #
14
19
  # @example
@@ -18,7 +23,7 @@ module JpPrefecture
18
23
  # @param code [Integer] 都道府県コード
19
24
  # @return [JpPrefecture::Prefecture] 都道府県インスタンス
20
25
  # @return [nil] 都道府県が見つからない場合は nil
21
- def self.build_by_code(code) # rubocop:disable Metrics/AbcSize
26
+ def self.build_by_code(code) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
22
27
  result = Mapping.data[code]
23
28
  return unless result
24
29
 
@@ -26,14 +31,14 @@ module JpPrefecture
26
31
 
27
32
  pref.code = code
28
33
  pref.name = result[:name]
29
- pref.name_e = result[:name_e].try(:capitalize)
30
- pref.name_r = result[:name_r].try(:capitalize)
34
+ pref.name_e = result[:name_e]&.capitalize
35
+ pref.name_r = result[:name_r]&.capitalize
31
36
  pref.name_h = result[:name_h]
32
37
  pref.name_k = result[:name_k]
33
38
  pref.zips = ZipMapping.data[code]
34
39
  pref.area = result[:area]
35
40
  pref.type =
36
- case pref.name.try(:slice, -1)
41
+ case pref.name&.slice(-1)
37
42
  when '都', '道', '府', '県'
38
43
  pref.name[-1]
39
44
  end
@@ -62,6 +67,12 @@ module JpPrefecture
62
67
  #
63
68
  # 文字列は前方一致で検索する
64
69
  #
70
+ # 複数の都道府県に一致する場合は、都道府県コード順で最初の 1 件を返す。
71
+ # 一致したすべての都道府県が必要な場合は {.where} を使用する
72
+ #
73
+ # 対応していない項目を指定した場合、または項目がちょうど 1 つでない場合は非推奨の警告を出力する。
74
+ # jp_prefecture 2.0.0 では ArgumentError になる予定
75
+ #
65
76
  # @example
66
77
  # # 都道府県コードを検索
67
78
  # JpPrefecture::Prefecture.find(1)
@@ -92,7 +103,7 @@ module JpPrefecture
92
103
  # @param args [Hash<Symbol, Integer>] :code 都道府県コード
93
104
  # @param args [Hash<Symbol, String>] :name 漢字表記/:name_e 英語表記/:name_r ローマ字表記/:name_h ひらがな表記/:name_k カタカナ表記
94
105
  # @param args [Hash<Symbol, Integer>] :zip 郵便番号
95
- # @param args [Hash<Symbol, (String, Integer)>] :all_fields マッピングに定義しているすべてのフィールドから検索
106
+ # @param args [Hash<Symbol, String>] :all_fields マッピングに定義しているすべてのフィールドから検索
96
107
  # @return [JpPrefecture::Prefecture] 都道府県が見つかった場合は都道府県インスタンス
97
108
  # @return [nil] 都道府県が見つからない場合は nil
98
109
  def self.find(args)
@@ -102,11 +113,78 @@ module JpPrefecture
102
113
  when Integer, String
103
114
  JpPrefecture::Prefecture::Finder.new.find(field: nil, value: args)
104
115
  when Hash
116
+ warn_unsupported_args(args)
117
+
105
118
  search_field = args.keys.first
106
119
  search_value = args.values.first
107
120
 
108
121
  JpPrefecture::Prefecture::Finder.new.find(field: search_field, value: search_value)
109
122
  end
110
123
  end
124
+
125
+ # 都道府県を検索し、一致したすべての都道府県を返す
126
+ #
127
+ # 文字列は前方一致で検索する
128
+ #
129
+ # @example
130
+ # # 複数の都道府県に一致する検索
131
+ # JpPrefecture::Prefecture.where(name: '山')
132
+ # # => [山形県, 山梨県, 山口県]
133
+ #
134
+ # # 英語表記で検索
135
+ # JpPrefecture::Prefecture.where(name_e: 'o')
136
+ # # => [大阪府, 岡山県, 大分県, 沖縄県]
137
+ #
138
+ # @param args [Hash<Symbol, String>] :name 漢字表記/:name_e 英語表記/:name_r ローマ字表記/:name_h ひらがな表記/:name_k カタカナ表記
139
+ # @return [Array<JpPrefecture::Prefecture>] 一致した都道府県インスタンスの配列 (コード順)。一致しない場合は空配列
140
+ # @raise [ArgumentError] 対応していない項目、または項目が 1 つでない場合
141
+ def self.where(args)
142
+ unless args.is_a?(Hash) && args.size == 1
143
+ raise ArgumentError, "expected a Hash with exactly one key, got: #{inspect_args(args)}"
144
+ end
145
+
146
+ field, value = args.first
147
+
148
+ unless Finder::NAME_FIELDS.include?(field)
149
+ raise ArgumentError, "unsupported field: #{field.inspect} (supported: #{Finder::NAME_FIELDS.join(', ')})"
150
+ end
151
+
152
+ JpPrefecture::Prefecture::Finder.new.where(field: field, value: value)
153
+ end
154
+
155
+ # find に対応していない引数が渡された場合に非推奨の警告を出力する
156
+ #
157
+ # 空の Hash は「項目が 1 つでない」と「対応していない項目 (nil)」の両方に該当するため、
158
+ # 警告が二重に出ないよう elsif で判定する
159
+ #
160
+ # @param args [Hash] find に渡された引数
161
+ # @return [void]
162
+ def self.warn_unsupported_args(args) # rubocop:disable Metrics/MethodLength
163
+ field = args.keys.first
164
+
165
+ message =
166
+ if args.size != 1
167
+ "expected a Hash with exactly one key, got: #{inspect_args(args)}"
168
+ elsif field.nil?
169
+ 'the nil key is deprecated; use find(code) or find(code: code) instead'
170
+ elsif !Finder::FIELDS.include?(field)
171
+ "unsupported field: #{field.inspect} (supported: #{Finder::FIELDS.join(', ')})"
172
+ end
173
+ return unless message
174
+
175
+ Deprecation.warn("#{message}. #{DEPRECATION_SUFFIX}")
176
+ end
177
+ private_class_method :warn_unsupported_args
178
+
179
+ # メッセージに埋め込む引数の表現を返す
180
+ #
181
+ # 値には利用者の入力が入りうるため、Hash はキーだけを、それ以外は型名を出す
182
+ #
183
+ # @param args [Object] find / where に渡された引数
184
+ # @return [String] Hash ならキーの配列の inspect、それ以外はクラス名
185
+ def self.inspect_args(args)
186
+ args.is_a?(Hash) ? args.keys.inspect : args.class.to_s
187
+ end
188
+ private_class_method :inspect_args
111
189
  end
112
190
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JpPrefecture
4
- VERSION = '1.1.1'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -5,12 +5,21 @@ require 'yaml'
5
5
  module JpPrefecture
6
6
  # コードと郵便番号のマッピング
7
7
  module ZipMapping
8
+ # [from, to] のペア配列を Range へ変換する
9
+ def self.convert_to_ranges(data)
10
+ data.transform_values do |pairs|
11
+ pairs.collect { |zip_from, zip_to| zip_from..zip_to }
12
+ end
13
+ end
14
+
15
+ private_class_method :convert_to_ranges
16
+
8
17
  filepath = File.join(File.dirname(__FILE__), '../../data/zip.yml')
9
- @data = YAML.load_file(filepath)
10
- @data = Hash[*@data.collect { |code, arr| [code, arr.collect { |zip_from, zip_to| zip_from..zip_to }] }.flatten(1)]
18
+ @data = convert_to_ranges(YAML.load_file(filepath))
11
19
 
12
20
  def self.data
13
- JpPrefecture.config.zip_mapping_data || @data
21
+ raw = JpPrefecture.config.zip_mapping_data
22
+ raw ? convert_to_ranges(raw) : @data
14
23
  end
15
24
 
16
25
  def self.code_for_zip(zip)
data/lib/jp_prefecture.rb CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  require 'jp_prefecture/base'
4
4
  require 'jp_prefecture/config'
5
+ require 'jp_prefecture/deprecation'
5
6
  require 'jp_prefecture/prefecture'
6
7
  require 'jp_prefecture/version'
7
8
 
9
+ # Gem のエントリポイント
8
10
  module JpPrefecture
9
11
  @config = Config.new
10
12
 
metadata CHANGED
@@ -1,170 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jp_prefecture
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chocoby
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-03-25 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activerecord
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 5.0.0
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 5.0.0
27
- - !ruby/object:Gem::Dependency
28
- name: appraisal
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-performance
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-rake
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop-rspec
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: simplecov
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: simplecov-lcov
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'
153
- - !ruby/object:Gem::Dependency
154
- name: sqlite3
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- description: Convert japan prefecture code (JIS X 0402 based) into prefecture name.
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Convert japan prefecture code (JIS X 0401 based) into prefecture name.
168
13
  email:
169
14
  - chocoby@himajin.dev
170
15
  executables: []
@@ -180,6 +25,7 @@ files:
180
25
  - lib/jp_prefecture.rb
181
26
  - lib/jp_prefecture/base.rb
182
27
  - lib/jp_prefecture/config.rb
28
+ - lib/jp_prefecture/deprecation.rb
183
29
  - lib/jp_prefecture/mapping.rb
184
30
  - lib/jp_prefecture/prefecture.rb
185
31
  - lib/jp_prefecture/prefecture/finder.rb
@@ -190,7 +36,6 @@ licenses:
190
36
  - MIT
191
37
  metadata:
192
38
  rubygems_mfa_required: 'true'
193
- post_install_message:
194
39
  rdoc_options: []
195
40
  require_paths:
196
41
  - lib
@@ -205,8 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
50
  - !ruby/object:Gem::Version
206
51
  version: '0'
207
52
  requirements: []
208
- rubygems_version: 3.2.32
209
- signing_key:
53
+ rubygems_version: 4.0.16
210
54
  specification_version: 4
211
55
  summary: Convert japan prefecture code into prefecture name
212
56
  test_files: []