unidom-common 1.4 → 1.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: 46f0e637b8fede019f80dea128b1aaff90f7901d
4
- data.tar.gz: b7604abc60c3c05f6163368ea9e28d6cb4cba41d
3
+ metadata.gz: 1e44a8b8ccece3288519276076c2131e12741b95
4
+ data.tar.gz: 9b3ae6a040a4049c4fbfdaf933e6f20fa38a5ff6
5
5
  SHA512:
6
- metadata.gz: ca5afb8e0c42bd8da40546735edaa919357fefe4f0745161abc30b8738596d59c5d020be9ed210c770355a32b2c3f1cf0a9495c43a20bbf49b7e80ee556e0695
7
- data.tar.gz: ed2bc11249d6934302d5e202b7e5806bc132df713ba7c66be62075d535b856cfa32e23f7a39684ce115515c524176675ef32915e4b31f64480807b3dcb5aa570
6
+ metadata.gz: 078a2f58cc191dd3bafe0b54ba141314b092f3868d9f9e3a870a4f4f48f9c7ad409ed24110498775e633dbef8387649b3c5d770ee3ce29dac597f31c0b66844b
7
+ data.tar.gz: f24e6d3d7a65872cd0910b3aa7c098a1cbb2e1b7d41e84b50f86f0bd15e5dc351920de85eeed7b3b33fdc4895204332503cf33f37d6935d94b5bd0fc4efe782f
data/README.md CHANGED
@@ -109,6 +109,61 @@ Project.notation_boolean_column_where(:enabled, true) # All enabled projects
109
109
 
110
110
 
111
111
 
112
+ ## Exact Columns
113
+
114
+ ```ruby
115
+ # db/migrate/YYYYMMDDHHMMSS_create_people.rb
116
+ class CreatePeople < ActiveRecord::Migration[5.0]
117
+
118
+ def change
119
+
120
+ create_table :people, id: :uuid do |t|
121
+
122
+ t.string :name, null: false, default: '', limit: 200
123
+
124
+ t.string :passport_number, null: false, default: nil, limit: 200
125
+
126
+ t.binary :identification_number_exact_signature, null: false, default: nil, limit: 80
127
+ t.binary :passport_number_exact_signature, null: false, default: nil, limit: 80
128
+
129
+ t.column :state, 'char(1)', null: false, default: 'C'
130
+ t.datetime :opened_at, null: false, default: Time.utc(1970)
131
+ t.datetime :closed_at, null: false, default: Time.utc(3000)
132
+ t.boolean :defunct, null: false, default: false
133
+ t.jsonb :notation, null: false, default: {}
134
+
135
+ t.timestamps null: false
136
+
137
+ end
138
+
139
+ add_index :people, :identification_number_exact_signature, unique: true
140
+ add_index :people, :passport_number_exact_signature, unique: true
141
+
142
+ end
143
+
144
+ end
145
+
146
+ # app/models/person.rb
147
+ class Person < ApplicationRecord
148
+
149
+ include Unidom::Common::Concerns::ModelExtension
150
+
151
+ attr_accessor :identification_number
152
+ # The identification number is not stored. Only the exact signature is stored like password.
153
+ exact_column :identification_number, :passport_number
154
+ # The passport number is stored in the clear text format.
155
+
156
+ end
157
+
158
+ # in any controller or rails console:
159
+ person = Person.new name: 'Tim', identification_number: '11010119901231001X', passport_number: 'E00000000'
160
+ person.save!
161
+ Person.identification_number_is('11010119901231001X').first==person # true
162
+ Person.passport_number_is('E00000000').first==person # true
163
+ ```
164
+
165
+
166
+
112
167
  ## Numeration
113
168
 
