unidom-geo 1.2 → 1.3

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
  SHA1:
3
- metadata.gz: 4d804f7b473b75141cb773b78046619750b7d4c6
4
- data.tar.gz: ea65c588897d92dea09f9832a6d3bad8abbd653c
3
+ metadata.gz: 45957405107d6cfc8b05b70870e5ab3ca60cb698
4
+ data.tar.gz: 02198793be1f7c86e96a8a528421c1075e566dd6
5
5
  SHA512:
6
- metadata.gz: df39c01b430a9c26d7e5da6d7d9a3d8e8ceb856088b889a3ed1e1a978d7ea320bbf7d76ef34214f5055156b33c84e25246200dc143cab98d7a191be32bf8b895
7
- data.tar.gz: 7844ceb083e5ce0194983aa0d3746a573732e91f0d750fa283985f192b1c2dd46f9cc6f2dd309a97b6ed4e8cff50741b549a942e06d56b7dcf5d93f893ce2e46
6
+ metadata.gz: bc95936a4854c65376e68551a9cd9d01e5fc7fe59a784a321b50bf48fe933bee86af029b53f3bff5b7ba42aa82f1689960f6541231749eb8338fc5a2acc8e19c
7
+ data.tar.gz: ba8a25a4e547244f893d9ef18b7ced35ed192dee371c5b81c5808ce082fbbd7243455cab215abd1926689efb9e556bfa51f244fd3964e38747e435f532ba722b
data/README.md CHANGED
@@ -6,22 +6,34 @@
6
6
  Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Geo domain model engine includes Town and Location models.
7
7
  Unidom (统一领域对象模型)是一系列的领域模型引擎。地理领域模型引擎包括乡镇和街道地址的模型。
8
8
 
9
+
10
+
9
11
  ## Recent Update
12
+
10
13
  Check out the [Road Map](ROADMAP.md) to find out what's the next.
11
14
  Check out the [Change Log](CHANGELOG.md) to find out what's new.
12
15
 
16
+
17
+
13
18
  ## Usage in Gemfile:
19
+
14
20
  ```ruby
15
21
  gem 'unidom-geo'
16
22
  ```
17
23
 
24
+
25
+
18
26
  ## Run the Database Migration:
27
+
19
28
  ```shell
20
29
  rake db:migrate
21
30
  ```
22
31
  The migration versions start with 200104.
23
32
 
33
+
34
+
24
35
  ## Call the Model:
36
+
25
37
  ```ruby
26
38
  Unidom::Geo::Location.valid_at.alive.first.region
27
39
 
@@ -36,19 +48,29 @@ Unidom::Geo::Locating.locate! location: location, located: shop
36
48
  location.locate? shop, at: Time.now
37
49
  ```
38
50
 
51
+
52
+
39
53
  ## Include the Concerns:
54
+
40
55
  ```ruby
41
56
  include Unidom::Geo::Concerns::AsLocated
57
+ include Unidom::Geo::Concerns::AsLocator
42
58
  include Unidom::Geo::Concerns::AsRegion
43
59
  ```
44
60
 
45
61
  ### As Located concern
46
62
  The As Located concern do the following tasks for the includer automatically:
47
- 1. Define the has_many :locatings macro as: ``has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :located``
48
- 2. Define the has_many :locations macro as: ``has_many :locations, through: :locatings, source: :location``
49
- 3. Define the #is_located! method as: ``is_located!(to: nil, by: nil, at: Time.now)``
63
+ 1. Define the has_many :locatings macro as: ``has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :located``
64
+ 2. Define the has_many :locations macro as: ``has_many :locations, through: :locatings, source: :location``
65
+ 3. Define the #is_located! method as: ``is_located!(to: nil, by: nil, at: Time.now)``
66
+ 4. Define the #is_located? method as: ``is_located?(to: nil, at: Time.now)``
67
+
68
+ ### As Locator concern
69
+ The As Locator concern do the following tasks for the includer automatically:
70
+ 1. Define the has_many :locatings macro as: ``has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :locator``
71
+ 2. Define the has_many :locations macro as: ``has_many :locations, through: :locatings, source: :location``
50
72
 
51
73
  ### As Region concern
52
74
  The As Region concern do the following tasks for the includer automatically:
53
- 1. Define the has_many :locations macro as: ``has_many :locations, class_name: 'Unidom::Geo::Location'``
75
+ 1. Define the has_many :locations macro as: ``has_many :locations, class_name: 'Unidom::Geo::Location'``
54
76
  2. Define the has_many :locatings macro as: ``has_many :locatings, through: :locations, source: :locatings``
@@ -11,6 +11,10 @@ module Unidom::Geo::Concerns::AsLocated
11
11
  locatings.location_is(to).valid_at(now: at).alive.first_or_create! locator: by, opened_at: at
12
12
  end
13
13
 
14
+ def is_located?(to: nil, at: Time.now)
15
+ locatings.location_is(to).valid_at(now: at).alive.exists?
16
+ end
17
+
14
18
  end
15
19
 
16
20
  module ClassMethods
@@ -0,0 +1,25 @@
1
+ module Unidom::Geo::Concerns::AsLocator
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :locator
8
+ has_many :locations, through: :locatings, source: :location
9
+
10
+ =begin
11
+ def locate!(to: nil, by: nil, at: Time.now)
12
+ locatings.location_is(to).valid_at(now: at).alive.first_or_create! locator: by, opened_at: at
13
+ end
14
+
15
+ def locate?(to: nil, at: Time.now)
16
+ locatings.location_is(to).valid_at(now: at).alive.exists?
17
+ end
18
+ =end
19
+
20
+ end
21
+
22
+ module ClassMethods
23
+ end
24
+
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Geo
3
- VERSION = '1.2'.freeze
3
+ VERSION = '1.3'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-geo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -40,6 +40,7 @@ files:
40
40
  - app/controllers/unidom/geo/application_controller.rb
41
41
  - app/helpers/unidom/geo/application_helper.rb
42
42
  - app/models/unidom/geo/concerns/as_located.rb
43
+ - app/models/unidom/geo/concerns/as_locator.rb
43
44
  - app/models/unidom/geo/concerns/as_region.rb
44
45
  - app/models/unidom/geo/locating.rb
45
46
  - app/models/unidom/geo/location.rb