unidom-certificate 2.1 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +86 -0
- data/app/models/unidom/certificate/certificating.rb +2 -3
- data/app/models/unidom/certificate/concerns/as_certification.rb +3 -1
- data/lib/rspec/models/unidom/certificate/concerns/as_certificated_shared_examples.rb +23 -0
- data/lib/rspec/models/unidom/certificate/concerns/as_certification_shared_examples.rb +23 -0
- data/lib/unidom/certificate/rspec_shared_examples.rb +2 -0
- data/lib/unidom/certificate/version.rb +1 -1
- metadata +5 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: dd70eeabf4ae48d02909c4530a68f2fccb3d63bd
         | 
| 4 | 
            +
              data.tar.gz: 12af2197e143c187cfa930b44fa38d7ffe5c9bff
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 94dd5fb13696c9572e269120a2e3c5000dc0babaf7f70d828ad2321c48702bc5a4428f9fb6cc11519e5477622eeff23683b7f25a085c45709779270d7b10daa0
         | 
| 7 | 
            +
              data.tar.gz: 4b1dd04d8e254be707db42d6c29d3d0884e5d4d324fbaa4fba78cf5af38596f62b125a924a3150e5039054a988a6f3a5d873d9d7fe5024b1f41e5f3a6f20ca70
         | 
    
        data/README.md
    CHANGED
    
    | @@ -87,6 +87,8 @@ end | |
| 87 87 |  | 
| 88 88 | 
             
            ## RSpec examples
         | 
| 89 89 |  | 
| 90 | 
            +
            ### RSpec example manifest (run automatically)
         | 
| 91 | 
            +
             | 
| 90 92 | 
             
            ```ruby
         | 
| 91 93 | 
             
            # spec/models/unidom_spec.rb
         | 
| 92 94 | 
             
            require 'unidom/certificate/models_rspec'
         | 
| @@ -97,3 +99,87 @@ require 'unidom/certificate/types_rspec' | |
| 97 99 | 
             
            # spec/validators/unidom_spec.rb
         | 
| 98 100 | 
             
            require 'unidom/certificate/validators_rspec'
         | 
| 99 101 | 
             
            ```
         | 
| 102 | 
            +
             | 
| 103 | 
            +
            ### RSpec shared examples (to be integrated)
         | 
| 104 | 
            +
             | 
