unidom-geo 1.5.7 → 2.0.1
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 +5 -5
- data/README.md +24 -0
- data/app/models/unidom/geo/concerns/as_locator.rb +6 -0
- data/db/migrate/20010401000000_create_unidom_locations.rb +4 -4
- data/db/migrate/20010402000000_create_unidom_locatings.rb +5 -5
- data/lib/rspec/models/unidom/geo/concerns/as_locator_shared_examples.rb +39 -0
- data/lib/unidom/geo/rspec_shared_examples.rb +1 -0
- data/lib/unidom/geo/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8e25f98615ec3a1877be55ce5ed52791f17183ea7015be3fde6cc34b5c53ff85
|
4
|
+
data.tar.gz: 544c24cc4572a0ab12d915cfa87361701fcdc8df0ad9a698c0568419515b7dd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 497a1c2ab5885baa1352b6f32a2c26e44b135f00ad277204c94cb8cc09f14b416942c4add9795b0a2ec4ff5178e1417cfa6660bb0111b714351ccc8f725819d4
|
7
|
+
data.tar.gz: 40dc6aaf39d6eb245eb4f82174790b2fc6b7a1faee8e0f4495d41e3083ab170385fae1563e9a468e733238067385b8390a8ce675b763d7c931477ce0e84df21c
|
data/README.md
CHANGED
@@ -121,6 +121,10 @@ require 'unidom/geo/validators_rspec'
|
|
121
121
|
# lib/unidom.rb
|
122
122
|
def initialize_unidom
|
123
123
|
|
124
|
+
Unidom::Party::Person.class_eval do
|
125
|
+
include Unidom::Geo::Concerns::AsLocator
|
126
|
+
end
|
127
|
+
|
124
128
|
Unidom::Party::Shop.class_eval do
|
125
129
|
include Unidom::Geo::Concerns::AsLocated
|
126
130
|
end
|
@@ -138,6 +142,26 @@ initialize_unidom
|
|
138
142
|
# spec/support/unidom_rspec_shared_examples.rb
|
139
143
|
require 'unidom/geo/rspec_shared_examples'
|
140
144
|
|
145
|
+
# spec/models/unidom/party/person_spec.rb
|
146
|
+
describe Unidom::Party::Person, type: :model do
|
147
|
+
|
148
|
+
context do
|
149
|
+
|
150
|
+
model_attributes = {
|
151
|
+
name: 'Tim'
|
152
|
+
}
|
153
|
+
|
154
|
+
located_attributes = {
|
155
|
+
name: 'Walmart'
|
156
|
+
}
|
157
|
+
located = Unidom::Party::Shop.create! located_attributes
|
158
|
+
|
159
|
+
it_behaves_like 'Unidom::Geo::Concerns::AsLocator', model_attributes, located
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
141
165
|
# spec/models/unidom/party/shop_spec.rb
|
142
166
|
describe Unidom::Party::Shop, type: :model do
|
143
167
|
|
@@ -11,7 +11,13 @@ module Unidom::Geo::Concerns::AsLocator
|
|
11
11
|
has_many :locations, through: :locatings, source: :location
|
12
12
|
|
13
13
|
def locate!(it, to: nil, at: Time.now)
|
14
|
+
|
15
|
+
assert_present! :it, it
|
16
|
+
assert_present! :to, to
|
17
|
+
assert_present! :at, at
|
18
|
+
|
14
19
|
locatings.location_is(to).located_is(it).valid_at(now: at).alive.first_or_create! opened_at: at
|
20
|
+
|
15
21
|
end
|
16
22
|
|
17
23
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateUnidomLocations < ActiveRecord::Migration
|
1
|
+
class CreateUnidomLocations < ActiveRecord::Migration[6.0]
|
2
2
|
|
3
3
|
def change
|
4
4
|
|
@@ -20,9 +20,9 @@ class CreateUnidomLocations < ActiveRecord::Migration
|
|
20
20
|
|
21
21
|
t.column :accuarcy_code, 'char(1)', null: false, default: 'N'
|
22
22
|
|
23
|
-
t.column :state, 'char(1)', null: false, default:
|
24
|
-
t.datetime :opened_at, null: false, default: ::
|
25
|
-
t.datetime :closed_at, null: false, default: ::
|
23
|
+
t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
|
24
|
+
t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
|
25
|
+
t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
|
26
26
|
t.boolean :defunct, null: false, default: false
|
27
27
|
t.jsonb :notation, null: false, default: {}
|
28
28
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateUnidomLocatings < ActiveRecord::Migration
|
1
|
+
class CreateUnidomLocatings < ActiveRecord::Migration[6.0]
|
2
2
|
|
3
3
|
def change
|
4
4
|
|
@@ -10,9 +10,9 @@ class CreateUnidomLocatings < ActiveRecord::Migration
|
|
10
10
|
t.references :locator, type: :uuid, null: false,
|
11
11
|
polymorphic: { null: false, default: '', limit: 200 }
|
12
12
|
|
13
|
-
t.column :state, 'char(1)', null: false, default:
|
14
|
-
t.datetime :opened_at, null: false, default: ::
|
15
|
-
t.datetime :closed_at, null: false, default: ::
|
13
|
+
t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
|
14
|
+
t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
|
15
|
+
t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
|
16
16
|
t.boolean :defunct, null: false, default: false
|
17
17
|
t.jsonb :notation, null: false, default: {}
|
18
18
|
|
@@ -26,4 +26,4 @@ class CreateUnidomLocatings < ActiveRecord::Migration
|
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
|
-
end
|
29
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
shared_examples 'Unidom::Geo::Concerns::AsLocator' do |model_attributes, located|
|
2
|
+
|
3
|
+
context do
|
4
|
+
|
5
|
+
locating_1_attribtues = {
|
6
|
+
location_id: SecureRandom.uuid,
|
7
|
+
located_id: SecureRandom.uuid,
|
8
|
+
located_type: 'Unidom::Geo::Located::Mock'
|
9
|
+
}
|
10
|
+
|
11
|
+
locating_2_attribtues = {
|
12
|
+
location_id: SecureRandom.uuid,
|
13
|
+
located_id: SecureRandom.uuid,
|
14
|
+
located_type: 'Unidom::Geo::Located::Mock'
|
15
|
+
}
|
16
|
+
|
17
|
+
it_behaves_like 'has_many', model_attributes, :locatings, Unidom::Geo::Locating, [ locating_1_attribtues, locating_2_attribtues ]
|
18
|
+
|
19
|
+
model = described_class.create! model_attributes
|
20
|
+
|
21
|
+
location_attributes = {
|
22
|
+
region_id: SecureRandom.uuid,
|
23
|
+
region_type: 'Unidom::Geo::Region::Mock',
|
24
|
+
longitude: 21.000000,
|
25
|
+
latitude: 31.000000,
|
26
|
+
postal_address: 'Some Address',
|
27
|
+
postal_code: '100000',
|
28
|
+
minimum_longitude: 19.900000,
|
29
|
+
minimum_latitude: 30.900000,
|
30
|
+
maximum_longitude: 21.100000,
|
31
|
+
maximum_latitude: 31.100000,
|
32
|
+
}
|
33
|
+
location = Unidom::Geo::Location.first_or_create! location_attributes
|
34
|
+
|
35
|
+
it_behaves_like 'assert_present!', model, :locate!, [ located, { to: location, at: Time.now } ], [ { 0 => :it }, :to, :at ]
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
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:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-30 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: '
|
19
|
+
version: '2.0'
|
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: '
|
26
|
+
version: '2.0'
|
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:
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- db/migrate/20010401000000_create_unidom_locations.rb
|
54
54
|
- db/migrate/20010402000000_create_unidom_locatings.rb
|
55
55
|
- lib/rspec/models/unidom/geo/concerns/as_located_shared_examples.rb
|
56
|
+
- lib/rspec/models/unidom/geo/concerns/as_locator_shared_examples.rb
|
56
57
|
- lib/rspec/models/unidom/geo/concerns/as_region_shared_examples.rb
|
57
58
|
- lib/rspec/models/unidom/geo/locating_spec.rb
|
58
59
|
- lib/rspec/models/unidom/geo/location_spec.rb
|
@@ -68,7 +69,7 @@ homepage: https://github.com/topbitdu/unidom-geo
|
|
68
69
|
licenses:
|
69
70
|
- MIT
|
70
71
|
metadata: {}
|
71
|
-
post_install_message:
|
72
|
+
post_install_message:
|
72
73
|
rdoc_options: []
|
73
74
|
require_paths:
|
74
75
|
- lib
|
@@ -83,9 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
- !ruby/object:Gem::Version
|
84
85
|
version: '0'
|
85
86
|
requirements: []
|
86
|
-
|
87
|
-
|
88
|
-
signing_key:
|
87
|
+
rubygems_version: 3.2.3
|
88
|
+
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Unidom Geo Domain Model Engine 地理领域模型引擎
|
91
91
|
test_files: []
|