phil_locator 1.0.0.pre → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9fc9edda45f27453501335ae18fcecdaad7c0c9cac9f209d1e408e776b20d9b3
4
- data.tar.gz: cec5bf8cb2c62fb742a5b44e7139103e137c35998d87cabd37e9ae7ea4106a44
3
+ metadata.gz: e978eb880a0edcaa18f658d372ea980b4ca09b0f60db00c940ad0b125ad36e37
4
+ data.tar.gz: ff7a612e3f7d8bf60bc0942b0dd8d395027e54efffa0b9eb8793d3f96bb4a1df
5
5
  SHA512:
6
- metadata.gz: b2fc4f2fb9c957ef4a496e97ca763247ade7633c6962957e8db20705ee747a0ed1d9623b3738ca19cd61b12cb55866cd9b6be12e9077ace514834f81c7a1479e
7
- data.tar.gz: 5140ac14c41b7ee1929546040bd12d8225ce07ba4bd3724bc276b710b8e9da5323f42e7f540afa22a4194cf5c48bf5222ddc3989fbdf9cef701156eb0e5b1800
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
@@ -4,3 +4,4 @@
4
4
  .rubocop-*
5
5
 
6
6
  *.gem
7
+ Gemfile.lock
data/README.md CHANGED
@@ -5,18 +5,18 @@
5
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/9cc2694e0d4b21080edc/test_coverage)](https://codeclimate.com/github/tenshiAMD/phil_locator/test_coverage)
6
6
 
7
7
  ## Description
8
- Provides registry records for `regions`, `cities`, and `provinces` in the Philippines.
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.0.0"
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.0.0"
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["phil_locator"].full_gem_path, "data"].join("/")
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 region_code
16
- self[:region_code].rjust(2, "0")
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["phil_locator"].full_gem_path, "data"].join("/")
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["phil_locator"].full_gem_path, "data"].join("/")
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