phil_locator 1.0.0.pre → 1.1.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/.codeclimate.yml +0 -4
- data/.gitignore +1 -0
- data/README.md +6 -3
- data/VERSION +1 -0
- data/app/models/phil_locator/barangay.rb +30 -0
- data/app/models/phil_locator/city.rb +5 -4
- data/app/models/phil_locator/province.rb +1 -1
- data/app/models/phil_locator/region.rb +1 -1
- data/data/barangays.yml +210146 -0
- data/data/cities.yml +76 -1723
- data/lib/phil_locator/gem_version.rb +16 -0
- data/lib/phil_locator/version.rb +8 -0
- data/lib/phil_locator.rb +2 -2
- data/phil_locator.gemspec +11 -5
- metadata +12 -6
- data/Gemfile.lock +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e978eb880a0edcaa18f658d372ea980b4ca09b0f60db00c940ad0b125ad36e37
|
4
|
+
data.tar.gz: ff7a612e3f7d8bf60bc0942b0dd8d395027e54efffa0b9eb8793d3f96bb4a1df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e2e04357371c369899fb7c7688ad7180e0e8b703c2e598165f118fdcff7df901190ce4a11f3d88e14ab639f3030ee22fe6c671af7bbdcb341bfa1a2bfe2ea2
|
7
|
+
data.tar.gz: 669289327aabc13114fbcb2f31686ee9c6e1c10b63fa765c2ccc9311267c7aeeba22d7084b496e248fd32b8aa38343fff0ff2017ba7cf372500f87aa1319264e
|
data/.codeclimate.yml
CHANGED
@@ -23,10 +23,6 @@ checks:
|
|
23
23
|
enabled: false
|
24
24
|
|
25
25
|
plugins:
|
26
|
-
brakeman:
|
27
|
-
enabled: true
|
28
|
-
bundler-audit:
|
29
|
-
enabled: true
|
30
26
|
rubocop:
|
31
27
|
enabled: true
|
32
28
|
channel: "rubocop-0-74" # See other channels here: https://github.com/codeclimate/codeclimate-rubocop/branches/active
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -5,18 +5,18 @@
|
|
5
5
|
[](https://codeclimate.com/github/tenshiAMD/phil_locator/test_coverage)
|
6
6
|
|
7
7
|
## Description
|
8
|
-
Provides registry records for `regions`, `cities`, and `
|
8
|
+
Provides registry records for `regions`, `cities`, `provinces`, and `barangays` in the Philippines.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
12
|
In Gemfile:
|
13
13
|
```
|
14
|
-
gem "phil_locator", "~> 1.
|
14
|
+
gem "phil_locator", "~> 1.1.0"
|
15
15
|
```
|
16
16
|
|
17
17
|
Or, from the command line:
|
18
18
|
```
|
19
|
-
gem install phil_locator -v "~> 1.
|
19
|
+
gem install phil_locator -v "~> 1.1.0"
|
20
20
|
```
|
21
21
|
|
22
22
|
## Usage
|
@@ -30,6 +30,9 @@ PhilLocator::Province.all
|
|
30
30
|
|
31
31
|
# Cities
|
32
32
|
PhilLocator::City.all
|
33
|
+
|
34
|
+
# Barangays
|
35
|
+
PhilLocator::Barangay.all
|
33
36
|
```
|
34
37
|
|
35
38
|
## Copyright
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module PhilLocator
|
2
|
+
class Barangay < ActiveYaml::Base
|
3
|
+
include ActiveHash::Associations
|
4
|
+
|
5
|
+
set_root_path [Gem.loaded_specs[self.module_parent.to_s.underscore].full_gem_path, "data"].join("/")
|
6
|
+
set_filename "barangays"
|
7
|
+
|
8
|
+
belongs_to :city, class_name: "PhilLocator::City", foreign_key: :city_code, primary_key: :code
|
9
|
+
|
10
|
+
def cities
|
11
|
+
PhilLocator::City.where(region_code: code.to_i.to_s)
|
12
|
+
end
|
13
|
+
|
14
|
+
def province
|
15
|
+
return if city.blank?
|
16
|
+
|
17
|
+
city.province
|
18
|
+
end
|
19
|
+
|
20
|
+
def psgcCode
|
21
|
+
code.ljust(9, "0")
|
22
|
+
end
|
23
|
+
|
24
|
+
def region
|
25
|
+
return if province.blank?
|
26
|
+
|
27
|
+
province.region
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -2,18 +2,19 @@ module PhilLocator
|
|
2
2
|
class City < ActiveYaml::Base
|
3
3
|
include ActiveHash::Associations
|
4
4
|
|
5
|
-
set_root_path [Gem.loaded_specs[
|
5
|
+
set_root_path [Gem.loaded_specs[self.module_parent.to_s.underscore].full_gem_path, "data"].join("/")
|
6
6
|
set_filename "cities"
|
7
7
|
|
8
|
-
belongs_to :region, class_name: "PhilLocator::Region", foreign_key: :region_code, primary_key: :code
|
9
8
|
belongs_to :province, class_name: "PhilLocator::Province", foreign_key: :province_code, primary_key: :code
|
10
9
|
|
11
10
|
def psgcCode
|
12
11
|
code.ljust(9, "0")
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
16
|
-
|
14
|
+
def region
|
15
|
+
return if province.blank?
|
16
|
+
|
17
|
+
province.region
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -2,7 +2,7 @@ module PhilLocator
|
|
2
2
|
class Province < ActiveYaml::Base
|
3
3
|
include ActiveHash::Associations
|
4
4
|
|
5
|
-
set_root_path [Gem.loaded_specs[
|
5
|
+
set_root_path [Gem.loaded_specs[self.module_parent.to_s.underscore].full_gem_path, "data"].join("/")
|
6
6
|
set_filename "provinces"
|
7
7
|
|
8
8
|
belongs_to :region, class_name: "PhilLocator::Region", foreign_key: :region_code, primary_key: :code
|
@@ -2,7 +2,7 @@ module PhilLocator
|
|
2
2
|
class Region < ActiveYaml::Base
|
3
3
|
include ActiveHash::Associations
|
4
4
|
|
5
|
-
set_root_path [Gem.loaded_specs[
|
5
|
+
set_root_path [Gem.loaded_specs[self.module_parent.to_s.underscore].full_gem_path, "data"].join("/")
|
6
6
|
set_filename "regions"
|
7
7
|
|
8
8
|
has_many :provinces, class_name: "PhilLocator::Province", foreign_key: :region_code, primary_key: :code
|