Code Monkey home page Code Monkey logo

sg_postcode's Introduction

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://:[email protected]: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.

sg_postcode's People

Contributors

duykhoa avatar

Stargazers

Sam Hon avatar  avatar

Watchers

Sam Hon avatar James Cloos avatar  avatar Adrian Lim avatar  avatar Celine avatar rspapps avatar  avatar  avatar  avatar

Forkers

duykhoa

sg_postcode's Issues

init the project

  • Setup the project with git
  • Add testing framework
  • Create readme file
  • integrate with CI Build Status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.