pinas 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +12 -0
- data/README.md +39 -14
- data/lib/generators/templates/README +2 -1
- data/lib/generators/templates/migration.rb +1 -1
- data/lib/pinas/data/data.yml +612911 -0
- data/lib/pinas/version.rb +1 -1
- data/lib/tasks/pinas_tasks.rake +7 -5
- data/philippines.png +0 -0
- data/pinas.gemspec +2 -1
- metadata +20 -4
- data/lib/pinas/data/locations.sql +0 -45131
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f3e0589de892a856a621dab3247b245fa0c72c2
|
4
|
+
data.tar.gz: fb51bfa96a76568878edbefd459e1c0d8f3b20d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f839829bd90ca9c479531ceec0884f4f034c6c34957ecfeba598a44a4b22a44343bb7cfc55d48f4f633679abe2d37e490a4d176b792d0a8cf65a31f8abce5e4f
|
7
|
+
data.tar.gz: 926674ff93cb19e2c609332843c235085c3eda39f2d20347798f2d58b21cf60d431c39e0b08091b11a1b61e17f6f4fdbe8faa9281a56079e0b85d127e57fbefd
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Pinas
|
2
2
|
|
3
|
-
|
3
|
+
[](http://badge.fury.io/rb/pinas)
|
4
|
+
[](https://travis-ci.org/pangkalizer/pinas)
|
5
|
+
|
6
|
+
 This gem provides hierarchical listing of Philippine location.
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
@@ -28,28 +31,50 @@ Or install it yourself as:
|
|
28
31
|
|
29
32
|
The gem provides ActiveRecord model `Pinas::Location` in 4 levels of locations
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
# All regions
|
35
|
+
Pinas::Location.regions
|
33
36
|
|
34
|
-
|
35
|
-
|
37
|
+
# All provinces
|
38
|
+
Pinas::Location.provinces
|
36
39
|
|
37
|
-
|
38
|
-
|
40
|
+
# All towns
|
41
|
+
Pinas::Location.towns
|
39
42
|
|
40
|
-
|
41
|
-
|
43
|
+
# All barangays
|
44
|
+
Pinas::Location.barangays
|
42
45
|
|
43
46
|
Or you can get sub locations
|
44
|
-
|
45
|
-
|
47
|
+
|
48
|
+
# get single location
|
49
|
+
batangas_province = Pinas::Location.where(name: 'BATANGAS').first # returns Batangas Province
|
46
50
|
|
47
|
-
|
48
|
-
|
51
|
+
# get all towns in Batangas
|
52
|
+
towns = batangas_province.towns
|
53
|
+
|
54
|
+
Get location coordinates
|
55
|
+
|
56
|
+
batangas_province.coordinates
|
57
|
+
|
58
|
+
Get formatted display
|
59
|
+
|
60
|
+
batangas_province.formatted_display
|
61
|
+
|
62
|
+
Or you may want to extend the model
|
63
|
+
|
64
|
+
class Location < Pinas::Location
|
65
|
+
end
|
66
|
+
|
49
67
|
|
50
68
|
## Caveats
|
51
69
|
|
52
|
-
At the moment this gem supports Rails 4.x
|
70
|
+
At the moment this gem only supports Ruby >= 1.9.3, Rails 4.x and Mysql adapter
|
71
|
+
|
72
|
+
|
73
|
+
## TODO
|
74
|
+
|
75
|
+
* Write tests
|
76
|
+
* Support other ORM
|
77
|
+
* Provide geo-polygons
|
53
78
|
|
54
79
|
|
55
80
|
## Contributing
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
|
@@ -14,7 +14,7 @@ class CreatePinasTables < ActiveRecord::Migration
|
|
14
14
|
t.string :postcode
|
15
15
|
t.string :longitude
|
16
16
|
t.string :latitude
|
17
|
-
t.timestamps null: false
|
17
|
+
t.timestamps null: false, default: Time.now
|
18
18
|
end
|
19
19
|
add_index :locations, :parent_id
|
20
20
|
add_index :locations, :postcode
|