japan_postcoder 0.1.3 β†’ 0.1.5

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: b9ec6c49d73a6649ebeef6420904b142db452db7737fde8c1901775454d52b54
4
- data.tar.gz: 748a7ec239765164ae7810042423c8369e0cb3c525f91005409dcaab5856d8f7
3
+ metadata.gz: d3e586650b4f5341b900ad823ee293bfd2f8657add741f38b547ff40c12efbca
4
+ data.tar.gz: a85ca2b8f88ae9c68f230dc9db5e76d6da19800087d8f6c43eb7302cc9036d06
5
5
  SHA512:
6
- metadata.gz: d2aa122b1f6ec5a842fc0a6e9a9471e9e3001ac6c9efc57a605c922f0fe12f241dd9545b767199be2a5fb978783ffabaaf8111e3356e92a97c6130dd662d5531
7
- data.tar.gz: 7fb3e7557d4eb126d9c86e5ca06f36d8c42a88d68793913fbf5adeff2ef973b8028a11d1aa455552d4625b42501692b6a02432957600f67ba22211ab990761de
6
+ metadata.gz: 1c42fdfa2a7728f0cee86f28aa86e1e68ff6c11793272eb9977d9168689c7f8de0d1a8ef68859fe70cd19442b7d664781880a65452313479bb05a7c5eafad91e
7
+ data.tar.gz: cade322ce15eb46ce73b119bd25b630da8209b526fc4bd29f8065f551abe94d9bc7f38ab1e79a199c5cfb9f6ce1898b1152ebbf1820b0535724e102efde341e8
data/README.md CHANGED
@@ -1,35 +1,82 @@
1
- # JapanPostcoder
1
+ <p align="center">
2
+ <a>
3
+ <img src="https://static.vecteezy.com/system/resources/thumbnails/004/587/562/small_2x/doodle-freehand-drawing-of-japan-map-free-vector.jpg" width="60" />
4
+ </a>
5
+ </p>
6
+ <h1 align="center">
7
+ πŸ‡―πŸ‡΅ Japan Postcoder
8
+ </h1>
2
9
 
3
- TODO: Delete this and the text below, and describe your gem
10
+ [![Tests](https://github.com/tonystrawberry/japan_postcoder/workflows/Ruby/badge.svg)](https://github.com/tonystrawberry/japan_postcoder/actions/workflows/main.yml)
11
+ <a href="https://codeclimate.com/github/tonystrawberry/japan_postcoder/maintainability"><img src="https://api.codeclimate.com/v1/badges/7362475ad52048cbbee1/maintainability" /></a>
12
+ <a href="https://codeclimate.com/github/tonystrawberry/japan_postcoder/test_coverage"><img src="https://api.codeclimate.com/v1/badges/7362475ad52048cbbee1/test_coverage" /></a>
4
13
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/japan_postcoder`. To experiment with that code, run `bin/console` for an interactive prompt.
14
+ Japan Postcoder is a library that allows you to get the address of a location in Japan from its postcode.
15
+ It will help you get the prefecture, city, ward and street name from a postcode.
6
16
 
7
- ## Installation
17
+ All the location data is provided by the [Japan Post](https://www.post.japanpost.jp/zipcode/download.html)
8
18
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
19
+ Rubygems link is here: https://rubygems.org/gems/japan_postcoder
10
20
 
11
- Install the gem and add to the application's Gemfile by executing:
21
+ # πŸƒπŸ» Getting started
12
22
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
23
+ Start by including `japan-postcoder` in your project:
14
24
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
25
+ ```bash
26
+ gem 'japan-postcoder'
27
+ ```
16
28
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
29
+ Then, you can use the `JapanPostcoder` class to get the address of a location in Japan from its postcode:
18
30
 
19
- ## Usage
31
+ # πŸ‘¨πŸ»β€πŸ’» Usage
20
32
 
21
- TODO: Write usage instructions here
33
+ You can use the `JapanPostcoder` class to get the address of a location in Japan in **string** format.
34
+ ```ruby
35
+ require 'japan-postcoder'
22
36
 
23
- ## Development
37
+ postcode = '2140037'
38
+ address = JapanPostcoder.to_address(postcode)
24
39
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+ puts address # => "η₯žε₯ˆε·ηœŒε·ε΄ŽεΈ‚ε€šζ‘©εŒΊθ…δ»™θ°·η”Ί"
41
+ ```
26
42
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+ You can also use the `JapanPostcoder` class to get the address of a location in Japan in **hash** format.
44
+ ```ruby
45
+ require 'japan-postcoder'
28
46
 
29
- ## Contributing
47
+ postcode = '2140037'
48
+ address = JapanPostcoder.to_address_hash(postcode)
30
49
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/japan_postcoder.
50
+ puts address # => {:prefecture=>"η₯žε₯ˆε·ηœŒ", :city=>"ε·ε΄ŽεΈ‚", :ward=>"ε€šζ‘©εŒΊ", :district=>"菅仙谷町"}
51
+ ```
32
52
 
33
- ## License
53
+ ## πŸ‡¬πŸ‡§ Romaji transcription
34
54
 
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
55
+ You can use the `JapanPostcoder` class to get the address of a location in Japan in **romaji** format by using the `romaji` named argument.
56
+
57
+ ```ruby
58
+ address = JapanPostcoder.to_address('2140037', romaji: true)
59
+ puts address # => "KANAGAWA KEN KAWASAKI SHI TAMA KU SUGESEN YACHO"
60
+ ```
61
+
62
+ ```ruby
63
+ address = JapanPostcoder.to_address_hash('2140037', romaji: true)
64
+ puts address # => {:prefecture=>"KANAGAWA KEN", :city=>"KAWASAKI SHI", :ward=>"TAMA KU", :district=>"SUGESEN YACHO"}
65
+ ```
66
+
67
+ # πŸ’ͺ Contributing
68
+
69
+ If you notice a bug or want to add a new feature, please open an issue or submit a pull request.
70
+ Thank you and enjoy!
71
+
72
+ # πŸ“ License
73
+
74
+ This project is free to use under the terms of the MIT License.
75
+
76
+ # πŸ“ Self-memo
77
+ After updating the gem:
78
+ - Update the version in `lib/japan_postcoder/version.rb`
79
+ - Create a PR and merge it after it's been approved & tested
80
+ - Run `gem build japan_postcoder.gemspec`
81
+ - Run `gem push japan_postcoder-<version>.gem`
82
+ - Run `gh release create <version>`
@@ -10,17 +10,16 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = '🏑 A Ruby gem for getting Japan address from postal code.'
12
12
  spec.description = "πŸ‡―πŸ‡΅ JapanPostcoder is a Ruby gem for getting Japan address from postal code.
13
- Information is based on the data from the JapanPost website:https://www.post.japanpost.jp/zipcode/download.html.
13
+ Information is based on the data from the JapanPost website: https://www.post.japanpost.jp/zipcode/download.html.
14
14
  "
15
15
  spec.homepage = 'https://github.com/tonystrawberry/japan_postcoder'
16
16
  spec.license = 'MIT'
17
17
  spec.required_ruby_version = '>= 2.7.0'
18
18
 
19
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
20
20
 
21
21
  spec.metadata['homepage_uri'] = spec.homepage
22
22
  spec.metadata['source_code_uri'] = 'https://github.com/tonystrawberry/japan_postcoder'
23
- spec.metadata['changelog_uri'] = 'https://github.com/tonystrawberry/japan_postcoder/CHANGELOG.md'
24
23
 
25
24
  # Specify which files should be added to the gem when it is released.
26
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -1,37 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ## Class for Japanese Address
4
- ## Has attributes for postcode, prefecture, city, ward and district
5
- #
6
- class JapanPostcoder::Address
7
- attr_accessor :postcode, :prefecture, :city, :ward, :district
3
+ module JapanPostcoder
4
+ ## Class for Japanese Address
5
+ ## Has attributes for postcode, prefecture, city, ward and district
6
+ #
7
+ class Address
8
+ attr_accessor :postcode, :prefecture, :city, :ward, :district
8
9
 
9
- # Initialize the address with postcode, prefecture, city, ward and district
10
- def initialize(postcode, prefecture, city, ward, district)
11
- @postcode = postcode
12
- @prefecture = prefecture
13
- @city = city
14
- @ward = ward
15
- @district = district
16
- end
10
+ # Initialize the address with postcode, prefecture, city, ward and district
11
+ def initialize(postcode, prefecture, city, ward, district)
12
+ @postcode = postcode
13
+ @prefecture = prefecture
14
+ @city = city
15
+ @ward = ward
16
+ @district = district
17
+ end
17
18
 
18
- # Returns the full address as a string
19
- def to_s(romaji: false)
20
- if romaji
21
- "#{@prefecture} #{@city} #{@ward} #{@district}"
22
- else
23
- "#{@prefecture}#{@city}#{@ward}#{@district}"
19
+ # Returns the full address as a string
20
+ def to_s(romaji: false)
21
+ if romaji
22
+ "#{@prefecture} #{@city} #{@ward} #{@district}"
23
+ else
24
+ "#{@prefecture}#{@city}#{@ward}#{@district}"
25
+ end
24
26
  end
25
- end
26
27
 
27
- # Returns the full address as a hash
28
- def to_h
29
- {
30
- postcode: @postcode,
31
- prefecture: @prefecture,
32
- city: @city,
33
- ward: @ward,
34
- district: @district
35
- }
28
+ # Returns the full address as a hash
29
+ def to_h
30
+ {
31
+ postcode: @postcode,
32
+ prefecture: @prefecture,
33
+ city: @city,
34
+ ward: @ward,
35
+ district: @district
36
+ }
37
+ end
36
38
  end
37
39
  end
@@ -14,6 +14,8 @@ module JapanPostcoder
14
14
  # Returns the address in string format
15
15
  # Example: 'η₯žε₯ˆε·ηœŒε·ε΄ŽεΈ‚ε€šζ‘©εŒΊθ₯Ώη”Ÿη”°'
16
16
  def self.to_address(postal_code, romaji: false)
17
+ postal_code = postal_code.to_s
18
+
17
19
  validate_postal_code!(postal_code)
18
20
 
19
21
  address = get_address(postal_code, romaji: romaji)
@@ -31,6 +33,8 @@ module JapanPostcoder
31
33
  # district: 'θ₯Ώη”Ÿη”°'
32
34
  # }
33
35
  def self.to_address_hash(postal_code, romaji: false)
36
+ postal_code = postal_code.to_s
37
+
34
38
  validate_postal_code!(postal_code)
35
39
 
36
40
  address = get_address(postal_code, romaji: romaji)
@@ -38,8 +42,6 @@ module JapanPostcoder
38
42
  address.to_h
39
43
  end
40
44
 
41
- private
42
-
43
45
  # Validates the postal code format
44
46
  # Raises InvalidPostalCodeError if the postal code is invalid
45
47
  def self.validate_postal_code!(postal_code)
@@ -51,7 +53,11 @@ module JapanPostcoder
51
53
 
52
54
  # Returns an Address object
53
55
  # Example:
54
- # #<Japan::Address:0x00007f9d0a8d3d88 @postcode="2140037", @prefecture="η₯žε₯ˆε·ηœŒ", @city="ε·ε΄ŽεΈ‚", @ward="ε€šζ‘©εŒΊ", @district="θ₯Ώη”Ÿη”°">
56
+ # #<Japan::Address:0x00007f9d0a8d3d88 @postcode="2140037",
57
+ # @prefecture="η₯žε₯ˆε·ηœŒ",
58
+ # @city="ε·ε΄ŽεΈ‚",
59
+ # @ward="ε€šζ‘©εŒΊ",
60
+ # @district="θ₯Ώη”Ÿη”°">
55
61
  def self.get_address(postal_code, romaji: false)
56
62
  # Read from ./jp_postcodes.json (Shift JIS)
57
63
  # Format: {
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JapanPostcoder
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: japan_postcoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Duong
@@ -12,7 +12,7 @@ date: 2023-08-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "\U0001F1EF\U0001F1F5 JapanPostcoder is a Ruby gem for getting Japan
14
14
  address from postal code.\n Information is based on the data from the JapanPost
15
- website:https://www.post.japanpost.jp/zipcode/download.html.\n "
15
+ website: https://www.post.japanpost.jp/zipcode/download.html.\n "
16
16
  email:
17
17
  - tony.duong.102@gmail.com
18
18
  executables: []
@@ -21,12 +21,9 @@ extra_rdoc_files: []
21
21
  files:
22
22
  - ".rspec"
23
23
  - ".rubocop.yml"
24
- - CHANGELOG.md
25
24
  - LICENSE.txt
26
25
  - README.md
27
26
  - Rakefile
28
- - japan_postcoder-0.1.0.gem
29
- - japan_postcoder-0.1.1.gem
30
27
  - japan_postcoder.gemspec
31
28
  - lib/japan_postcoder.rb
32
29
  - lib/japan_postcoder/address.rb
@@ -36,10 +33,9 @@ homepage: https://github.com/tonystrawberry/japan_postcoder
36
33
  licenses:
37
34
  - MIT
38
35
  metadata:
39
- allowed_push_host: https://rubygems.org
36
+ allowed_push_host: https://rubygems.org/
40
37
  homepage_uri: https://github.com/tonystrawberry/japan_postcoder
41
38
  source_code_uri: https://github.com/tonystrawberry/japan_postcoder
42
- changelog_uri: https://github.com/tonystrawberry/japan_postcoder/CHANGELOG.md
43
39
  rubygems_mfa_required: 'true'
44
40
  post_install_message:
45
41
  rdoc_options: []
data/CHANGELOG.md DELETED
@@ -1,3 +0,0 @@
1
- ## [0.1.0] - 2023-08-22
2
-
3
- - Initial release
Binary file
Binary file