0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Convert SG Postcode to long lat array
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 3.2
~> 1.8.0
 Project Readme

SgPostcode 💎

Build Status

Convert an array of Postcode to an array of place info, include long, lat, and format address.

##Requirement :octocat:

  • ruby > 1.9, recommend > 2.0.0
  • redis

##DEMO

I also create a docker version for the demo, it use Passenger Docker Image. Thanks you for saving my life 😚

##Install 📎

To install this gem, simply use gem install sg_postcode or add this line

gem 'sg_postcode', '~> 1.2.6'

to the Gemfile, and run bundle install. 😁

##Usage 💝

Follow this snippet

 require 'sg_postcode'
 postcode = ['238432', '234444']
 SgPostcode::Array.new(postcodes).convert

There are some options:

  • response_type: default is :json
  • host: default :Google
  • cache: true or false

Actually right now, this gem only accept these default value 😏

####ADVANCE USAGES: 💡

  1. Key Path

To edit the response data's fields, you can take a look at lib/sg_postcode/response/config.rb

We use #dig method, that is implement in this tutorial to get the value in the hash. So we call key_path for the path of a key sequence. Checkout this snippet for more information.

  1. Redis config

In default, Redis will use localhost and port 6379, if you want to customize, you can set the value for the environment variable REDIS_URL.

For example:

ENV['REDIS_URL'] = 'redis://:p4ssw0rd@10.0.1.1:6380/15'

Check out the redis gem for more information.

The gem use Hash type to store the postcode request. The Hash key is defined in lib/sg_postcode/services/cache_adapter.rb

You can change it, just call SgPostcode::CacheAdapter.hashname = 'IamAwesomeStore'

##Contribute 👍

Feel free to fork it and send me PRs and Issues, comments to help it better. 👍

This project use Zenhub as a PM tool.

##Copyright 💯

This project rocks and uses MIT-LICENSE.