phil_locator 1.1.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e978eb880a0edcaa18f658d372ea980b4ca09b0f60db00c940ad0b125ad36e37
4
- data.tar.gz: ff7a612e3f7d8bf60bc0942b0dd8d395027e54efffa0b9eb8793d3f96bb4a1df
3
+ metadata.gz: 7d12c866185b3ac196dd2c202802764a178c7663d15fe084e9e993269579a0fc
4
+ data.tar.gz: d41b0da954548f50efb380e1059ed3fc02a134a4fdf4fdec2ca0b9f8e5dba713
5
5
  SHA512:
6
- metadata.gz: 80e2e04357371c369899fb7c7688ad7180e0e8b703c2e598165f118fdcff7df901190ce4a11f3d88e14ab639f3030ee22fe6c671af7bbdcb341bfa1a2bfe2ea2
7
- data.tar.gz: 669289327aabc13114fbcb2f31686ee9c6e1c10b63fa765c2ccc9311267c7aeeba22d7084b496e248fd32b8aa38343fff0ff2017ba7cf372500f87aa1319264e
6
+ metadata.gz: 936dd12ab5f7cd65acee6c9b45f7c08184d6e6d6a906ef0b0cdfa7c98bea147d8dc2ee51457a4b016b036936a3d451aed24ee763422c7fe4162937f6b1739307
7
+ data.tar.gz: 8b9db0d51dee215b70bade15c1e09df50502342cbcf4bd72b6233f99fd14f164666aac01dc1a97a0264ec15b132c9641962fe93189c9b5b81bf6ccf9a56e9aa3
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Phil Locator
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/phil_locator.svg)](https://badge.fury.io/rb/phil_locator)
4
+
3
5
  ## Build Status
4
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/9cc2694e0d4b21080edc/maintainability)](https://codeclimate.com/github/tenshiAMD/phil_locator/maintainability)
5
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/9cc2694e0d4b21080edc/test_coverage)](https://codeclimate.com/github/tenshiAMD/phil_locator/test_coverage)
@@ -11,12 +13,12 @@ Provides registry records for `regions`, `cities`, `provinces`, and `barangays`
11
13
 
12
14
  In Gemfile:
13
15
  ```
14
- gem "phil_locator", "~> 1.1.0"
16
+ gem "phil_locator", "~> 1.2.0"
15
17
  ```
16
18
 
17
19
  Or, from the command line:
18
20
  ```
19
- gem install phil_locator -v "~> 1.1.0"
21
+ gem install phil_locator -v "~> 1.2.0"
20
22
  ```
21
23
 
22
24
  ## Usage
@@ -35,6 +37,17 @@ PhilLocator::City.all
35
37
  PhilLocator::Barangay.all
36
38
  ```
37
39
 
40
+ ## Configuration
41
+
42
+ Create an initializer `phil_locator.rb` to configure the options, here's a sample provided below
43
+
44
+ ```
45
+ PhilLocator.configure do |config|
46
+ # This overrides the default data directory
47
+ config.data_root_path = Rails.root.join("data").to_s
48
+ end
49
+ ```
50
+
38
51
  ## Copyright
39
52
 
40
53
  Copyright (c) 2019 Angel Aviel Domaoan, released under the [MIT license](/LICENSE).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -2,7 +2,7 @@ module PhilLocator
2
2
  class Barangay < ActiveYaml::Base
3
3
  include ActiveHash::Associations
4
4
 
5
- set_root_path [Gem.loaded_specs[self.module_parent.to_s.underscore].full_gem_path, "data"].join("/")
5
+ set_root_path self.module_parent.data_root_path
6
6
  set_filename "barangays"
7
7
 
8
8
  belongs_to :city, class_name: "PhilLocator::City", foreign_key: :city_code, primary_key: :code
@@ -2,7 +2,7 @@ module PhilLocator
2
2
  class City < ActiveYaml::Base
3
3
  include ActiveHash::Associations
4
4
 
5
- set_root_path [Gem.loaded_specs[self.module_parent.to_s.underscore].full_gem_path, "data"].join("/")
5
+ set_root_path self.module_parent.data_root_path
6
6
  set_filename "cities"
7
7
 
8
8
  belongs_to :province, class_name: "PhilLocator::Province", foreign_key: :province_code, primary_key: :code
@@ -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[self.module_parent.to_s.underscore].full_gem_path, "data"].join("/")
5
+ set_root_path self.module_parent.data_root_path
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[self.module_parent.to_s.underscore].full_gem_path, "data"].join("/")
5
+ set_root_path self.module_parent.data_root_path
6
6
  set_filename "regions"
7
7
 
8
8
  has_many :provinces, class_name: "PhilLocator::Province", foreign_key: :region_code, primary_key: :code
@@ -0,0 +1,9 @@
1
+ module PhilLocator
2
+ class Configuration
3
+ attr_accessor :data_root_path
4
+
5
+ def initialize
6
+ @data_root_path = [PhilLocator.gem_full_path, "data"].join("/")
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,6 @@
1
1
  require_relative "gem_version"
2
2
 
3
3
  module PhilLocator
4
- # Returns the version of the currently loaded Active Job as a <tt>Gem::Version</tt>
5
4
  def self.version
6
5
  gem_version
7
6
  end
data/lib/phil_locator.rb CHANGED
@@ -1,9 +1,34 @@
1
1
  require "active_hash"
2
2
 
3
+ require "phil_locator/configuration"
3
4
  require "phil_locator/version"
4
5
 
5
6
  module PhilLocator
6
7
  extend ActiveSupport::Autoload
8
+
9
+ mattr_writer :configuration
10
+
11
+ def self.configuration
12
+ @configuration ||= PhilLocator::Configuration.new
13
+ end
14
+
15
+ def self.configure
16
+ yield configuration if block_given?
17
+ end
18
+
19
+ def self.data_root_path
20
+ raise "`#{name}.data_root_path` MUST be a String object." unless configuration.data_root_path.is_a?(String)
21
+
22
+ configuration.data_root_path
23
+ end
24
+
25
+ def self.gem_full_path
26
+ Gem.loaded_specs[gem_name].full_gem_path
27
+ end
28
+
29
+ def self.gem_name
30
+ name.underscore
31
+ end
7
32
  end
8
33
 
9
34
  require "phil_locator/engine"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phil_locator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angel Aviel Domaoan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-18 00:00:00.000000000 Z
11
+ date: 2019-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_hash
@@ -47,6 +47,7 @@ files:
47
47
  - data/provinces.yml
48
48
  - data/regions.yml
49
49
  - lib/phil_locator.rb
50
+ - lib/phil_locator/configuration.rb
50
51
  - lib/phil_locator/engine.rb
51
52
  - lib/phil_locator/gem_version.rb
52
53
  - lib/phil_locator/version.rb
@@ -56,7 +57,7 @@ licenses:
56
57
  - MIT
57
58
  metadata:
58
59
  bug_tracker_uri: https://github.com/tenshiAMD/phil_locator/issues
59
- source_code_uri: https://github.com/tenshiAMD/phil_locator/tree/v1.1.0
60
+ source_code_uri: https://github.com/tenshiAMD/phil_locator/tree/v1.2.0
60
61
  post_install_message:
61
62
  rdoc_options: []
62
63
  require_paths: