unidom-geo 1.5.6 → 1.5.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04091f3b47716f81dabccd033d78edfb71c9e2ea'
|
4
|
+
data.tar.gz: 30d6f758f78fbcddc14fb9bd0e656d6e58fcd27f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61f026168f11f4f82cdb65c5e1c2a3c9312773ccab006ed2dd26499bc5c798fedd439dcb027f4725b47bfa88a6ceb406bf33870d7e79a938ee93586af139801f
|
7
|
+
data.tar.gz: 63ce8db98d6fdfcec255eeeacfb8e533f0a511f95cb349eb5b545eec6cf248d42d1a8e27c8789a1231467cf85dc3c5d23a4af73a3762dfb5d973a785d57d373c
|
data/README.md
CHANGED
@@ -147,7 +147,20 @@ describe Unidom::Party::Shop, type: :model do
|
|
147
147
|
name: 'Some Shop'
|
148
148
|
}
|
149
149
|
|
150
|
-
|
150
|
+
location_attributes = {
|
151
|
+
postal_address: '#1 Some Street',
|
152
|
+
postal_code: '610000',
|
153
|
+
region_id: SecureRandom.uuid,
|
154
|
+
region_type: 'Unidom::Geo::Region::Mock'
|
155
|
+
}
|
156
|
+
location = Unidom::Geo::Location.create! location_attributes
|
157
|
+
|
158
|
+
locator_attributes = {
|
159
|
+
name: 'Tim'
|
160
|
+
}
|
161
|
+
locator = Unidom::Party::Person.create! locator_attributes
|
162
|
+
|
163
|
+
it_behaves_like 'Unidom::Geo::Concerns::AsLocated', model_attributes, location, locator
|
151
164
|
|
152
165
|
end
|
153
166
|
|
@@ -3,7 +3,8 @@
|
|
3
3
|
|
4
4
|
module Unidom::Geo::Concerns::AsLocated
|
5
5
|
|
6
|
-
extend
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
include Unidom::Common::Concerns::ArgumentValidation
|
7
8
|
|
8
9
|
included do |includer|
|
9
10
|
|
@@ -15,7 +16,13 @@ module Unidom::Geo::Concerns::AsLocated
|
|
15
16
|
# location = Unidom::Geo::Location.first
|
16
17
|
# shop.is_located! to: location, by: current_person
|
17
18
|
def is_located!(to: nil, by: nil, at: Time.now)
|
19
|
+
|
20
|
+
assert_present! :to, to
|
21
|
+
assert_present! :by, by
|
22
|
+
assert_present! :at, at
|
23
|
+
|
18
24
|
locatings.location_is(to).valid_at(now: at).alive.first_or_create! locator: by, opened_at: at
|
25
|
+
|
19
26
|
end
|
20
27
|
|
21
28
|
##
|
@@ -23,7 +30,12 @@ module Unidom::Geo::Concerns::AsLocated
|
|
23
30
|
# location = Unidom::Geo::Location.first
|
24
31
|
# 如: shop.is_located? to: location, at: Time.now
|
25
32
|
def is_located?(to: nil, at: Time.now)
|
33
|
+
|
34
|
+
assert_present! :to, to
|
35
|
+
assert_present! :at, at
|
36
|
+
|
26
37
|
locatings.location_is(to).valid_at(now: at).alive.exists?
|
38
|
+
|
27
39
|
end
|
28
40
|
|
29
41
|
end
|
@@ -1,17 +1,26 @@
|
|
1
|
-
shared_examples 'Unidom::Geo::Concerns::AsLocated' do |model_attributes|
|
1
|
+
shared_examples 'Unidom::Geo::Concerns::AsLocated' do |model_attributes, location, locator|
|
2
2
|
|
3
|
-
|
4
|
-
location_id: SecureRandom.uuid,
|
5
|
-
locator_id: SecureRandom.uuid,
|
6
|
-
locator_type: 'Unidom::Geo::Locator::Mock'
|
7
|
-
}
|
3
|
+
context do
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
locating_1_attribtues = {
|
6
|
+
location_id: SecureRandom.uuid,
|
7
|
+
locator_id: SecureRandom.uuid,
|
8
|
+
locator_type: 'Unidom::Geo::Locator::Mock'
|
9
|
+
}
|
14
10
|
|
15
|
-
|
11
|
+
locating_2_attribtues = {
|
12
|
+
location_id: SecureRandom.uuid,
|
13
|
+
locator_id: SecureRandom.uuid,
|
14
|
+
locator_type: 'Unidom::Geo::Locator::Mock'
|
15
|
+
}
|
16
|
+
|
17
|
+
it_behaves_like 'has_many', model_attributes, :locatings, Unidom::Geo::Locating, [ locating_1_attribtues, locating_2_attribtues ]
|
18
|
+
|
19
|
+
located = described_class.create! model_attributes
|
20
|
+
|
21
|
+
it_behaves_like 'assert_present!', located, :is_located!, [ { to: location, by: locator, at: Time.now } ], [ :to, :by, :at ]
|
22
|
+
it_behaves_like 'assert_present!', located, :is_located?, [ { to: location, at: Time.now } ], [ :to, :at ]
|
23
|
+
|
24
|
+
end
|
16
25
|
|
17
26
|
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.5.
|
4
|
+
version: 1.5.7
|
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-03-
|
11
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|