unidom-certificate 2.0.4 → 2.0.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: b9f85b7345a1580bf9da3437f447500dc614cf40
4
- data.tar.gz: ea9d05eb572e3096c92b405e6c46399d5bb70e33
3
+ metadata.gz: ca0e580e879911b3072e2cb3851d950dd9ef8da4
4
+ data.tar.gz: 498b1f4a7b64734fb93caa4776e69c9eab858e1b
5
5
  SHA512:
6
- metadata.gz: 8820f842d51f3d1824e525fd6979daa41c6ab428e02f23b242589c8032ca69a0dd81a298e6609d0396c3d7dd27b0d52899d31859c7200255c7d4909a258bcc05
7
- data.tar.gz: f7cb3594b446aa0bb6fee092827117e2c2ee40663f7afef2b5def658fb8c829ca5c9cec0ceeb64f62cefdb76d04bc57027023a3a43a6a1390cde8cb4115e8454
6
+ metadata.gz: 87ed53486673f17662470856658a9ce9b714b86d1b031551fe0de9bc3099ad660468eb7436ee94f75c7613cfde2676339bbeabe5f0afbd9a53fb8d2d5c4e175a
7
+ data.tar.gz: ec53b9a4f1edc6dc05e336aa1f02836ed2d1456ec35830b5af62608528dd543e99310e187a6cde84e638b576260a6249030a1eaa2ebef8fee1eeaac578b4ad99
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Unidom Certificate 证书领域模型引擎
2
2
 
