unidom-certificate-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 +10 -1
- data/app/models/unidom/certificate/china/identity_card.rb +5 -3
- data/lib/unidom/certificate/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: 367cb07f19c0240c362f2850ca519e2f033112f9
|
4
|
+
data.tar.gz: 4f5a4896ca07d4c9e213c35c068f2d5a26a31574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1580a74418a880324a8af138257b47db22844a68bb8c3556f89ff4cd6c2ac9bcfda7fc7ca4c89bfe42e525ea13f46e0e9e4351d7e6384978f71094d4d31700b8
|
7
|
+
data.tar.gz: 40d22ab278ab589e093a1e38faf06eb3d997eafde6d19a03c4638a757ddbbdff6706318bc7d10b3286d0ed8f17ac8dc2ae66bed8298af4578c1acc5606e1dbff
|
data/README.md
CHANGED
@@ -18,5 +18,14 @@ rake db:migrate
|
|
18
18
|
|
19
19
|
## Call the Model
|
20
20
|
```ruby
|
21
|
-
Unidom::Certificate::China::IdentityCard.identification_number_is('51010519801231123X').
|
21
|
+
identity_card = Unidom::Certificate::China::IdentityCard.identification_number_is('51010519801231123X').first_or_create(
|
22
|
+
name: 'John',
|
23
|
+
address: '#1 Nanjing Street, Shanghai, China',
|
24
|
+
issuing_authority_name: 'Shanghai Police Station',
|
25
|
+
ethnicity_code: 'HA',
|
26
|
+
validity_from_date: '2015-01-01',
|
27
|
+
validity_thru_date: '2025-01-01'
|
28
|
+
)
|
29
|
+
identity_card.gender_code # '1' male, calculated from the identification_number
|
30
|
+
identity_card.birth_date # '1980-12-31', calculated from the identification_number
|
22
31
|
```
|
@@ -4,9 +4,11 @@ class Unidom::Certificate::China::IdentityCard < ActiveRecord::Base
|
|
4
4
|
|
5
5
|
self.table_name = 'unidom_china_identity_cards'
|
6
6
|
|
7
|
+
FORMAT_VALIDATION_REGEX = /\A\d{17}[\dx]\z/i
|
8
|
+
|
7
9
|
validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
|
8
10
|
validates :address, presence: true, length: { in: 2..self.columns_hash['address'].limit }
|
9
|
-
validates :identification_number, presence: true, length: { is: self.columns_hash['identification_number'].limit }
|
11
|
+
validates :identification_number, presence: true, length: { is: self.columns_hash['identification_number'].limit }, format: FORMAT_VALIDATION_REGEX
|
10
12
|
validates :issuing_authority_name, presence: true, length: { in: 2..self.columns_hash['issuing_authority_name'].limit }
|
11
13
|
|
12
14
|
has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certification
|
@@ -15,9 +17,9 @@ class Unidom::Certificate::China::IdentityCard < ActiveRecord::Base
|
|
15
17
|
|
16
18
|
include Unidom::Common::Concerns::ModelExtension
|
17
19
|
|
18
|
-
before_validation
|
20
|
+
before_validation do
|
19
21
|
self.birth_date = Date.parse "#{identification_number[6..9]}-#{identification_number[10..11]}-#{identification_number[12..13]}"
|
20
22
|
self.gender_code = identification_number[16].to_i.odd? ? '1' : '2'
|
21
|
-
|
23
|
+
end
|
22
24
|
|
23
25
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-certificate-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-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: unidom-
|
14
|
+
name: unidom-common
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.5'
|
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.5'
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
28
28
|
The China Certificate domain model engine includes Identity Card, Driving License,
|
29
29
|
and Business License models. Unidom (统一领域对象模型)是一系列的领域模型引擎。中国证件领域模型引擎包括中国大陆的身份证、驾驶证、营业执照等模型。
|