| 105 | 
            +
            ```ruby
         | 
| 106 | 
            +
            # The Unidom::Certificate::China::BusinessLicense model, & the Unidom::Certificate::China::IdentityCard model already include the Unidom::Certificate::Concerns::AsCertification concern
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            # app/models/your_certification.rb
         | 
| 109 | 
            +
            class YourCertification < ApplicationRecord
         | 
| 110 | 
            +
             | 
| 111 | 
            +
              include Unidom::Common::Concerns::ModelExtension
         | 
| 112 | 
            +
              include Unidom::Certificate::Concerns::AsCertification
         | 
| 113 | 
            +
             | 
| 114 | 
            +
            end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
            # lib/unidom.rb
         | 
| 117 | 
            +
            def initialize_unidom
         | 
| 118 | 
            +
             | 
| 119 | 
            +
              Unidom::Party::Company.class_eval do
         | 
| 120 | 
            +
                include Unidom::Certificate::Concerns::AsCertificated
         | 
| 121 | 
            +
              end
         | 
| 122 | 
            +
             | 
| 123 | 
            +
              Unidom::Party::Person.class_eval do
         | 
| 124 | 
            +
                include Unidom::Certificate::Concerns::AsCertificated
         | 
| 125 | 
            +
              end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
              Unidom::Party::Shop.class_eval do
         | 
| 128 | 
            +
                include Unidom::Certificate::Concerns::AsCertificated
         | 
| 129 | 
            +
              end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
            end
         | 
| 132 | 
            +
             | 
| 133 | 
            +
            # spec/rails_helper.rb
         | 
| 134 | 
            +
            require 'unidom'
         | 
| 135 | 
            +
            initialize_unidom
         | 
| 136 | 
            +
             | 
| 137 | 
            +
            # spec/support/unidom_rspec_shared_examples.rb
         | 
| 138 | 
            +
            require 'unidom/certificate/rspec_shared_examples'
         | 
| 139 | 
            +
             | 
| 140 | 
            +
            # spec/models/unidom/party/company_spec.rb
         | 
| 141 | 
            +
            describe Unidom::Party::Company, type: :model do
         | 
| 142 | 
            +
             | 
| 143 | 
            +
              model_attribtues = {
         | 
| 144 | 
            +
                name: 'Tesla'
         | 
| 145 | 
            +
              }
         | 
| 146 | 
            +
             | 
| 147 | 
            +
              it_behaves_like 'Unidom::Certificate::Concerns::AsCertificated', model_attribtues
         | 
| 148 | 
            +
             | 
| 149 | 
            +
            end
         | 
| 150 | 
            +
             | 
| 151 | 
            +
            # spec/models/unidom/party/person_spec.rb
         | 
| 152 | 
            +
            describe Unidom::Party::Person, type: :model do
         | 
| 153 | 
            +
             | 
| 154 | 
            +
              model_attribtues = {
         | 
| 155 | 
            +
                name: 'Tim'
         | 
| 156 | 
            +
              }
         | 
| 157 | 
            +
             | 
| 158 | 
            +
              it_behaves_like 'Unidom::Certificate::Concerns::AsCertificated', model_attribtues
         | 
| 159 | 
            +
             | 
| 160 | 
            +
            end
         | 
| 161 | 
            +
             | 
| 162 | 
            +
            # spec/models/unidom/party/shop_spec.rb
         | 
| 163 | 
            +
            describe Unidom::Party::Shop, type: :model do
         | 
| 164 | 
            +
             | 
| 165 | 
            +
              model_attribtues = {
         | 
| 166 | 
            +
                name: 'WalMart'
         | 
| 167 | 
            +
              }
         | 
| 168 | 
            +
             | 
| 169 | 
            +
              it_behaves_like 'Unidom::Certificate::Concerns::AsCertificated', model_attribtues
         | 
| 170 | 
            +
             | 
| 171 | 
            +
            end
         | 
| 172 | 
            +
             | 
| 173 | 
            +
            # spec/models/your_certification_spec.rb
         | 
| 174 | 
            +
            describe YourCertification, type: :model do
         | 
| 175 | 
            +
             | 
| 176 | 
            +
              model_attribtues = {
         | 
| 177 | 
            +
                name:          'Your Certification Name',
         | 
| 178 | 
            +
                serial_number: '12345678',
         | 
| 179 | 
            +
                issued_on:     '2020-01-01'
         | 
| 180 | 
            +
              }
         | 
| 181 | 
            +
             | 
| 182 | 
            +
              it_behaves_like 'Unidom::Certificate::Concerns::AsCertification', model_attribtues
         | 
| 183 | 
            +
             | 
| 184 | 
            +
            end
         | 
| 185 | 
            +
            ```
         | 
| @@ -19,9 +19,8 @@ class Unidom::Certificate::Certificating < Unidom::Certificate::ApplicationRecor | |
| 19 19 | 
             
              # 由认证者 certificator 用证书 certification 去认证的人或者机构 certificated ,认证时间是: opened_at。
         | 
| 20 20 | 
             
              def self.certificate!(certification: nil, certificated: nil, certificator: nil, opened_at: Time.now)
         | 
| 21 21 | 
             
                assert_present! :certification, certification
         | 
| 22 | 
            -
                 | 
| 23 | 
            -
                 | 
| 24 | 
            -
                raise ArgumentError.new('The opened_at argument is required.'    ) if opened_at.blank?
         | 
| 22 | 
            +
                assert_present! :certificated,  certificated
         | 
| 23 | 
            +
                assert_present! :opened_at,     opened_at
         | 
| 25 24 |  | 
| 26 25 | 
             
                attributes = { opened_at: opened_at }
         | 
| 27 26 | 
             
                if certificator.present?
         | 
| @@ -4,6 +4,7 @@ | |
| 4 4 | 
             
            module Unidom::Certificate::Concerns::AsCertification
         | 
| 5 5 |  | 
| 6 6 | 
             
              extend ActiveSupport::Concern
         | 
| 7 | 
            +
              include Unidom::Common::Concerns::ArgumentValidation
         | 
| 7 8 |  | 
| 8 9 | 
             
              included do |includer|
         | 
| 9 10 |  | 
| @@ -14,7 +15,8 @@ module Unidom::Certificate::Concerns::AsCertification | |
| 14 15 | 
             
                # 如:mcse.certificate! person, by: bill_gates, at: Time.now
         | 
| 15 16 | 
             
                def certificate!(certificated, by: nil, at: Time.now)
         | 
| 16 17 |  | 
| 17 | 
            -
                   | 
| 18 | 
            +
                  assert_present! :certificated, certificated
         | 
| 19 | 
            +
                  #raise ArgumentError.new('The certificated argument is required.') if certificated.blank?
         | 
| 18 20 | 
             
                  raise ArgumentError.new('The by argument is required.'          ) if by.blank?
         | 
| 19 21 | 
             
                  raise ArgumentError.new('The at argument is required.'          ) if at.blank?
         | 
| 20 22 |  | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            shared_examples 'Unidom::Certificate::Concerns::AsCertificated' do |model_attributes|
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              context do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                certificating_1_attribtues = {
         | 
| 6 | 
            +
                    certificator_id:    SecureRandom.uuid,
         | 
| 7 | 
            +
                    certificator_type:  'Unidom::Certificate::Certificator::Mock',
         | 
| 8 | 
            +
                    certification_id:   SecureRandom.uuid,
         | 
| 9 | 
            +
                    certification_type: 'Unidom::Certificate::Certification::Mock'
         | 
| 10 | 
            +
                  }
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                certificating_2_attribtues = {
         | 
| 13 | 
            +
                    certificator_id:    SecureRandom.uuid,
         | 
| 14 | 
            +
                    certificator_type:  'Unidom::Certificate::Certificator::Mock',
         | 
| 15 | 
            +
                    certification_id:   SecureRandom.uuid,
         | 
| 16 | 
            +
                    certification_type: 'Unidom::Certificate::Certification::Mock'
         | 
| 17 | 
            +
                  }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                it_behaves_like 'has_many', model_attributes, :certificatings, Unidom::Certificate::Certificating, [ certificating_1_attribtues, certificating_2_attribtues ]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            shared_examples 'Unidom::Certificate::Concerns::AsCertification' do |model_attributes|
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              context do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                certificating_1_attribtues = {
         | 
| 6 | 
            +
                    certificator_id:   SecureRandom.uuid,
         | 
| 7 | 
            +
                    certificator_type: 'Unidom::Certificate::Certificator::Mock',
         | 
| 8 | 
            +
                    certificated_id:   SecureRandom.uuid,
         | 
| 9 | 
            +
                    certificated_type: 'Unidom::Certificate::Certificated::Mock'
         | 
| 10 | 
            +
                  }
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                certificating_2_attribtues = {
         | 
| 13 | 
            +
                    certificator_id:   SecureRandom.uuid,
         | 
| 14 | 
            +
                    certificator_type: 'Unidom::Certificate::Certificator::Mock',
         | 
| 15 | 
            +
                    certificated_id:   SecureRandom.uuid,
         | 
| 16 | 
            +
                    certificated_type: 'Unidom::Certificate::Certificated::Mock'
         | 
| 17 | 
            +
                  }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                it_behaves_like 'has_many', model_attributes, :certificatings, Unidom::Certificate::Certificating, [ certificating_1_attribtues, certificating_2_attribtues ]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            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:  | 
| 4 | 
            +
              version: 2.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: 2017- | 
| 11 | 
            +
            date: 2017-03-25 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: unidom-common
         | 
| @@ -51,10 +51,13 @@ files: | |
| 51 51 | 
             
            - config/routes.rb
         | 
| 52 52 | 
             
            - db/migrate/20010201000000_create_unidom_certificatings.rb
         | 
| 53 53 | 
             
            - lib/rspec/models/unidom/certificate/certificating_spec.rb
         | 
| 54 | 
            +
            - lib/rspec/models/unidom/certificate/concerns/as_certificated_shared_examples.rb
         | 
| 55 | 
            +
            - lib/rspec/models/unidom/certificate/concerns/as_certification_shared_examples.rb
         | 
| 54 56 | 
             
            - lib/tasks/certificate_tasks.rake
         | 
| 55 57 | 
             
            - lib/unidom/certificate.rb
         | 
| 56 58 | 
             
            - lib/unidom/certificate/engine.rb
         | 
| 57 59 | 
             
            - lib/unidom/certificate/models_rspec.rb
         | 
| 60 | 
            +
            - lib/unidom/certificate/rspec_shared_examples.rb
         | 
| 58 61 | 
             
            - lib/unidom/certificate/types_rspec.rb
         | 
| 59 62 | 
             
            - lib/unidom/certificate/validators_rspec.rb
         | 
| 60 63 | 
             
            - lib/unidom/certificate/version.rb
         |