3
+ [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/unidom-certificate/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-certificate.svg)](https://badge.fury.io/rb/unidom-certificate)
5
7
  [![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-certificate.svg)](https://gemnasium.com/github.com/topbitdu/unidom-certificate)
6
8
 
@@ -38,7 +40,7 @@ The migration versions start with 200102.
38
40
  ```ruby
39
41
  officer = Unidom::Party::Person.create! name: 'John'
40
42
  mall = Unidom::Party::Shop.create! name: 'WalMart'
41
- certification = Unidom::Certificate::China::BusinessLicense.registration_number_is('123456789012345').valid_at.alive.first_or_create! name: 'WalMart', address: 'Beijing', legal_representative_name: 'Tim'
43
+ certification = Unidom::Certificate::China::BusinessLicense.registration_number_is('123456789012345').valid_at.alive.first_or_create! name: 'WalMart', address: 'Beijing', legal_representative_name: 'Tim'
42
44
  certificating = Unidom::Certificate::Certificating.certificate!(certification: certification, certificated: mall, certificator: officer, opened_at: Time.now)
43
45
  ```
44
46
 
@@ -54,13 +56,29 @@ include Unidom::Certificate::Concerns::AsCertification
54
56
  ### As Certificated concern
55
57
 
56
58
  The As Certificated concern do the following tasks for the includer automatically:
57
- 1. Define the has_many :certificatings macro as: ``has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certificated``
58
- 2. Define the #is_certificated! method as: ``def is_certificated!(certification, by: nil, at: Time.now)``
59
+ 1. Define the has_many :certificatings macro as: ``has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certificated``
60
+ 2. Define the #is_certificated! method as: ``def is_certificated!(certification, by: nil, at: Time.now)``
59
61
  3. Define the #is_certificated? method as: ``def is_certificated?(certification, at: Time.now)``
60
62
 
61
63
  ### As Certification concern
62
64
 
63
65
  The As Certification concern do the following tasks for the includer automatically:
64
- 1. Define the has_many :certificatings macro as: ``has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certification``
65
- 2. Define the #certificate! method as: ``def certificate!(certificated, by: nil, at: Time.now)``
66
+ 1. Define the has_many :certificatings macro as: ``has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certification``
67
+ 2. Define the #certificate! method as: ``def certificate!(certificated, by: nil, at: Time.now)``
66
68
  3. Define the #certificate? method as: ``def certificate?(certificated, at: Time.now)``
69
+
70
+
71
+
72
+ ## Disable the Model & Migration
73
+
74
+ If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
75
+ ```ruby
76
+ # config/initializers/unidom.rb
77
+ Unidom::Common.configure do |options|
78
+
79
+ options[:neglected_namespaces] = %w{
80
+ Unidom::Certificate
81
+ }
82
+
83
+ end
84
+ ```
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application controller 是模块内所有控制器的基类。
3
+
1
4
  class Unidom::Certificate::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::Certificate::ApplicationJob < ActiveJob::Base
2
5
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application mailer 是模块内所有电子邮件发送类的基类。
3
+
1
4
  class Unidom::Certificate::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::ApplicationRecord < ActiveRecord::Base
2
5
  self.abstract_class = true
3
6
  end
@@ -15,8 +15,11 @@ class Unidom::Certificate::Certificating < Unidom::Certificate::ApplicationRecor
15
15
  scope :certificated_is, ->(certificated) { where certificated: certificated }
16
16
  scope :certification_is, ->(certification) { where certification: certification }
17
17
 
18
+ ##
19
+ # 由认证者 certificator 用证书 certification 去认证的人或者机构 certificated ,认证时间是: opened_at。
18
20
  def self.certificate!(certification: nil, certificated: nil, certificator: nil, opened_at: Time.now)
19
- raise ArgumentError.new('The certification argument is required.') if certification.blank?
21
+ assert_present! :certification, certification
22
+ #raise ArgumentError.new('The certification argument is required.') if certification.blank?
20
23
  raise ArgumentError.new('The certificated argument is required.' ) if certificated.blank?
21
24
  raise ArgumentError.new('The opened_at argument is required.' ) if opened_at.blank?
22
25
 
@@ -30,4 +33,4 @@ class Unidom::Certificate::Certificating < Unidom::Certificate::ApplicationRecor
30
33
  self.certification_is(certification).certificated_is(certificated).valid_at(now: opened_at).alive.first_or_create! attributes
31
34
  end
32
35
 
33
- end
36
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Certificate::Certificating'
@@ -9,6 +9,9 @@ module Unidom::Certificate::Concerns::AsCertificated
9
9
 
10
10
  has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certificated
11
11
 
12
+ ##
13
+ # 被认证者被证书 certification 认证,认证者为 by ,认证时间是 at (缺省为当前时间)。
14
+ # 如: person.is_certificated! mcse, by: bill_gates, at: Time.now
12
15
  def is_certificated!(certification, by: nil, at: Time.now)
13
16
 
14
17
  raise ArgumentError.new('The certification argument is required.') if certification.blank?
@@ -19,6 +22,9 @@ module Unidom::Certificate::Concerns::AsCertificated
19
22
 
20
23
  end
21
24
 
25
+ ##
26
+ # 判断当前被认证者在指定的时间 at (缺省为当前时间)是否有指定的证书 certification 。如:
27
+ # person.is_certificated? mcse, at: Time.now
22
28
  def is_certificated?(certification, at: Time.now)
23
29
 
24
30
  raise ArgumentError.new('The certification argument is required.') if certification.blank?
@@ -9,6 +9,9 @@ module Unidom::Certificate::Concerns::AsCertification
9
9
 
10
10
  has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certification
11
11
 
12
+ ##
13
+ # 用证书去认证参与者(被认证者)。 by 是认证者, at 是认证时间(缺省为当前时间)。
14
+ # 如:mcse.certificate! person, by: bill_gates, at: Time.now
12
15
  def certificate!(certificated, by: nil, at: Time.now)
13
16
 
14
17
  raise ArgumentError.new('The certificated argument is required.') if certificated.blank?
@@ -19,6 +22,9 @@ module Unidom::Certificate::Concerns::AsCertification
19
22
 
20
23
  end
21
24
 
25
+ ##
26
+ # 判断当前认证书在指定的时间 at (缺省为当前时间)是否对被认证者 certificated 生效。如:
27
+ # mcse.certificated? person, at: Time.now
22
28
  def certificate?(certificated, at: Time.now)
23
29
 
24
30
  raise ArgumentError.new('The certificated argument is required.') if certificated.blank?
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Certificate
3
- VERSION = '2.0.4'.freeze
3
+ VERSION = '2.0.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-certificate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.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-20 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 Certificate domain model engine includes Identity Card and Business License
29
29
  models. Unidom (统一领域对象模型)是一系列的领域模型引擎。证书领域模型引擎包括身份证和营业执照的模型。