Project

pinas

0.0
No commit activity in last 3 years
No release in over 3 years
Provide Philippines locations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0

Runtime

~> 1.2
< 5, >= 3.2.6
 Project Readme

Pinas

Gem Version Build Status

Pinas This gem provides hierarchical listing of Philippine location.

Installation

Add this line to your application's Gemfile:

gem 'pinas'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pinas

Setup

$ rails g pinas:install

$ rake db:migrate

$ rake pinas:load_data

Usage/Sample

The gem provides ActiveRecord model Pinas::Location in 4 levels of locations

# All regions
Pinas::Location.regions

# All provinces
Pinas::Location.provinces

# All towns
Pinas::Location.towns

# All barangays
Pinas::Location.barangays

Or you can get sub locations

# get single location
batangas_province = Pinas::Location.where(name: 'BATANGAS').first # returns Batangas Province

# get all towns in Batangas
towns = batangas_province.towns

Get location coordinates

batangas_province.coordinates

Get formatted display

batangas_province.formatted_display

Or you may want to extend the model

class Location < Pinas::Location
end

Caveats

At the moment this gem only supports Ruby >= 1.9.3, Rails 4.x and ActiveRecord compatible storage

TODO

  • Write tests
  • Support other ORM
  • Provide geo-polygons

Contributing

  1. Fork it ( https://github.com/pangkalizer/pinas/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request