jp_address 0.0.5 → 0.0.6

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: '0889396e617633b2af55a6a945d002cc5e458534836b263196696fb9e495ab13'
4
- data.tar.gz: c227d271b43d600bce2263c5acc525bfb95fad1bbd0220c032a5d208ec016818
3
+ metadata.gz: dc228821115f2e98e52ad5ae56e08c38c8fc7d5d5a062092730d056392c684a7
4
+ data.tar.gz: c7faf9d05284e2f2fe71a3ce0330ca8880b40a87b32c80bb3559185eaa2c7ed5
5
5
  SHA512:
6
- metadata.gz: 440e77f385dd7831ccd66ecdc126a854e564eb759627232f30077b9c3d8fa588c90bf9de4b17203a9c8f64993a52b407f7fd2acd40b39431cde7752da2204fdb
7
- data.tar.gz: cf225b7ca01116d1e93d421b1c51fa6fed06f33d2c51a2cfc1abd08adf5121db51d902c7dd245d71df2fdd752813dc1e9e2d10332d58c3279d1c46c363d9ef9f
6
+ metadata.gz: '08310f53ddb11ab7015d35105af832bffee63ffb20db6c443eb981845e2c7ce16a977beeefe294556be35cc1b8fe401938da997dd2e87ae3662e2296d9dd5e3a'
7
+ data.tar.gz: 67982252ef4e0678571508dd33aaaa0085fb2aaa3e48b4e0384431bb7141e81943e19d1c2eb8ca3c3e35b97e5a30ab62f2af7a4fe90729a6f930a2368bc34ef5
data/README.rdoc CHANGED
@@ -1,13 +1,13 @@
1
- = JpAddress: A Rails plugin for Japan Zipcode API.
1
+ = Ruby on Rails 6 郵便番号住所検索 gem
2
2
 
3
3
  == JpAddressとは
