unidom-certificate-china 1.3 → 1.4

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: 41d0bd8693c28537c3cd040291581e45aed30df4
4
- data.tar.gz: da6f0dec683aa96d48ccba5efc62574737eecafd
3
+ metadata.gz: 1d8ba2d2b978a505a66994e6e14e1cb64784f91f
4
+ data.tar.gz: 4691fe8b019b9764363068bb915e43e635c64788
5
5
  SHA512:
6
- metadata.gz: 2b6bbac06200b5536b9598b413d9a1c555ba5367d05f8a85b0bc895672a38aa30e30f3ae5e16c4181531cb4df10ab1294d91a4bc823e698fbe76a7e76b6f9a29
7
- data.tar.gz: b5beebe420dffddd5a323aaeaf2088c1ff9cd9bb679eb6eb4d92e8c819603c07f6ee3bd3938be6ac63681b62f128d60e4270d32de906ec01e0dd400d84df045c
6
+ metadata.gz: 1ae7e9e702bc26fb27ff80ddbc904cfdfc5f2cfdafafef2f222c172e8b97c6066bc1427fb078c593e13eedea3b16df94d5a2514db660253ff2b0aa2ae49c46e0
7
+ data.tar.gz: ddf4272aed977244a73064ad8fb41a6ae2b2f5a63826521d3188ffba6bf3220e7ba59e1dacac46644fdbea55209bcad32ec9a2f9d4d7ffe0398c46e35358f85d
data/README.md CHANGED
@@ -82,13 +82,17 @@ include Unidom::Certificate::China::Concerns::AsIdentityCardCertificated
82
82
  ### As Business License Certificated
83
83
 
84
84
  The As Business License Certificated do the following tasks for the includer automatically:
85
+
85
86
  1. Include the [As Certificated](http://https://github.com/topbitdu/unidom-certificated) concern
87
+
86
88
  2. Define the has_many :china_business_licenses macro as: ``has_many :china_business_licenses, through: :certificatings, source: :certification, source_type: 'Unidom::Certificate::China::BusinessLicense'``
87
89
 
88
90
  ### As Identity Card Certificated
89
91
 
90
92
  The As Identity Card Certificated do the following tasks for the includer automatically:
93
+
91
94
  1. Include the [As Certificated](http://https://github.com/topbitdu/unidom-certificated) concern
95
+
92
96
  2. Define the has_many :china_identity_cards macro as: ``has_many :china_identity_cards, through: :certificatings, source: :certification, source_type: 'Unidom::Certificate::China::IdentityCard'``
93
97
 
94
98
 
@@ -1,6 +1,6 @@
1
- module China
2
- class ApplicationController < ActionController::Base
3
- protect_from_forgery with: :exception
4
- end
1
+ ##
2
+ # Application controller 是模块内所有控制器的基类。
5
3
 
4
+ class Unidom::Certificate::China::ApplicationController < ActionController::Base
5
+ protect_from_forgery with: :exception
6
6
  end
@@ -1,2 +1,5 @@
1
+ ##
2
+ # Application job 是模块内所有异步任务的基类。
3
+
1
4
  class Unidom::Certificate::China::ApplicationJob < ActiveJob::Base
2
5
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application mailer 是模块内所有电子邮件发送类的基类。
3
+
1
4
  class Unidom::Certificate::China::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::Certificate::China::ApplicationRecord < ActiveRecord::Base
2
5
  self.abstract_class = true
3
6
  end
@@ -1,3 +1,4 @@
1
+ ##
1
2
  # Business License 是中国的工商营业执照。
2
3
 
3
4
  class Unidom::Certificate::China::BusinessLicense < Unidom::Certificate::China::ApplicationRecord
@@ -0,0 +1,22 @@
1
+ # GB 32100-2015《法人和其他组织统一社会信用代码编码规则》
2
+ # http://qyj.saic.gov.cn/wjfb/201509/t20150929_162430.html
3
+
4
+ class Unidom::Certificate::China::UnifiedSocialCreditIdentifierValidator < ActiveModel::EachValidator
5
+
6
+ WEIGHTS = [ 1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28 ].freeze
7
+ VALUES = '0123456789ABCDEFGHJKLMNPQRTUWXY'.freeze
8
+
9
+ def validate_each(record, attribute, value)
10
+
11
+ value = value.to_s
12
+ sum = 0
13
+ value[0..16].chars.each_with_index do |char, index| sum += VALUES.index(char)*WEIGHTS[index] end
14
+ checksum = sum % 31
15
+ checksum = 0==checksum ? 31 : checksum
16
+ checksum = 31-checksum
17
+
18
+ record.errors[attribute] << (options[:message]||'is invalid') unless VALUES[checksum]==value[17]
19
+
20
+ end
21
+
22
+ end
@@ -1,7 +1,7 @@
1
1
  module Unidom
2
2
  module Certificate
3
3
  module China
4
- VERSION = '1.3'.freeze
4
+ VERSION = '1.4'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-certificate-china
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
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-13 00:00:00.000000000 Z
11
+ date: 2017-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-certificate
@@ -55,6 +55,7 @@ files:
55
55
  - app/models/unidom/certificate/china/concerns/as_identity_card_certificated.rb
56
56
  - app/models/unidom/certificate/china/identity_card.rb
57
57
  - app/validators/unidom/certificate/china/identification_number_validator.rb
58
+ - app/validators/unidom/certificate/china/unified_social_credit_identifier_validator.rb
58
59
  - app/views/layouts/unidom/certificate/china/application.html.erb
59
60
  - config/routes.rb
60
61
  - db/migrate/20010291560010_create_unidom_china_identity_cards.rb