An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          







πŸ‡―πŸ‡΅ Japan Postcoder

[![Tests](https://github.com/tonystrawberry/japan_postcoder/workflows/Ruby/badge.svg)](https://github.com/tonystrawberry/japan_postcoder/actions/workflows/main.yml)


[![Gem Version](https://badge.fury.io/rb/japan_postcoder.svg)](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 `