unidom-geo 1.4.4 → 1.4.5
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/README.md +27 -9
- data/app/controllers/unidom/geo/application_controller.rb +3 -0
- data/app/jobs/unidom/geo/application_job.rb +3 -0
- data/app/mailers/unidom/geo/application_mailer.rb +3 -0
- data/app/models/unidom/geo/application_record.rb +3 -0
- data/app/models/unidom/geo/concerns/as_located.rb +8 -0
- data/app/models/unidom/geo/locating.rb +1 -1
- data/app/models/unidom/geo/location.rb +1 -1
- data/lib/unidom/geo/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec75e08c0307987c1cacab5fea9dbf31588fcd50
|
4
|
+
data.tar.gz: b86578703813ca367aad0f47f46023b2661e2c4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6234b6e1cf61e8437a1bde7ff3c270bc62d3665fcbf47e3259deef7dee7be212cd35620ab528993b19a982251cb4c7ae31b62b56ef8dee333a778e1bcc7557d2
|
7
|
+
data.tar.gz: 375120d30f4cc6941e003b389516ec8041529d6097063c579fc39fb26a0fc0503052608f39ae900da2d3289cf4d73b6ec70aa29f6ed38bda0d95ef7a5b5feca4
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Unidom Geo 地理领域模型引擎
|
2
2
|
|
3
|
+
[](http://www.rubydoc.info/gems/unidom-geo/frames)
|
3
4
|
[](http://opensource.org/licenses/MIT)
|
5
|
+
|
4
6
|
[](https://badge.fury.io/rb/unidom-geo)
|
5
7
|
[](https://gemnasium.com/github.com/topbitdu/unidom-geo)
|
6
8
|
|
@@ -61,21 +63,37 @@ include Unidom::Geo::Concerns::AsRegion
|
|
61
63
|
|
62
64
|
### As Located concern
|
63
65
|
|
64
|
-
The As Located concern do the following tasks for the includer automatically:
|
65
|
-
1. Define the has_many :locatings macro as: ``has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :located``
|
66
|
-
2. Define the has_many :locations macro as: ``has_many :locations, through: :locatings, source: :location``
|
67
|
-
3. Define the #is_located! method as: ``is_located!(to: nil, by: nil, at: Time.now)``
|
66
|
+
The As Located concern do the following tasks for the includer automatically:
|
67
|
+
1. Define the has_many :locatings macro as: ``has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :located``
|
68
|
+
2. Define the has_many :locations macro as: ``has_many :locations, through: :locatings, source: :location``
|
69
|
+
3. Define the #is_located! method as: ``is_located!(to: nil, by: nil, at: Time.now)``
|
68
70
|
4. Define the #is_located? method as: ``is_located?(to: nil, at: Time.now)``
|
69
71
|
|
70
72
|
### As Locator concern
|
71
73
|
|
72
|
-
The As Locator concern do the following tasks for the includer automatically:
|
73
|
-
1. Define the has_many :locatings macro as: ``has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :locator``
|
74
|
-
2. Define the has_many :locations macro as: ``has_many :locations, through: :locatings, source: :location``
|
74
|
+
The As Locator concern do the following tasks for the includer automatically:
|
75
|
+
1. Define the has_many :locatings macro as: ``has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :locator``
|
76
|
+
2. Define the has_many :locations macro as: ``has_many :locations, through: :locatings, source: :location``
|
75
77
|
3. Define the #locate! method as: ``locate!(it, to: nil, at: Time.now)``
|
76
78
|
|
77
79
|
### As Region concern
|
78
80
|
|
79
|
-
The As Region concern do the following tasks for the includer automatically:
|
80
|
-
1. Define the has_many :locations macro as: ``has_many :locations, class_name: 'Unidom::Geo::Location'``
|
81
|
+
The As Region concern do the following tasks for the includer automatically:
|
82
|
+
1. Define the has_many :locations macro as: ``has_many :locations, class_name: 'Unidom::Geo::Location'``
|
81
83
|
2. Define the has_many :locatings macro as: ``has_many :locatings, through: :locations, source: :locatings``
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
## Disable the Model & Migration
|
88
|
+
|
89
|
+
If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
|
90
|
+
```ruby
|
91
|
+
# config/initializers/unidom.rb
|
92
|
+
Unidom::Common.configure do |options|
|
93
|
+
|
94
|
+
options[:neglected_namespaces] = %w{
|
95
|
+
Unidom::Geo
|
96
|
+
}
|
97
|
+
|
98
|
+
end
|
99
|
+
```
|
@@ -10,10 +10,18 @@ module Unidom::Geo::Concerns::AsLocated
|
|
10
10
|
has_many :locatings, class_name: 'Unidom::Geo::Locating', as: :located
|
11
11
|
has_many :locations, through: :locatings, source: :location
|
12
12
|
|
13
|
+
##
|
14
|
+
# 将当前位置与地标 to 关联起来。如:
|
15
|
+
# location = Unidom::Geo::Location.first
|
16
|
+
# shop.is_located! to: location, by: current_person
|
13
17
|
def is_located!(to: nil, by: nil, at: Time.now)
|
14
18
|
locatings.location_is(to).valid_at(now: at).alive.first_or_create! locator: by, opened_at: at
|
15
19
|
end
|
16
20
|
|
21
|
+
##
|
22
|
+
# 检查当前位置与地标 to 在指定的时间 at (缺省是当前时间)是否关联起来了。
|
23
|
+
# location = Unidom::Geo::Location.first
|
24
|
+
# 如: shop.is_located? to: location, at: Time.now
|
17
25
|
def is_located?(to: nil, at: Time.now)
|
18
26
|
locatings.location_is(to).valid_at(now: at).alive.exists?
|
19
27
|
end
|
data/lib/unidom/geo/version.rb
CHANGED
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.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.9'
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
28
28
|
The Geo domain model engine includes Region, Town, and Location models. Unidom (统一领域对象模型)是一系列的领域模型引擎。地理领域模型引擎包括行政区划、乡镇和街道地址的模型。
|
29
29
|
email:
|