4
- 日本郵便の「郵便番号データ」を Rails 6.1 で使用するための gem です。
4
+ 日本郵便の「郵便番号データ(https://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip)」を Rails 6.1 で使用するための gem です。
5
5
  以下の機能を提供します。
6
6
 
7
- * 郵便局提供の郵便番号データをダウンロードしてDBにロードするクラスメソッド。(JpAddress::Zipcode.load_master_data)
8
- * 郵便番号をキーに住所情報を返却するAPI(jp_address/zipcodes#search)。
7
+ * 郵便局提供の郵便番号データをダウンロードして自前DBのテーブル(jp_address_zipcodes)にロードするクラスメソッド。(JpAddress::Zipcode.load_master_data)
8
+ * 郵便番号を受け取り住所情報をJSONで返却するAPI(jp_address/zipcodes#search)。
9
9
 
10
- 要するに、「郵便番号検索 ruby gem」でググった人向けの gem です。
10
+ 要するに、「郵便番号住所検索 ruby gem」でググった人向けの gem です。
11
11
  お使いのRailsアプリケーションにマウントして使えますので、後必要なのは戻ってくるJSONを加工する手順だけです。
12
12
 
13
13
  == インストール
@@ -17,8 +17,8 @@ GemFileに追記
17
17
  gem 'jp_address'
18
18
 
19
19
  テーブルの作成
20
- % rake jp_address:install:migrations
21
- % rake db:migrate
20
+ % bundle exec rails jp_address:install:migrations
21
+ % bundle exec rails db:migrate
22
22
 
23
23
  == マスターデータのDBへのロード
24
24
  開発環境
@@ -47,10 +47,10 @@ GemFileに追記
47
47
 
48
48
  == APIを利用するためのサンプル JavaScript
49
49
  フォームには
50
- * zipcode(テキストボックス)
51
- * prefecture_id(セレクトボックス。いわゆる都道府県プルダウン)
52
- * address(テキストボックス)
53
- の3要素があり、zipcodeに入れられた値を元にAPIを叩き、prefecture_id と address に
50
+ * #zipcode(テキストボックス)
51
+ * #prefecture_id(セレクトボックス。いわゆる都道府県プルダウン)
52
+ * #address(テキストボックス)
53
+ の3要素があり、#zipcodeに入れられた値を元にAPIを叩き、#prefecture_id と #address に
54
54
  値をセットするサンプルです。
55
55
 
56
56
  prefecture_id の選択は、都道府県名で行っています。
@@ -59,6 +59,7 @@ prefecture_id の選択は、都道府県名で行っています。
59
59
  ※ JQuery の存在を前提にしています。
60
60
  ※ もともと CoffeeScript で書いてあったソースを decaffeinate したものです。
61
61
 
62
+ // ここから
62
63
  function _classCallCheck(instance, Constructor) {
63
64
  if (!(instance instanceof Constructor)) {
64
65
  throw new TypeError("Cannot call a class as a function");
@@ -154,14 +155,17 @@ prefecture_id の選択は、都道府県名で行っています。
154
155
 
155
156
  return AddressSearch;
156
157
  }();
158
+ // ここまでを application.js など共通に読み込まれるファイルに配置。
157
159
 
160
+ // ここから
158
161
  // #zipcode, #prefecture_id, #address を各自の環境に合わせて書き換えてください。
159
162
  $(function() {
160
163
  var address_search = new AddressSearch('#zipcode', '#prefecture_id', '#address');
161
- return $('#zipcode').keyup(function() {
162
- return address_search.execute();
164
+ $('#zipcode').keyup(function() {
165
+ address_search.execute();
163
166
  });
164
167
  });
168
+ // ここまでをフォームのあるページに配置。
165
169
 
166
170
 
167
171
  == 作者
@@ -17,10 +17,12 @@ module JpAddress
17
17
  private_class_method :_setup_directory
18
18
 
19
19
  def self._request_to_japanpost
20
- url = URI.parse('http://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip')
21
- res = Net::HTTP.start(url.host, url.port) do |http|
22
- http.get('/zipcode/dl/kogaki/zip/ken_all.zip')
23
- end
20
+ res = nil
21
+ https = Net::HTTP.new('www.post.japanpost.jp',443)
22
+ https.use_ssl = true
23
+ https.start {
24
+ res = https.get('/zipcode/dl/kogaki/zip/ken_all.zip')
25
+ }
24
26
  res
25
27
  end
26
28
  private_class_method :_request_to_japanpost
@@ -1,4 +1,4 @@
1
- class CreateJpAddressZipcodes < ActiveRecord::Migration
1
+ class CreateJpAddressZipcodes < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table :jp_address_zipcodes do |t|
4
4
  t.string :zip , null: false, index: true
data/lib/jp_address.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'net/http'
1
+ require 'net/https'
2
2
  require 'uri'
3
3
  require 'tempfile'
4
4
  require 'csv'
@@ -1,3 +1,3 @@
1
1
  module JpAddress
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
File without changes
@@ -0,0 +1,6 @@
1
+  (12.3ms) SELECT sqlite_version(*)
2
+  (0.1ms) SELECT sqlite_version(*)
3
+  (0.1ms) SELECT sqlite_version(*)
4
+  (0.1ms) SELECT sqlite_version(*)
5
+  (0.1ms) SELECT sqlite_version(*)
6
+  (0.2ms) SELECT sqlite_version(*)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jp_address
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tad Kam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2021-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -165,6 +165,8 @@ files:
165
165
  - spec/dummy/config/routes.rb
166
166
  - spec/dummy/config/secrets.yml
167
167
  - spec/dummy/db/schema.rb
168
+ - spec/dummy/db/test.sqlite3
169
+ - spec/dummy/log/test.log
168
170
  - spec/dummy/public/404.html
169
171
  - spec/dummy/public/422.html
170
172
  - spec/dummy/public/500.html
@@ -194,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
196
  - !ruby/object:Gem::Version
195
197
  version: '0'
196
198
  requirements: []
197
- rubygems_version: 3.2.15
199
+ rubygems_version: 3.1.4
198
200
  signing_key:
199
201
  specification_version: 4
200
202
  summary: Simple japan-zipcode-addresses API
@@ -232,6 +234,8 @@ test_files:
232
234
  - spec/dummy/config/secrets.yml
233
235
  - spec/dummy/config.ru
234
236
  - spec/dummy/db/schema.rb
237
+ - spec/dummy/db/test.sqlite3
238
+ - spec/dummy/log/test.log
235
239
  - spec/dummy/public/404.html
236
240
  - spec/dummy/public/422.html
237
241
  - spec/dummy/public/500.html