114
169
  ```ruby
@@ -359,212 +414,248 @@ hex_digested == Unidom::Common::Numeration.hex digested # true
359
414
  <tbody>
360
415
 
361
416
  <tr>
362
- <td>[![unidom-common](https://badge.fury.io/rb/unidom-common.svg)](https://github.com/topbitdu/unidom-common)</td>
417
+ <td><a href="https://github.com/topbitdu/unidom-common">unidom-common</a></td>
363
418
  <td>200001DDHHMMSS</td>
364
419
  <td>-</td>
365
420
  <td>The Common domain model engine includes the common models. 常用领域模型引擎包括一些常用的模型。</td>
366
421
  </tr>
367
422
 
368
423
  <tr>
369
- <td>[![unidom-visitor](https://badge.fury.io/rb/unidom-visitor.svg)](https://github.com/topbitdu/unidom-visitor)</td>
424
+ <td><a href="https://github.com/topbitdu/unidom-visitor">unidom-visitor</a></td>
370
425
  <td>200002DDHHMMSS</td>
371
426
  <td>
372
- - Identificating
373
- - Authenticating
374
- - Recognization
375
- - User
376
- - Guest
377
- - Password
427
+ <ul>
428
+ <li>Identificating</li>
429
+ <li>Authenticating</li>
430
+ <li>Recognization</li>
431
+ <li>User</li>
432
+ <li>Guest</li>
433
+ <li>Password</li>
434
+ <ul>
378
435
  </td>
379
436
  <td>The Visitor domain model engine includes Identificating, Authenticating, Recognization, Visitor (User &amp; Guest), and Password models. 访问者领域模型引擎包括身份标识、身份鉴别、身份识别、访问者(用户和游客)、密码的模型。</td>
380
437
  </tr>
381
438
 
382
439
  <tr>
383
- <td>[![unidom-category](https://badge.fury.io/rb/unidom-category.svg)](https://github.com/topbitdu/unidom-category)</td>
440
+ <td><a href="https://github.com/topbitdu/unidom-category">unidom-category</a></td>
384
441
  <td>200003DDHHMMSS</td>
385
442
  <td>
386
- - Category
387
- - Categorizing
388
- - Category Rollup
389
- - Category Associating
443
+ <ul>
444
+ <li>Category</li>
445
+ <li>Categorizing</li>
446
+ <li>Category Rollup</li>
447
+ <li>Category Associating</li>
448
+ <ul>
390
449
  </td>
391
450
  <td>The Category domain model engine includes Category and its relative models. 类别领域模型引擎包括类别及其相关的模型。</td>
392
451
  </tr>
393
452
 
394
453
  <tr>
395
- <td>[![unidom-authorization](https://badge.fury.io/rb/unidom-authorization.svg)](https://github.com/topbitdu/unidom-authorization)</td>
454
+ <td><a href="https://github.com/topbitdu/unidom-authorization">unidom-authorization</a></td>
396
455
  <td>200004DDHHMMSS</td>
397
456
  <td>
398
- - Permission
399
- - Authorizing
457
+ <ul>
458
+ <li>Permission</li>
459
+ <li>Authorizing</li>
460
+ <ul>
400
461
  </td>
401
462
  <td>The Authorization domain model engine includes the Permission and Authorizing models. 授权领域模型引擎包括权限、授权的模型。</td>
402
463
  </tr>
403
464
 
404
465
  <tr>
405
- <td>[![unidom-action](https://badge.fury.io/rb/unidom-action.svg)](https://github.com/topbitdu/unidom-action)</td>
466
+ <td><a href="https://github.com/topbitdu/unidom-action">unidom-action</a></td>
406
467
  <td>200005DDHHMMSS</td>
407
468
  <td>
408
- - Reason
409
- - State Transition
410
- - Obsolescence
411
- - Acting
469
+ <ul>
470
+ <li>Reason</li>
471
+ <li>State Transition</li>
472
+ <li>Obsolescing</li>
473
+ <li>Acting</li>
474
+ </ul>
412
475
  </td>
413
- <td>The Action domain model engine includes the Reason, State Transition, Obsolescene, and the Acting models. 审计领域模型引擎包括原因、状态迁移、废弃和行为日志的模型。</td>
476
+ <td>The Action domain model engine includes the Reason, State Transition, Obsolescing, and the Acting models. 审计领域模型引擎包括原因、状态迁移、废弃和行为日志的模型。</td>
414
477
  </tr>
415
478
 
416
479
  <tr>
417
- <td>[![unidom-standard](https://badge.fury.io/rb/unidom-standard.svg)](https://github.com/topbitdu/unidom-standard)</td>
480
+ <td><a href="https://github.com/topbitdu/unidom-standard">unidom-standard</a></td>
418
481
  <td>200006DDHHMMSS</td>
419
482
  <td>
420
- - Standard
421
- - Standard Associating
483
+ <ul>
484
+ <li>Standard</li>
485
+ <li>Standard Associating</li>
486
+ </ul>
422
487
  </td>
423
488
  <td>The Standard domain model engine includes the Standard model and the Standard Associating model. 标准领域模型引擎包括行为标准和标准关联的模型。</td>
424
489
  </tr>
425
490
 
426
491
 
427
492
  <tr>
428
- <td>[![unidom-party](https://badge.fury.io/rb/unidom-party.svg)](https://github.com/topbitdu/unidom-party)</td>
493
+ <td><a href="https://github.com/topbitdu/unidom-party">unidom-party</a></td>
429
494
  <td>200101DDHHMMSS</td>
430
495
  <td>
431
- - Person
432
- - Shop
433
- - Company
434
- - Government Agency
435
- - Party Relation
496
+ <ul>
497
+ <li>Person</li>
498
+ <li>Shop</li>
499
+ <li>Company</li>
500
+ <li>Government Agency</li>
501
+ <li>Party Relation</li>
502
+ </ul>
436
503
  </td>
437
504
  <td>The Party domain model engine includes the Person, Shop, Company, Government Agency, and the Party Relation models. 参与者领域模型引擎包括个人、店铺、公司、政府机构、参与者关系的模型。</td>
438
505
  </tr>
439
506
 
440
507
  <tr>
441
- <td>[![unidom-certificate](https://badge.fury.io/rb/unidom-certificate.svg)](https://github.com/topbitdu/unidom-certificate)</td>
508
+ <td><a href="https://github.com/topbitdu/unidom-certificate">unidom-certificate</a></td>
442
509
  <td>200102DDHHMMSS</td>
443
510
  <td>
444
- - Certificating
511
+ <ul>
512
+ <li>Certificating</li>
513
+ </ul>
445
514
  </td>
446
515
  <td>The Certificate domain model engine includes the Certificating model.
447
516
  证书领域模型引擎包括证书认证的模型。</td>
448
517
  </tr>
449
518
 
450
519
  <tr>
451
- <td>[![unidom-contact](https://badge.fury.io/rb/unidom-contact.svg)](https://github.com/topbitdu/unidom-contact)</td>
520
+ <td><a href="https://github.com/topbitdu/unidom-contact">unidom-contact</a></td>
452
521
  <td>200103DDHHMMSS</td>
453
522
  <td>
454
- - Contact Subscription
455
- - Email Address
523
+ <ul>
524
+ <li>Contact Subscription</li>
525
+ <li>Email Address</li>
526
+ </ul>
456
527
  </td>
457
528
  <td>The Contact domain model engine includes the Contact Subscription and Email Address models. 联系方式领域模型引擎包括联系方式订阅和电子邮箱地址的模型。</td>
458
529
  </tr>
459
530
 
460
531
  <tr>
461
- <td>[![unidom-geo](https://badge.fury.io/rb/unidom-geo.svg)](https://github.com/topbitdu/unidom-geo)</td>
532
+ <td><a href="https://github.com/topbitdu/unidom-geo">unidom-geo</a></td>
462
533
  <td>200104DDHHMMSS</td>
463
534
  <td>
464
- - Location
465
- - Locating
535
+ <ul>
536
+ <li>Location</li>
537
+ <li>Locating</li>
538
+ </ul>
466
539
  </td>
467
540
  <td>The Geo domain model engine includes the Location and Locating models. 地理领域模型引擎包括位置和定位的模型。</td>
468
541
  </tr>
469
542
 
470
543
 
471
544
  <tr>
472
- <td>[![unidom-article_number](https://badge.fury.io/rb/unidom-article_number.svg)](https://github.com/topbitdu/unidom-article_number)</td>
545
+ <td><a href="https://github.com/topbitdu/unidom-article_number">unidom-article_number</a></td>
473
546
  <td>200201DDHHMMSS</td>
474
547
  <td>
475
- - Marking
476
- - EAN 13 Barcode
477
- - EAN 8 Barcode
548
+ <ul>
549
+ <li>Marking</li>
550
+ <li>EAN 13 Barcode</li>
551
+ <li>EAN 8 Barcode</li>
552
+ </ul>
478
553
  </td>
479
554
  <td>The Article Number domain model engine includes Marking, EAN-13, and EAN-8 models. 物品编码领域模型引擎包括打码、EAN-13和EAN-8的模型。</td>
480
555
  </tr>
481
556
 
482
557
  <tr>
483
- <td>[![unidom-product](https://badge.fury.io/rb/unidom-product.svg)](https://github.com/topbitdu/unidom-product)</td>
558
+ <td><a href="https://github.com/topbitdu/unidom-product">unidom-product</a></td>
484
559
  <td>200202DDHHMMSS</td>
485
560
  <td>
486
- - Product
487
- - Product Associating
561
+ <ul>
562
+ <li>Product</li>
563
+ <li>Product Associating</li>
564
+ </ul>
488
565
  </td>
489
566
  <td>The Product domain model engine includes Product and Produt Associating models. 产品领域模型引擎包括产品和产品关联的模型。</td>
490
567
  </tr>
491
568
 
492
569
  <tr>
493
- <td>[![unidom-price](https://badge.fury.io/rb/unidom-price.svg)](https://github.com/topbitdu/unidom-price)</td>
570
+ <td><a href="https://github.com/topbitdu/unidom-price">unidom-price</a></td>
494
571
  <td>200203DDHHMMSS</td>
495
572
  <td>
496
- - Price
573
+ <ul>
574
+ <li>Price</li>
575
+ </ul>
497
576
  </td>
498
577
  <td>The Price domain model engine includes Price and its relative models. 价格领域模型引擎包括定价及其相关的模型。</td>
499
578
  </tr>
500
579
 
501
580
  <tr>
502
- <td>[![unidom-shopping](https://badge.fury.io/rb/unidom-shopping.svg)](https://github.com/topbitdu/unidom-shopping)</td>
581
+ <td><a href="https://github.com/topbitdu/unidom-shopping">unidom-shopping</a></td>
503
582
  <td>200205DDHHMMSS</td>
504
583
  <td>
505
- - Shopping Cart
506
- - Shopping Item
584
+ <ul>
585
+ <li>Shopping Cart</li>
586
+ <li>Shopping Item</li>
587
+ </ul>
507
588
  </td>
508
589
  <td>The Shopping domain model engine includes Shopping Cart and Shopping Item models. 购物领域模型引擎包括购物车和购物项的模型。</td>
509
590
  </tr>
510
591
 
511
592
  <tr>
512
- <td>[![unidom-order](https://badge.fury.io/rb/unidom-order.svg)](https://github.com/topbitdu/unidom-order)</td>
593
+ <td><a href="https://github.com/topbitdu/unidom-order">unidom-order</a></td>
513
594
  <td>200206DDHHMMSS</td>
514
595
  <td>
515
- - Order
516
- - Order Item
517
- - Order Adjustment
596
+ <ul>
597
+ <li>Order</li>
598
+ <li>Order Item</li>
599
+ <li>Order Adjustment</li>
600
+ </ul>
518
601
  </td>
519
602
  <td>The Order domain model engine includes Order, Order Item, and Order Adjustment models. 订单领域模型引擎包括订单、订单项和订单调整的模型。</td>
520
603
  </tr>
521
604
 
522
605
  <tr>
523
- <td>[![unidom-inventory](https://badge.fury.io/rb/unidom-inventory.svg)](https://github.com/topbitdu/unidom-inventory)</td>
606
+ <td><a href="https://github.com/topbitdu/unidom-inventory">unidom-inventory</a></td>
524
607
  <td>200209DDHHMMSS</td>
525
608
  <td>
526
- - Serialized Inventory Item
527
- - Grouped Inventory Item
528
- - Lot
529
- - Inventory Item Variance
609
+ <ul>
610
+ <li>Serialized Inventory Item</li>
611
+ <li>Grouped Inventory Item</li>
612
+ <li>Lot</li>
613
+ <li>Inventory Item Variance</li>
614
+ </ul>
530
615
  </td>
531
616
  <td>The Inventory domain model engine includes the Serialized Inventory Item, the Grouped Inventory Item, the Lot, and the Inventory Item Variance models. 库存领域模型引擎包括序列化库存项、分组库存项、批量和库存项变化的模型。</td>
532
617
  </tr>
533
618
 
534
619
  <tr>
535
- <td>[![unidom-shipment](https://badge.fury.io/rb/unidom-shipment.svg)](https://github.com/topbitdu/unidom-shipment)</td>
620
+ <td><a href="https://github.com/topbitdu/unidom-shipment">unidom-shipment</a></td>
536
621
  <td>200210DDHHMMSS</td>
537
622
  <td>
538
- - Shipment
539
- - Shipment Item
540
- - Shipment Package
541
- - Shipment Package Item
542
- - Shipment Receipt
623
+ <ul>
624
+ <li>Shipment</li>
625
+ <li>Shipment Item</li>
626
+ <li>Shipment Package</li>
627
+ <li>Shipment Package Item</li>
628
+ <li>Shipment Receipt</li>
629
+ </ul>
543
630
  </td>
544
631
  <td>The Shipment domain model engine includes the Shipment, Shipment Item, Shipment Package, Shipment Package Item, and Shipment Receipt model. 装运领域模型引擎包括装运、装运项、装运包裹、装运包裹项、装运收据的模型。</td>
545
632
  </tr>
546
633
 
547
634
 
548
635
  <tr>
549
- <td>[![unidom-position](https://badge.fury.io/rb/unidom-position.svg)](https://github.com/topbitdu/unidom-position)</td>
636
+ <td><a href="https://github.com/topbitdu/unidom-position">unidom-position</a></td>
550
637
  <td>200402DDHHMMSS</td>
551
638
  <td>
552
- - Occupation
553
- - Position
554
- - Post
555
- - Position Reporting Structure
639
+ <ul>
640
+ <li>Occupation</li>
641
+ <li>Position</li>
642
+ <li>Post</li>
643
+ <li>Position Reporting Structure</li>
644
+ </ul>
556
645
  </td>
557
646
  <td>The Position domain model engine includes the Occupation, Position, Post, and Position Reporting Structure models.
558
647
  职位领域模型引擎包括职业、职位、岗位及岗位报告关系模型。</td>
559
648
  </tr>
560
649
 
561
650
  <tr>
562
- <td>[![unidom-accession](https://badge.fury.io/rb/unidom-accession.svg)](https://github.com/topbitdu/unidom-accession)</td>
651
+ <td><a href="https://github.com/topbitdu/unidom-accession">unidom-accession</a></td>
563
652
  <td>200405DDHHMMSS</td>
564
653
  <td>
565
- - Post Fulfillment
654
+ <ul>
655
+ <li>Post Fulfillment</li>
656
+ </ul>
566
657
  </td>
567
- <td>The Position domain model engine includes the Post Fulfillment and its relative models. 就职领域模型引擎包括岗位履行及其相关的模型。</td>
658
+ <td>The Accession domain model engine includes the Post Fulfillment and its relative models. 就职领域模型引擎包括岗位履行及其相关的模型。</td>
568
659
  </tr>
569
660
 
570
661
 
@@ -178,10 +178,27 @@ module Unidom::Common::Concerns::ModelExtension
178
178
  end
179
179
  end
180
180
 
181
+ def exact_column(*names)
182
+ names.each do |name|
183
+ name = name.to_s
184
+ instance_eval do
185
+ scope :"#{name}_is", ->(value) { where "#{name}_exact_signature" => exact_signature(self, name, value) }
186
+ before_save do
187
+ send "#{name}_exact_signature=", self.class.exact_signature(self.class, name, send(name))
188
+ end
189
+ end
190
+ end
191
+ end
192
+
181
193
  def assert_present!(name, value)
182
194
  raise ArgumentError.new("The #{name} argument is required.") if value.blank?
183
195
  end
184
196
 
197
+ def exact_signature(klass, name, value)
198
+ text = "#{Rails.application.secrets[:secret_key_base]}@#{Rails.root}/#{klass.table_name}##{name}=#{value}"
199
+ "#{Digest::MD5.digest(text)}#{Digest::SHA512.digest(text)}"
200
+ end
201
+
185
202
  end
186
203
 
187
204
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Common
3
- VERSION = '1.4'.freeze
3
+ VERSION = '1.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-common
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.4'
4
+ version: '1.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: 2016-09-30 00:00:00.000000000 Z
11
+ date: 2016-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails