unidom-region-china 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/app/models/unidom/region/china/region.rb +3 -1
- data/lib/unidom/region/china/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 288ec73c692e996d7b7f0add61f7d3ab635d09d1
|
4
|
+
data.tar.gz: 59d37b73b55f217f349c84bda7968182d1a19ab9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5580430d2bf8f5e9f864aa029710a5616ac8c9b53c15e2f93edaa266d692ee769cbd0dd3e59f481bbdd670f4a902297af88a7a7a2bb84f2c10d54e12820aee31
|
7
|
+
data.tar.gz: e8c178359878f29b27011b41c267d8282e9a48b31a463217ec11290c88b3642f1b3b4b42d902f880b676bc6c6d592ec1bf97a23778ac2a79e2f260c1626c099e
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Unidom Region China
|
2
2
|
|
3
|
+
[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
|
4
|
+
|
3
5
|
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The China Region domain model engine includes the Region model and its migration.
|
4
6
|
Unidom (统一领域对象模型)是一系列的领域模型引擎。中国行政区划领域模型引擎包括中国大陆的行政区划模型及其数据迁移脚本。
|
5
7
|
|
@@ -20,5 +22,6 @@ bundle exec rake unidom:region:china:import file=/china-region-data/NBS-county/2
|
|
20
22
|
|
21
23
|
## Call the Model:
|
22
24
|
```ruby
|
23
|
-
Unidom::Region::China::Region.
|
25
|
+
Unidom::Region::China::Region.root_level # All the 31 province-level regions including Beijing, Tianjin, etc.
|
26
|
+
Unidom::Region::China::Region.numeric_coded_as('120000').valid_at.alive.first # Tianjin (天津)
|
24
27
|
```
|
@@ -27,7 +27,7 @@ class Unidom::Region::China::Region < ActiveRecord::Base
|
|
27
27
|
|
28
28
|
validates :numeric_code, numericality: { integer_only: true }
|
29
29
|
validates :alphabetic_code, allow_blank: true, length: { minimum: 2 }
|
30
|
-
validates :name, presence:
|
30
|
+
validates :name, presence: true, length: { maximum: self.columns_hash['name'].limit }
|
31
31
|
|
32
32
|
belongs_to :scheme, polymorphic: true
|
33
33
|
has_many :locations, class_name: 'Unidom::Geo::Location', as: :region
|
@@ -39,6 +39,8 @@ class Unidom::Region::China::Region < ActiveRecord::Base
|
|
39
39
|
scope :name_is, ->(name) { where name: name }
|
40
40
|
scope :being_virtual, ->(virtual = true) { where virtual: virtual }
|
41
41
|
|
42
|
+
scope :root_level, -> { numeric_code_ending_with '0000' }
|
43
|
+
|
42
44
|
include ::Unidom::Common::Concerns::ModelExtension
|
43
45
|
|
44
46
|
def numeric_code_prefix
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-region-china
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
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-01-
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|