https://github.com/tonystrawberry/japan_postcoder
π‘ A Ruby gem for getting Japan address from postal code.
https://github.com/tonystrawberry/japan_postcoder
address gem japan ruby
Last synced: over 1 year ago
JSON representation
π‘ A Ruby gem for getting Japan address from postal code.
- Host: GitHub
- URL: https://github.com/tonystrawberry/japan_postcoder
- Owner: tonystrawberry
- License: mit
- Created: 2023-08-22T11:34:46.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-22T15:56:03.000Z (almost 3 years ago)
- Last Synced: 2024-04-26T07:22:46.135Z (about 2 years ago)
- Topics: address, gem, japan, ruby
- Language: Ruby
- Homepage:
- Size: 9.78 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
π―π΅ Japan Postcoder
[](https://github.com/tonystrawberry/japan_postcoder/actions/workflows/main.yml)
[](https://badge.fury.io/rb/japan_postcoder)
Japan Postcoder is a library that allows you to get the address of a location in Japan from its postcode.
It will help you get the prefecture, city, ward and street name from a postcode.
All the location data is provided by the [Japan Post](https://www.post.japanpost.jp/zipcode/download.html)
Rubygems link is here: https://rubygems.org/gems/japan_postcoder
# ππ» Getting started
Start by including `japan-postcoder` in your project:
```bash
gem 'japan-postcoder'
```
Then, you can use the `JapanPostcoder` class to get the address of a location in Japan from its postcode:
# π¨π»βπ» Usage
You can use the `JapanPostcoder` class to get the address of a location in Japan in **string** format.
```ruby
require 'japan-postcoder'
postcode = '2140037'
address = JapanPostcoder.to_address(postcode)
puts address # => "η₯ε₯ε·ηε·ε΄εΈε€ζ©εΊθ
δ»θ°·ηΊ"
```
You can also use the `JapanPostcoder` class to get the address of a location in Japan in **hash** format.
```ruby
require 'japan-postcoder'
postcode = '2140037'
address = JapanPostcoder.to_address_hash(postcode)
puts address # => {:prefecture=>"η₯ε₯ε·η", :city=>"ε·ε΄εΈ", :ward=>"ε€ζ©εΊ", :district=>"θ
δ»θ°·ηΊ"}
```
## π¬π§ Romaji transcription
You can use the `JapanPostcoder` class to get the address of a location in Japan in **romaji** format by using the `romaji` named argument.
```ruby
address = JapanPostcoder.to_address('2140037', romaji: true)
puts address # => "KANAGAWA KEN KAWASAKI SHI TAMA KU SUGESEN YACHO"
```
```ruby
address = JapanPostcoder.to_address_hash('2140037', romaji: true)
puts address # => {:prefecture=>"KANAGAWA KEN", :city=>"KAWASAKI SHI", :ward=>"TAMA KU", :district=>"SUGESEN YACHO"}
```
# πͺ Contributing
If you notice a bug or want to add a new feature, please open an issue or submit a pull request.
Thank you and enjoy!
# π License
This project is free to use under the terms of the MIT License.
# π Self-memo
After updating the gem:
- Update the version in `lib/japan_postcoder/version.rb`
- Create a PR and merge it after it's been approved & tested
- Run `gem build japan_postcoder.gemspec`
- Run `gem push japan_postcoder-.gem`
- Run `gh release create `