unidom-geo 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de985c80fc44a553c419760277bd898648418822
4
- data.tar.gz: 054d7ae8e6270cd72999fb9437f172124807add3
3
+ metadata.gz: ec75e08c0307987c1cacab5fea9dbf31588fcd50
4
+ data.tar.gz: b86578703813ca367aad0f47f46023b2661e2c4f
5
5
  SHA512:
6
- metadata.gz: 832ea4737e1ecb94dd8f3d1dbdfe4e17b560a09cd189e0dfa7ec9f3c10a160c38c642656f23fe0bc2c90d0bb2c134498da4615732aaa4890ab0dd0596e1ad656
7
- data.tar.gz: e2dad2bc6c0c2ba21b31c30356a30a22e6d5cf4b71c1517cce315d59a15ebb5eae0d50b84b3e84987323d5507b7d0fa69e278427717bc19b7012ae1b9abb3a8f
6
+ metadata.gz: 6234b6e1cf61e8437a1bde7ff3c270bc62d3665fcbf47e3259deef7dee7be212cd35620ab528993b19a982251cb4c7ae31b62b56ef8dee333a778e1bcc7557d2
7
+ data.tar.gz: 375120d30f4cc6941e003b389516ec8041529d6097063c579fc39fb26a0fc0503052608f39ae900da2d3289cf4d73b6ec70aa29f6ed38bda0d95ef7a5b5feca4
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Unidom Geo 地理领域模型引擎
2
2
 
3
+ [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/unidom-geo/frames)
3
4
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
5
+
4
6
  [![Gem Version](https://badge.fury.io/rb/unidom-geo.svg)](https://badge.fury.io/rb/unidom-geo)
5
7
  [![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-geo.svg)](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
+ ```
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application controller 是模块内所有控制器的基类。
3
+
1
4
  class Unidom::Geo::ApplicationController < ActionController::Base
2
5
  protect_from_forgery with: :exception
3
6
  end
@@ -1,2 +1,5 @@
1
+ ##
2
+ # Application job 是模块内所有异步任务的基类。
3
+
1
4
  class Unidom::Geo::ApplicationJob < ActiveJob::Base
2
5
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application mailer 是模块内所有电子邮件发送类的基类。
3
+
1
4
  class Unidom::Geo::ApplicationMailer < ActionMailer::Base
2
5
  default from: 'from@example.com'
3
6
  layout 'mailer'
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application record 是模块内所有模型的抽象基类。
3
+
1
4
  class Unidom::Geo::ApplicationRecord < ActiveRecord::Base
2
5
  self.abstract_class = true
3
6
  end
@@ -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
@@ -29,4 +29,4 @@ class Unidom::Geo::Locating < Unidom::Geo::ApplicationRecord
29
29
  self.located_is(located).location_is(location).valid_at.alive.first_or_create! attributes
30
30
  end
31
31
 
32
- end
32
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Geo::Locating'
@@ -39,4 +39,4 @@ class Unidom::Geo::Location < Unidom::Geo::ApplicationRecord
39
39
  locatings.located_is(located).valid_at(now: at).alive.exists?
40
40
  end
41
41
 
42
- end
42
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Geo::Location'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Geo
3
- VERSION = '1.4.4'.freeze
3
+ VERSION = '1.4.5'.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.4.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-03 00:00:00.000000000 Z
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.8'
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.8'
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: