unidom-geo 0.2 → 0.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: 99edf34802dae03b1030d2f753953e5e18ddb968
4
- data.tar.gz: 4459523b9f18b844f3a3779ba76b5249f8c934c5
3
+ metadata.gz: 12d31ea61eb003e61fccae0699f67ee7eb690ed5
4
+ data.tar.gz: 53df0070bdaff458ac4409f126241400f5547456
5
5
  SHA512:
6
- metadata.gz: 6be77f01de86483d6ced96685375d5f46ef2e27cb5c0d25a648ea1bf050c0a3d9389410c13d2e057675c299fdafdfb7eb61ce996d960985b4a6365517086efaa
7
- data.tar.gz: e45571e16c68a5040dacf4eccdaf76db4275f1243c511c6c3607aa908fe9107404fc8109e942e85303661f1fe9a1482021402a85c5066c231a1f3ec727c80f07
6
+ metadata.gz: fb82d867053175160ac9634ff864b2b1ff297cfb947eb69e69c9f45c2892382546960b9a6f487196e10a1fa65e270645bae05dbf05d47be2b2ccd2ccc1423915
7
+ data.tar.gz: 6497cce2c3bb2300fb2b2cfab07eb5986b44212b512cfbf4741f7743d1b48f9e2641a4c0504add999456c2d3654f9717f5fb2b91a09d9727bebf4491e50db2dd
data/README.md CHANGED
@@ -6,6 +6,10 @@
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
+ ## Recent Update
10
+ Check out the [Road Map](ROADMAP.md) to find out what's the next.
11
+ Check out the [Change Log](CHANGELOG.md) to find out what's new.
12
+
9
13
  ## Usage in Gemfile:
10
14
  ```ruby
11
15
  gem 'unidom-geo'
@@ -15,8 +19,12 @@ gem 'unidom-geo'
15
19
  ```shell
16
20
  rake db:migrate
17
21
  ```
22
+ The migration versions start with 200104.
18
23
 
19
24
  ## Call the Model:
20
25
  ```ruby
21
26
  Unidom::Geo::Location.valid_at.alive.first.region
27
+
28
+ active_locatings = location.locatings.valid_at.alive
29
+ Unidom::Geo::Locating.locate! location, shop
22
30
  ```
@@ -10,4 +10,4 @@
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
- //= require_tree .
13
+ //= require_self
@@ -10,6 +10,5 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require_tree .
14
13
  *= require_self
15
14
  */
@@ -1,9 +1,11 @@
1
1
  # Locating 是地理定位,表示地理位置和被定位物体之间的关联。
2
2
 
3
- class Unidom::Geo::Location < ActiveRecord::Base
3
+ class Unidom::Geo::Locating < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'unidom_locatings'
6
6
 
7
+ include Unidom::Common::Concerns::ModelExtension
8
+
7
9
  belongs_to :location, class_name: 'Unidom::Geo::Location'
8
10
  belongs_to :located, polymorphic: true
9
11
  belongs_to :locator, polymorphic: true
@@ -12,6 +14,15 @@ class Unidom::Geo::Location < ActiveRecord::Base
12
14
  scope :located_is, ->(located) { where located: located }
13
15
  scope :located_by, ->(locator) { where locator: locator }
14
16
 
15
- include Unidom::Common::Concerns::ModelExtension
17
+ def self.locate!(location, located, locator = nil, opened_at = Time.now)
18
+ attributes = { opened_at: opened_at }
19
+ if locator.present?
20
+ attributes[:locator] = locator
21
+ else
22
+ attributes[:locator_id] = Unidom::Common::NULL_UUID
23
+ attributes[:locator_type] = ''
24
+ end
25
+ self.located_is(located).location_is(location).valid_at.alive.first_or_create! attributes
26
+ end
16
27
 
17
28
  end
@@ -4,6 +4,8 @@ class Unidom::Geo::Location < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'unidom_locations'
6
6
 
7
+ include Unidom::Common::Concerns::ModelExtension
8
+
7
9
  validates :latitude, presence: true, numericality: { greater_than_or_equal_to: -90, less_than_or_equal_to: 90 }
8
10
  validates :longitude, presence: true, numericality: { greater_than_or_equal_to: -180, less_than_or_equal_to: 180 }
9
11
 
@@ -17,9 +19,9 @@ class Unidom::Geo::Location < ActiveRecord::Base
17
19
 
18
20
  belongs_to :region, polymorphic: true
19
21
 
22
+ has_many :locatings, class_name: 'Unidom::Geo::Locating'
23
+
20
24
  scope :region_is, ->(region) { where region: region }
21
25
  scope :postal_address_is, ->(postal_address) { where postal_address: postal_address }
22
26
 
23
- include Unidom::Common::Concerns::ModelExtension
24
-
25
27
  end
@@ -2,13 +2,14 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Unidom Geo</title>
5
- <%= stylesheet_link_tag 'unidom/geo/application', media: 'all' %>
6
- <%= javascript_include_tag 'unidom/geo/application' %>
5
+ <%= stylesheet_link_tag 'unidom/geo/application', media: 'all' %>
7
6
  <%= csrf_meta_tags %>
8
7
  </head>
9
8
  <body>
10
9
 
11
10
  <%= yield %>
12
11
 
12
+ <%= javascript_include_tag 'unidom/geo/application' %>
13
+
13
14
  </body>
14
15
  </html>
@@ -20,7 +20,6 @@ class CreateUnidomLocations < ActiveRecord::Migration
20
20
 
21
21
  t.column :accuarcy_code, 'char(1)', null: false, default: 'N'
22
22
 
23
- t.string :slug, null: false, default: nil, limit: 200
24
23
  t.column :state, 'char(1)', null: false, default: 'C'
25
24
  t.datetime :opened_at, null: false, default: ::Time.utc(1970)
26
25
  t.datetime :closed_at, null: false, default: ::Time.utc(3000)
@@ -38,8 +37,7 @@ class CreateUnidomLocations < ActiveRecord::Migration
38
37
  add_index :unidom_locations, :minimum_longitude
39
38
  add_index :unidom_locations, :maximum_latitude
40
39
  add_index :unidom_locations, :maximum_longitude
41
- add_index :unidom_locations, :slug, unique: true
42
- # add_index :unidom_locations, [ :postal_address, :region_id, :region_type ], unique: true
40
+ add_index :unidom_locations, [ :postal_address, :region_id, :region_type ], unique: true, name: 'index_unidom_locations_on_postal_address_and_region'
43
41
 
44
42
  end
45
43
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Geo
3
- VERSION = '0.2'.freeze
3
+ VERSION = '0.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: '0.2'
4
+ version: '0.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-02-25 00:00:00.000000000 Z
11
+ date: 2016-07-21 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: '0.2'
19
+ version: '0.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: '0.2'
26
+ version: '0.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:
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  version: '0'
70
70
  requirements: []
71
71
  rubyforge_project:
72
- rubygems_version: 2.4.5.1
72
+ rubygems_version: 2.6.4
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Unidom Geo Domain Model Engine 地理领域模型引擎