phil_locator 1.0.0.pre

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9fc9edda45f27453501335ae18fcecdaad7c0c9cac9f209d1e408e776b20d9b3
4
+ data.tar.gz: cec5bf8cb2c62fb742a5b44e7139103e137c35998d87cabd37e9ae7ea4106a44
5
+ SHA512:
6
+ metadata.gz: b2fc4f2fb9c957ef4a496e97ca763247ade7633c6962957e8db20705ee747a0ed1d9623b3738ca19cd61b12cb55866cd9b6be12e9077ace514834f81c7a1479e
7
+ data.tar.gz: 5140ac14c41b7ee1929546040bd12d8225ce07ba4bd3724bc276b710b8e9da5323f42e7f540afa22a4194cf5c48bf5222ddc3989fbdf9cef701156eb0e5b1800
data/.codeclimate.yml ADDED
@@ -0,0 +1,37 @@
1
+ version: '2'
2
+
3
+ checks:
4
+ argument-count:
5
+ enabled: false
6
+ complex-logic:
7
+ enabled: false
8
+ file-lines:
9
+ enabled: false
10
+ method-complexity:
11
+ enabled: false
12
+ method-count:
13
+ enabled: false
14
+ method-lines:
15
+ enabled: false
16
+ nested-control-flow:
17
+ enabled: false
18
+ return-statements:
19
+ enabled: false
20
+ similar-code:
21
+ enabled: false
22
+ identical-code:
23
+ enabled: false
24
+
25
+ plugins:
26
+ brakeman:
27
+ enabled: true
28
+ bundler-audit:
29
+ enabled: true
30
+ rubocop:
31
+ enabled: true
32
+ channel: "rubocop-0-74" # See other channels here: https://github.com/codeclimate/codeclimate-rubocop/branches/active
33
+
34
+ prepare:
35
+ fetch:
36
+ - url: 'https://raw.githubusercontent.com/rails/rails/master/.rubocop.yml'
37
+ path: ".rubocop-https---raw-githubusercontent-com-rails-rails-master--rubocop-yml"
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .idea
2
+ .DS_Store
3
+
4
+ .rubocop-*
5
+
6
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rails
4
+
5
+ inherit_from:
6
+ - 'https://raw.githubusercontent.com/rails/rails/master/.rubocop.yml'
7
+
8
+ AllCops:
9
+ TargetRubyVersion: 2.6
10
+
11
+ Style/FrozenStringLiteralComment:
12
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+ gemspec
9
+
10
+ group :development, :test do
11
+ gem "rubocop", ">= 0.74.0", require: false
12
+ gem "rubocop-junit-formatter"
13
+ gem "rubocop-performance", require: false
14
+ gem "rubocop-rails", "~> 2.0.1", require: false
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ phil_locator (1.0.0)
5
+ active_hash (~> 2.3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ active_hash (2.3.0)
11
+ activesupport (>= 5.0.0)
12
+ activesupport (5.2.3)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 0.7, < 2)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ ast (2.4.0)
18
+ concurrent-ruby (1.1.5)
19
+ i18n (1.7.0)
20
+ concurrent-ruby (~> 1.0)
21
+ jaro_winkler (1.5.3)
22
+ minitest (5.12.2)
23
+ parallel (1.18.0)
24
+ parser (2.6.5.0)
25
+ ast (~> 2.4.0)
26
+ rack (2.0.7)
27
+ rainbow (3.0.0)
28
+ rubocop (0.74.0)
29
+ jaro_winkler (~> 1.5.1)
30
+ parallel (~> 1.10)
31
+ parser (>= 2.6)
32
+ rainbow (>= 2.2.2, < 4.0)
33
+ ruby-progressbar (~> 1.7)
34
+ unicode-display_width (>= 1.4.0, < 1.7)
35
+ rubocop-junit-formatter (0.1.4)
36
+ rubocop-performance (1.5.0)
37
+ rubocop (>= 0.71.0)
38
+ rubocop-rails (2.0.1)
39
+ rack (>= 1.1)
40
+ rubocop (>= 0.70.0)
41
+ ruby-progressbar (1.10.1)
42
+ thread_safe (0.3.6)
43
+ tzinfo (1.2.5)
44
+ thread_safe (~> 0.1)
45
+ unicode-display_width (1.6.0)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ phil_locator!
52
+ rubocop (>= 0.74.0)
53
+ rubocop-junit-formatter
54
+ rubocop-performance
55
+ rubocop-rails (~> 2.0.1)
56
+
57
+ BUNDLED WITH
58
+ 1.17.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Angel Aviel Domaoan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Phil Locator
2
+
3
+ ## Build Status
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/9cc2694e0d4b21080edc/maintainability)](https://codeclimate.com/github/tenshiAMD/phil_locator/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/9cc2694e0d4b21080edc/test_coverage)](https://codeclimate.com/github/tenshiAMD/phil_locator/test_coverage)
6
+
7
+ ## Description
8
+ Provides registry records for `regions`, `cities`, and `provinces` in the Philippines.
9
+
10
+ ## Installation
11
+
12
+ In Gemfile:
13
+ ```
14
+ gem "phil_locator", "~> 1.0.0"
15
+ ```
16
+
17
+ Or, from the command line:
18
+ ```
19
+ gem install phil_locator -v "~> 1.0.0"
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```
25
+ # Regions
26
+ PhilLocator::Region.all
27
+
28
+ # Provinces
29
+ PhilLocator::Province.all
30
+
31
+ # Cities
32
+ PhilLocator::City.all
33
+ ```
34
+
35
+ ## Copyright
36
+
37
+ Copyright (c) 2019 Angel Aviel Domaoan, released under the [MIT license](/LICENSE).
File without changes
@@ -0,0 +1,19 @@
1
+ module PhilLocator
2
+ class City < ActiveYaml::Base
3
+ include ActiveHash::Associations
4
+
5
+ set_root_path [Gem.loaded_specs["phil_locator"].full_gem_path, "data"].join("/")
6
+ set_filename "cities"
7
+
8
+ belongs_to :region, class_name: "PhilLocator::Region", foreign_key: :region_code, primary_key: :code
9
+ belongs_to :province, class_name: "PhilLocator::Province", foreign_key: :province_code, primary_key: :code
10
+
11
+ def psgcCode
12
+ code.ljust(9, "0")
13
+ end
14
+
15
+ def region_code
16
+ self[:region_code].rjust(2, "0")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ module PhilLocator
2
+ class Province < ActiveYaml::Base
3
+ include ActiveHash::Associations
4
+
5
+ set_root_path [Gem.loaded_specs["phil_locator"].full_gem_path, "data"].join("/")
6
+ set_filename "provinces"
7
+
8
+ belongs_to :region, class_name: "PhilLocator::Region", foreign_key: :region_code, primary_key: :code
9
+
10
+ has_many :cities, class_name: "PhilLocator::City", foreign_key: :province_code, primary_key: :code
11
+
12
+ def psgcCode
13
+ code.ljust(9, "0")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module PhilLocator
2
+ class Region < ActiveYaml::Base
3
+ include ActiveHash::Associations
4
+
5
+ set_root_path [Gem.loaded_specs["phil_locator"].full_gem_path, "data"].join("/")
6
+ set_filename "regions"
7
+
8
+ has_many :provinces, class_name: "PhilLocator::Province", foreign_key: :region_code, primary_key: :code
9
+
10
+ def cities
11
+ PhilLocator::City.where(region_code: code.to_i.to_s)
12
+ end
13
+
14
+ def psgcCode
15
+ code.ljust(9, "0")
16
+ end
17
+ end
18
+ end