unidom-geo-china 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/assets/javascripts/unidom/geo/china/application.js +1 -1
- data/app/assets/stylesheets/unidom/geo/china/application.css +0 -1
- data/app/models/unidom/geo/china/region.rb +12 -9
- data/app/views/layouts/unidom/geo/china/application.html.erb +3 -2
- data/lib/unidom/geo/china/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70c8f8c8ebb8daffd6de328fba9502812afb8c99
|
4
|
+
data.tar.gz: 45165c649ec96997c5de8d6ca2aa951c601492c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e4db96018499a72be7e123f10e0d6ef75eafcb4ca732ccb9d41dd78d4a631f4c76afe6bddb6aa410bb91e0ec18a201ec206225aa98c312f988bf0e134929e57
|
7
|
+
data.tar.gz: 89dd8eba094bed15c66c0b65a3f9f3abf7b067b6545eb6ca398e56a000f88f20d7b5598af89e78bca04981e27001a7d06868866be65d4c9f797dc674027b48ff
|
data/README.md
CHANGED
@@ -6,6 +6,10 @@
|
|
6
6
|
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The China Geo domain model engine includes the Region model and its migration.
|
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-china'
|
@@ -15,6 +19,7 @@ gem 'unidom-geo-china'
|
|
15
19
|
```shell
|
16
20
|
rake db:migrate
|
17
21
|
```
|
22
|
+
The migration versions start with 2001049156.
|
18
23
|
|
19
24
|
## Import Data
|
20
25
|
```shell
|
@@ -26,4 +31,7 @@ bundle exec rake unidom:geo:china:town:import file=/china-region-data/NBS-town/2
|
|
26
31
|
```ruby
|
27
32
|
Unidom::Geo::China::Region.root_level # All the 31 province-level regions including Beijing, Tianjin, etc.
|
28
33
|
Unidom::Geo::China::Region.numeric_coded_as('120000').valid_at.alive.first # Tianjin (天津)
|
34
|
+
|
35
|
+
active_locations = region.locations.valid_at.alive
|
36
|
+
active_towns = region.towns.valid_at.alive
|
29
37
|
```
|
@@ -25,25 +25,28 @@ class Unidom::Geo::China::Region < ActiveRecord::Base
|
|
25
25
|
|
26
26
|
self.table_name = 'unidom_china_regions'
|
27
27
|
|
28
|
+
include Unidom::Common::Concerns::ModelExtension
|
29
|
+
|
28
30
|
validates :numeric_code, numericality: { integer_only: true }
|
29
|
-
validates :alphabetic_code, allow_blank:
|
30
|
-
validates :name, presence:
|
31
|
+
validates :alphabetic_code, allow_blank: true, length: { minimum: 2 }
|
32
|
+
validates :name, presence: true, length: { maximum: self.columns_hash['name'].limit }
|
33
|
+
|
34
|
+
belongs_to :scheme, polymorphic: true
|
31
35
|
|
32
|
-
|
33
|
-
has_many
|
34
|
-
|
36
|
+
has_many :locations, class_name: 'Unidom::Geo::Location', as: :region
|
37
|
+
has_many :locatings, through: :locations, source: :locatings
|
38
|
+
|
39
|
+
has_many :towns, class_name: 'Unidom::Geo::China::Town'
|
35
40
|
|
36
41
|
scope :scheme_is, ->(scheme) { scheme.present? ? where(scheme: scheme) : scheme_id_is.scheme_type_is }
|
37
|
-
scope :scheme_id_is, ->(scheme_id =
|
38
|
-
scope :scheme_type_is, ->(scheme_type = ''
|
42
|
+
scope :scheme_id_is, ->(scheme_id = Unidom::Common::NULL_UUID) { where scheme_id: scheme_id }
|
43
|
+
scope :scheme_type_is, ->(scheme_type = '' ) { where scheme_type: scheme_type }
|
39
44
|
|
40
45
|
scope :name_is, ->(name) { where name: name }
|
41
46
|
scope :being_virtual, ->(virtual = true) { where virtual: virtual }
|
42
47
|
|
43
48
|
scope :root_level, -> { numeric_code_ending_with '0000' }
|
44
49
|
|
45
|
-
include Unidom::Common::Concerns::ModelExtension
|
46
|
-
|
47
50
|
def numeric_code_prefix
|
48
51
|
numeric_code[0..1]
|
49
52
|
end
|
@@ -2,13 +2,14 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>Unidom Geo China</title>
|
5
|
-
<%= stylesheet_link_tag
|
6
|
-
<%= javascript_include_tag 'unidom/geo/china/application' %>
|
5
|
+
<%= stylesheet_link_tag 'unidom/geo/china/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/china/application' %>
|
13
|
+
|
13
14
|
</body>
|
14
15
|
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-geo-china
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
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-
|
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.
|
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.
|
26
|
+
version: '0.9'
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
28
28
|
The China Contact domain model engine includes Mobile Phone Number and its relative
|
29
29
|
models. Unidom (统一领域对象模型)是一系列的领域模型引擎。中国地理领域模型引擎包括中国大陆的行政区划及其相关的模型。
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.4
|
73
|
+
rubygems_version: 2.6.4
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: Unidom China Geo Domain Model Engine 中国地理领域模型引擎
|