jp_prefecture 0.11.0 → 1.0.0.rc1

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: c16ea4e0cdab390ac0f2e7ce37db364d1e9d7dbb7c9cb1ccdb80aa9dc0da4e62
4
- data.tar.gz: 566e0820a0aef1caa58dc22ef002a72f44f9b96f1457448ea9721c96717cf076
3
+ metadata.gz: 217106ade0af0e82af7aaedf8f8a102b0bc543f990377f67726c7d41eebcd019
4
+ data.tar.gz: a575cc752f1e40f38f241e88b98d53ce85d95878333aee142ea8882be9834f77
5
5
  SHA512:
6
- metadata.gz: 148c89e504aa745015e8eeaed0460be88bc4d23094a98a248d739cb67bceeeaaa5c971cd74d902565b4d8c2c6b636066479c725936e7454b30cb8b0cff81b2f2
7
- data.tar.gz: a9408dcea7c0ec9725719c510b594c21d14bf85eb74f57c9dfbc252dda724163133c07dd43aee44df2907f4c01e944d57261fedca489ecb825ff1c9a40edf851
6
+ metadata.gz: babe85ea6e8e46444036676f877b5f584ef66f4723c328267512fc4b34f1819345e2191f11efe903336bf3c27a4fe9f852b86f7faf5519cc24b420c081a9605a
7
+ data.tar.gz: 62deb95e0a7c18a8b6120e1faf17627aef3021fb1930d8e3e0e09e075f184f7df7d33fa00c59213625a08db656c15e302a307928e8562abf96c58e83db5b4949
data/CHANGELOG.md CHANGED
@@ -1,75 +1,112 @@
1
1
  ## Unreleased
2
2
 
3
- ## 0.11.0 (Dec 18, 2020)
3
+ ## 1.0.0.rc1 (2021-02-10)
4
+
5
+ ### Breaking changes
6
+
7
+ * 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))
8
+
9
+ 古い Ruby/Rails のサポートを終了しました。今後も大きな不具合が見つかった場合、可能な限りは対応する予定です。
10
+
11
+ サポートするバージョンの範囲は Ruby/Rails のメンテナンスポリシーに則るのがシンプルですが、この Gem では厳しくする必要はないと考えています。
12
+ Ruby/Rails のメンテナンスポリシーで決められているバージョンは最低限サポートし、実装やテストのメンテナンスが困難になったバージョンからサポートを終了する方針で検討しています。ご意見があればください。
13
+
14
+ ### Features
15
+
16
+ * Ruby 3.0 をサポートに追加 (PR [#42](https://github.com/chocoby/jp_prefecture/pull/42)/[@chocoby](https://github.com/chocoby))
17
+ * 郵便番号データを更新 (PR [#46](https://github.com/chocoby/jp_prefecture/pull/46)/[@chocoby](https://github.com/chocoby))
18
+ * `JpPrefecture::Prefecture` クラスに都道府県コードから都道府県インスタンスを作成する `build_by_code` メソッドを追加 (PR [#44](https://github.com/chocoby/jp_prefecture/pull/44)/[@chocoby](https://github.com/chocoby))
19
+
20
+ 都道府県コードを指定すると、それに対応した都道府県の `JpPrefecture::Prefecture` インスタンスを取得するメソッドを追加しました。
21
+ `JpPrefecture::Prefecture.build` メソッドは参照している処理がなくなったため、削除しました。
22
+
23
+ ### Fixes
24
+
25
+ * 文字列による検索は項目を指定して検索する (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))
26
+
27
+ `JpPrefecture::Prefecture.find(name: '東')` を実行すると、青森県が取得されていた問題への対応です。これはマッピングのすべての項目を検索していたためです。
28
+ 対応として、`name` を指定した場合は漢字表記、`name_e` は英語表記など、指定した項目のみを検索するように変更しました。
29
+ すべての項目から検索したい場合は `JpPrefecture::Prefecture.find(all_fields: 'string')` を使用してください。
30
+
31
+ ### Documentation
32
+
33
+ * CONTRIBUTING.md を追加 (PR [#41](https://github.com/chocoby/jp_prefecture/pull/41)/[@chocoby](https://github.com/chocoby))
34
+
35
+ ### Misc
36
+
37
+ * RuboCop を導入 (PR [#40](https://github.com/chocoby/jp_prefecture/pull/40)/[@chocoby](https://github.com/chocoby))
38
+ * Gem に含めるファイルを最低限のものにする (PR [#48](https://github.com/chocoby/jp_prefecture/pull/48)/[@chocoby](https://github.com/chocoby))
39
+
40
+ ## 0.11.0 (2020-12-18)
4
41
 
5
42
  * Rails 6.1 をサポート (PR [#37](https://github.com/chocoby/jp_prefecture/pull/37)/[@chocoby](https://github.com/chocoby))
6
43
  * GitHub Actions でビルドを実行するようにした (PR [#34](https://github.com/chocoby/jp_prefecture/pull/34)/[@chocoby](https://github.com/chocoby))
7
44
 
8
- ## 0.10.0 (Aug 19, 2019)
45
+ ## 0.10.0 (2019-08-19)
9
46
 
10
47
  * Rails 6.0 をサポート (PR [#33](https://github.com/chocoby/jp_prefecture/pull/33)/[@chocoby](https://github.com/chocoby))
11
48
 
12
- ## 0.9.0 (Jan 15, 2017)
49
+ ## 0.9.0 (2017-01-15)
13
50
 
14
51
  * 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))
15
52
  * 都道府県情報に種類を追加 (PR [#23](https://github.com/chocoby/jp_prefecture/pull/23)/[@gazayas](https://github.com/gazayas))
16
53
 
17
- ## 0.8.1 (Mar 30, 2016)
54
+ ## 0.8.1 (2016-03-30)
18
55
 
19
56
  * `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))
20
57
 
21
- ## 0.8.0 (Sep 07, 2014)
58
+ ## 0.8.0 (2014-09-07)
22
59
 
23
60
  * 都道府県情報に八地方区分情報を追加 (PR [#14](https://github.com/chocoby/jp_prefecture/pull/14)/[@kkosuge](https://github.com/kkosuge))
24
61
 
25
- ## 0.7.0 (Jun 18, 2014)
62
+ ## 0.7.0 (2014-06-18)
26
63
 
27
64
  * 都道府県名にひらがな、カタカナを追加 (PR [#12](https://github.com/chocoby/jp_prefecture/pull/12)/[@yukihr](https://github.com/yukihr))
28
65
 
29
- ## 0.6.0 (Mar 10, 2014)
66
+ ## 0.6.0 (2014-03-10)
30
67
 
31
68
  * 都道府県名を前方一致で検索できるようにした (PR [#11](https://github.com/chocoby/jp_prefecture/pull/11)/[@yuuna](https://github.com/yuuna))
32
69
  * 都道府県名の検索ロジックを高速化
33
70
 
34
- ## 0.5.0 (Nov 30, 2013)
71
+ ## 0.5.0 (2013-11-30)
35
72
 
36
73
  * 郵便番号から都道府県を検索する機能の追加 (PR [#9](https://github.com/chocoby/jp_prefecture/pull/9)/[@fruwe](https://github.com/fruwe))
37
74
 
38
- ## 0.4.0 (Jul 08, 2013)
75
+ ## 0.4.0 (2013-07-08)
39
76
 
40
77
  * 都道府県のマッピングを変更する機能の追加 (PR [#8](https://github.com/chocoby/jp_prefecture/pull/8)/[@mizoR](https://github.com/mizoR))
41
78
 
42
- ## 0.3.2 (Jun 12, 2013)
79
+ ## 0.3.2 (2013-06-12)
43
80
 
44
81
  * 文字列を downcase してから都道府県の検索を行うようにした
45
82
 
46
- ## 0.3.1 (Jun 11, 2013)
83
+ ## 0.3.1 (2013-06-11)
47
84
 
48
85
  * name で渡した文字列が変更されるバグを修正
49
86
 
50
- ## 0.3.0 (Jun 11, 2013)
87
+ ## 0.3.0 (2013-06-11)
51
88
 
52
89
  * 都道府県名(英語表記含む)から都道府県を検索できるようにした
53
90
  * 都道府県名からの検索と同様の方法で、都道府県コードを検索できるようにした
54
91
  * String 型の都道府県コードに対応
55
92
 
56
- ## 0.2.0 (Jun 09, 2013)
93
+ ## 0.2.0 (2013-06-09)
57
94
 
58
95
  * 英語表記を追加
59
96
  * Ruby 1.8.7 のサポートを終了
60
97
 
61
- ## 0.1.1 (Mar 01, 2013)
98
+ ## 0.1.1 (2013-03-01)
62
99
 
63
100
  * モデルで使用する時に、生成するメソッド名を指定できるようにした
64
101
  * Configuration モデル/Model モジュールを廃止
65
102
  * extend による使用を廃止
66
103
  * Travis CI によるテストを行うようにした
67
104
 
68
- ## 0.1.0 (Feb 17, 2013)
105
+ ## 0.1.0 (2013-02-17)
69
106
 
70
107
  * モデルで使用する時に、対象のカラム名を指定するようにした
71
108
 
72
- ## 0.0.1 (Feb 14, 2013)
109
+ ## 0.0.1 (2013-02-14)
73
110
 
74
111
  * 都道府県の変換
75
112
  * 簡単な Rails サポート
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Kenta Okamoto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -41,7 +41,7 @@ require 'jp_prefecture'
41
41
  都道府県コードを渡すと、都道府県コードから都道府県を検索します:
42
42
 
43
43
  ```ruby
44
- pref = JpPrefecture::Prefecture.find 13
44
+ pref = JpPrefecture::Prefecture.find(13)
45
45
  # => #<JpPrefecture::Prefecture:0x007fceb11927d8 @code=13, @name="東京都", @name_e="Tokyo", @name_h="とうきょうと", @name_k="トウキョウト", @zips=[1000000..2080035], @area="関東">
46
46
  pref.code
47
47
  # => 13
@@ -62,18 +62,27 @@ pref.type
62
62
  以下のように書くことも可能です:
63
63
 
64
64
  ```ruby
65
- JpPrefecture::Prefecture.find code: 13
65
+ JpPrefecture::Prefecture.find(code: 13)
66
66
  ```
67
67
 
68
68
  ### 都道府県名から都道府県を検索
69
69
 
70
+ 前方一致で都道府県を検索します:
71
+
70
72
  ```ruby
71
- JpPrefecture::Prefecture.find name: "東京都"
72
- JpPrefecture::Prefecture.find name: "Tokyo"
73
- JpPrefecture::Prefecture.find name: "tokyo"
74
- JpPrefecture::Prefecture.find name: "トウキョウト"
75
- JpPrefecture::Prefecture.find name: "とうきょうと"
76
- JpPrefecture::Prefecture.find name: "東京"
73
+ # 漢字表記
74
+ JpPrefecture::Prefecture.find(name: "東京都")
75
+ JpPrefecture::Prefecture.find(name: "東京")
76
+
77
+ # 英語表記
78
+ JpPrefecture::Prefecture.find(name_e: "Tokyo")
79
+ JpPrefecture::Prefecture.find(name_e: "tokyo")
80
+
81
+ # ひらがな表記
82
+ JpPrefecture::Prefecture.find(name_h: "とうきょうと")
83
+
84
+ # カタカナ表記
85
+ JpPrefecture::Prefecture.find(name_k: "トウキョウト")
77
86
  ```
78
87
 
79
88
  ### 都道府県の一覧を取得
@@ -150,21 +159,33 @@ end
150
159
  マッピングデータを指定することができます:
151
160
 
152
161
  ```ruby
153
- custom_mapping_path = "..." # /path/to/mapping_data
162
+ custom_mapping_path = "/path/to/mapping_data.yml"
154
163
 
155
164
  JpPrefecture.setup do |config|
156
- config.mapping_data = YAML.load_file custom_mapping_path
165
+ config.mapping_data = YAML.load_file(custom_mapping_path)
157
166
  end
158
167
  ```
159
168
 
160
169
  マッピングデータのフォーマットについては [prefecture.yml](https://github.com/chocoby/jp_prefecture/blob/master/data/prefecture.yml) を参考にしてください。
161
170
 
171
+ ### 郵便番号の情報を変更する
172
+
173
+ ```ruby
174
+ custom_zip_mapping_path = "/path/to/zip_mapping_data.yml"
175
+
176
+ JpPrefecture.setup do |config|
177
+ config.zip_mapping_data = YAML.load_file(custom_zip_mapping_path)
178
+ end
179
+ ```
180
+
181
+ データのフォーマットについては [zip.yml](https://github.com/chocoby/jp_prefecture/blob/master/data/zip.yml) を参考にしてください。
182
+
162
183
 
163
184
  ## インストール
164
185
 
165
186
  以下の行を `Gemfile` に記述してから:
166
187
 
167
- ```
188
+ ```ruby
168
189
  gem 'jp_prefecture'
169
190
  ```
170
191
 
@@ -183,35 +204,14 @@ $ gem install jp_prefecture
183
204
 
184
205
  ## サポートしているバージョン
185
206
 
186
- * Ruby: 1.9.3 / 2.0 / 2.1 / 2.2 / 2.3 / 2.4 / 2.5 / 2.6 / 2.7
187
- * Rails: 3.2 / 4.0 / 4.1 / 4.2 / 5.0 / 5.1 / 5.2 / 6.0 / 6.1
207
+ * Ruby: 2.4 - 3.0
208
+ * Rails: 5.0 - 6.1
188
209
 
210
+ これより古い Ruby/Rails バージョンを使用する場合は、[`v0.11.0`](https://github.com/chocoby/jp_prefecture/tree/0.x) を利用してください。
189
211
 
190
212
  ## Contributing
191
213
 
192
- 1. Fork it
193
- 2. Create your feature branch (`git checkout -b my-new-feature`)
194
- 3. Commit your changes (`git commit -am 'Added some feature'`)
195
- 4. Push to the branch (`git push origin my-new-feature`)
196
- 5. Create new Pull Request
197
-
198
-
199
- ## テスト
200
-
201
- ```
202
- git clone https://github.com/chocoby/jp_prefecture.git
203
- cd jp_prefecture
204
- bundle install
205
- bundle exec rspec
206
- ```
207
-
208
- 複数バージョンの Active Record でテストを実行:
209
-
210
- ```
211
- bundle exec appraisal install
212
- bundle exec appraisal rspec
213
- ```
214
-
214
+ [CONTRIBUTING.md](https://github.com/chocoby/jp_prefecture/blob/master/CONTRIBUTING.md) を確認してください。
215
215
 
216
216
  ## GitHub
217
217
 
data/README_EN.md CHANGED
@@ -38,7 +38,7 @@ require 'jp_prefecture'
38
38
  Provide prefecture code to search prefecture's data
39
39
 
40
40
  ```ruby
41
- pref = JpPrefecture::Prefecture.find 13
41
+ pref = JpPrefecture::Prefecture.find(13)
42
42
  # => #<JpPrefecture::Prefecture:0x007fceb11927d8 @code=13, @name="東京都", @name_e="Tokyo", @name_h="とうきょうと", @name_k="トウキョウト", @zips=[1000000..2080035], @area="関東">
43
43
  pref.code
44
44
  # => 13
@@ -59,18 +59,27 @@ pref.type
59
59
  or
60
60
 
61
61
  ```ruby
62
- JpPrefecture::Prefecture.find code: 13
62
+ JpPrefecture::Prefecture.find(code: 13)
63
63
  ```
64
64
 
65
65
  ### Search by Prefecture Name
66
66
 
67
+ Search for a prefecture by forward match.
68
+
67
69
  ```ruby
68
- JpPrefecture::Prefecture.find name: "東京都"
69
- JpPrefecture::Prefecture.find name: "Tokyo"
70
- JpPrefecture::Prefecture.find name: "tokyo"
71
- JpPrefecture::Prefecture.find name: "トウキョウト"
72
- JpPrefecture::Prefecture.find name: "とうきょうと"
73
- JpPrefecture::Prefecture.find name: "東京"
70
+ # Kanji
71
+ JpPrefecture::Prefecture.find(name: "東京都")
72
+ JpPrefecture::Prefecture.find(name: "東京")
73
+
74
+ # English
75
+ JpPrefecture::Prefecture.find(name_e: "Tokyo")
76
+ JpPrefecture::Prefecture.find(name_e: "tokyo")
77
+
78
+ # Hiragana
79
+ JpPrefecture::Prefecture.find(name_h: "とうきょうと")
80
+
81
+ # Kakatana
82
+ JpPrefecture::Prefecture.find(name_k: "トウキョウト")
74
83
  ```
75
84
 
76
85
  ### All Prefectures
@@ -144,18 +153,32 @@ end
144
153
 
145
154
  ### Customize Mapping Data
146
155
 
147
- Customize mapping data with `custom_mapping_path`.
156
+ Customize mapping data with `mapping_data`.
148
157
 
149
158
  ```ruby
150
- custom_mapping_path = "..." # /path/to/mapping_data
159
+ custom_mapping_path = "/path/to/mapping_data.yml"
151
160
 
152
161
  JpPrefecture.setup do |config|
153
- config.mapping_data = YAML.load_file custom_mapping_path
162
+ config.mapping_data = YAML.load_file(custom_mapping_path)
154
163
  end
155
164
  ```
156
165
 
157
166
  Check out [prefecture.yml](https://github.com/chocoby/jp_prefecture/blob/master/data/prefecture.yml) for data format.
158
167
 
168
+ ### Customize Zip Code Data
169
+
170
+ Customize zip code data with `zip_mapping_data`.
171
+
172
+ ```ruby
173
+ custom_zip_mapping_path = "/path/to/zip_mapping_data.yml"
174
+
175
+ JpPrefecture.setup do |config|
176
+ config.zip_mapping_data = YAML.load_file(custom_zip_mapping_path)
177
+ end
178
+ ```
179
+
180
+ Check out [zip.yml](https://github.com/chocoby/jp_prefecture/blob/master/data/zip.yml) for data format.
181
+
159
182
 
160
183
  ## Installation
161
184
 
@@ -182,37 +205,16 @@ $ gem install jp_prefecture
182
205
 
183
206
  [http://rdoc.info/github/chocoby/jp_prefecture/master/frames/index](http://rdoc.info/github/chocoby/jp_prefecture/master/frames/index)
184
207
 
185
- ## Supports
208
+ ## Supported versions
186
209
 
187
- * Ruby: 1.9.3 / 2.0 / 2.1 / 2.2 / 2.3 / 2.4 / 2.5 / 2.6 / 2.7
188
- * Rails: 3.2 / 4.0 / 4.1 / 4.2 / 5.0 / 5.1 / 5.2 / 6.0 / 6.1
210
+ * Ruby: 2.4 - 3.0
211
+ * Rails: 5.0 - 6.1
189
212
 
213
+ If you are using an older Ruby/Rails version, please use [`v0.11.0`](https://github.com/chocoby/jp_prefecture/tree/0.x).
190
214
 
191
215
  ## Contributing
192
216
 
193
- 1. Fork it
194
- 2. Create your feature branch (`git checkout -b my-new-feature`)
195
- 3. Commit your changes (`git commit -am 'Added some feature'`)
196
- 4. Push to the branch (`git push origin my-new-feature`)
197
- 5. Create new Pull Request
198
-
199
-
200
- ## Test
201
-
202
- ```
203
- git clone https://github.com/chocoby/jp_prefecture.git
204
- cd jp_prefecture
205
- bundle install
206
- bundle exec rspec
207
- ```
208
-
209
- Run test in multiple `ActiveRecord` versions
210
-
211
- ```
212
- bundle exec appraisal install
213
- bundle exec appraisal rspec
214
- ```
215
-
217
+ See [CONTRIBUTING.md](https://github.com/chocoby/jp_prefecture/blob/master/CONTRIBUTING.md).
216
218
 
217
219
  ## GitHub
218
220
 
data/data/zip.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  # { prefecture_code: [[from_zip_1, to_zip_1], [from_zip_2, to_zip_2], ...], ... }
2
+ # Last updated: 2021-02-10 05:59:09 UTC
2
3
  ---
3
4
  1:
4
5
  - - 10000
@@ -41,6 +42,8 @@
41
42
  - 3491221
42
43
  10:
43
44
  - - 3700000
45
+ - 3701506
46
+ - - 3701511
44
47
  - 3792314
45
48
  - - 3840097
46
49
  - 3840097
@@ -51,6 +54,8 @@
51
54
  - 3491216
52
55
  - - 3500001
53
56
  - 3691912
57
+ - - 3701507
58
+ - 3701507
54
59
  12:
55
60
  - - 2600000
56
61
  - 2995506
@@ -110,14 +115,14 @@
110
115
  - - 4314121
111
116
  - 4314121
112
117
  - - 4400001
113
- - 4970058
114
- - - 4980000
118
+ - 4980000
119
+ - - 4980001
115
120
  - 4980069
116
121
  24:
117
122
  - - 4980000
118
123
  - 4980000
119
124
  - - 4980801
120
- - 4980823
125
+ - 4980824
121
126
  - - 5100000
122
127
  - 5195835
123
128
  - - 6471321
@@ -231,8 +236,8 @@
231
236
  - - 8391421
232
237
  - 8391421
233
238
  - - 8700001
234
- - 8710000
235
- - - 8710001
239
+ - 8701223
240
+ - - 8710000
236
241
  - 8710208
237
242
  - - 8710311
238
243
  - 8710716