japan_postcoder 0.1.4 β†’ 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: 42f711e90b2e76e99624f0aafbfde2556a8861fc6e0a8ee28e257d23fdc5e297
4
- data.tar.gz: f754eed765d524c921a94151e280c73cb0a6c8a67207603664dab81454dfe4d4
3
+ metadata.gz: d3e586650b4f5341b900ad823ee293bfd2f8657add741f38b547ff40c12efbca
4
+ data.tar.gz: a85ca2b8f88ae9c68f230dc9db5e76d6da19800087d8f6c43eb7302cc9036d06
5
5
  SHA512:
6
- metadata.gz: e33bfd75a16a545c31b0788f915a2df232d2a8208feed1f60e39889b44a9b72ff1d8def8e9eb4077b22ca44ae0a8a30870459a64fe857b2d92935b250a6825fc
7
- data.tar.gz: b8a812518c9ab347682f26f38dcc41f4a5629d3252fe060b79451036b728932b2aac7188c14121e868b256244d55d423063e4bcd3013c9acaa1a2f1f611252e4
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>`
@@ -16,11 +16,10 @@ Gem::Specification.new do |spec|
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.4'
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.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Duong
@@ -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
@@ -39,7 +36,6 @@ metadata:
39
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