README.md in unidom-common-1.3 vs README.md in unidom-common-1.4
- old
+ new
@@ -5,45 +5,68 @@
[![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-common.svg)](https://gemnasium.com/github.com/topbitdu/unidom-common)
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Common domain model engine includes the common models.
Unidom (统一领域对象模型)是一系列的领域模型引擎。常用领域模型引擎包括一些常用的模型。
+
+
## Recent Update
+
Check out the [Road Map](ROADMAP.md) to find out what's the next.
Check out the [Change Log](CHANGELOG.md) to find out what's new.
+
+
## Usage in Gemfile
+
```ruby
gem 'unidom-common'
```
+
+
## Run the Database Migration
+
```shell
rake db:migrate
```
The migration versions starts with 200001.
The migration enabled the PostgreSQL uuid-ossp extension.
+
+
## Include Concern in Models
+
```ruby
include Unidom::Common::Concerns::ModelExtension
```
+
+
## Model Extension concern
+
```ruby
class Project < ActiveRecord::Base
include Unidom::Common::Concerns::ModelExtension
validates :name, presence: true, length: { in: 2..200 }
validates :audition_state, presence: true, length: { is: 1 }
belongs_to :customer
belongs_to :team
+ belongs_to :place
# other fields: code, description
+ def kick_off(in: nil)
+ assert_present! :in, in
+ # An argument error is raised if in is blank.
+
+ self.place = in
+ end
+
end
Project.coded_as('JIRA').valid_at(Time.now).alive(true) # Same as Project.coded_as('JIRA').valid_at.alive
team.projects.valid_during('2015-01-01'..'2015-12-31').dead
Project.included_by([ id_1, id_2 ]).excluded_by id_3
@@ -52,11 +75,14 @@
Project.created_before('2015-01-01 00:00:00')
Project.created_not_before('2015-01-01 00:00:00')
Project.audition_transited_to('A').transited_to('C')
```
+
+
## No-SQL Columns
+
```ruby
class Project < ActiveRecord::Base
include Unidom::Common::Concerns::ModelExtension
@@ -79,21 +105,27 @@
project.enabled? # true
Project.notation_boolean_column_where(:enabled, true) # All enabled projects
```
+
+
## Numeration
+
```ruby
binary = 'some string'
hex = Unidom::Common::Numeration.hex binary # "736f6d6520737472696e67"
# convert a binary (usually a string) to it's hex string
text = Unidom::Common::Numeration.rev_hex hex # "some string"
# convert a hex string to its text value
```
+
+
## AES 256 Cryptor
+
```ruby
class IdentityCard
include Unidom::Common::Concerns::Aes256Cryptor
attr_accessor :identification_number, :encrypted_identification_number
@@ -124,11 +156,14 @@
decrypted = identity_card.decrypt_identification_number
# The decrypted should equal to identification_number
# The AES 256 Cryptor also has the #hex_encrypt and the #hex_decrypt methods
```
+
+
## MD 5 Digester
+
```ruby
class IdentityCard
include Unidom::Common::Concerns::Md5Digester
attr_accessor :identification_number
@@ -151,11 +186,14 @@
digested = identity_card.digest_identification_number
hex_digested = identity_card.hex_digest_identification_number
hex_digested == Unidom::Common::Numeration.hex digested # true
```
+
+
## SHA 256 Digester
+
```ruby
class IdentityCard
include Unidom::Common::Concerns::Sha256Digester
attr_accessor :identification_number
@@ -178,11 +216,14 @@
digested = identity_card.digest_identification_number
hex_digested = identity_card.hex_digest_identification_number
hex_digested == Unidom::Common::Numeration.hex digested # true
```
+
+
## SHA 384 Digester
+
```ruby
class IdentityCard
include Unidom::Common::Concerns::Sha384Digester
attr_accessor :identification_number
@@ -205,11 +246,14 @@
digested = identity_card.digest_identification_number
hex_digested = identity_card.hex_digest_identification_number
hex_digested == Unidom::Common::Numeration.hex digested # true
```
+
+
## SHA 512 Digester
+
```ruby
class IdentityCard
include Unidom::Common::Concerns::Sha512Digester
attr_accessor :identification_number
@@ -233,11 +277,13 @@
hex_digested = identity_card.hex_digest_identification_number
hex_digested == Unidom::Common::Numeration.hex digested # true
```
+
## SHA 1 Digester
+
```ruby
class IdentityCard
include Unidom::Common::Concerns::Sha1Digester
attr_accessor :identification_number
@@ -261,11 +307,13 @@
hex_digested = identity_card.hex_digest_identification_number
hex_digested == Unidom::Common::Numeration.hex digested # true
```
+
## SHA 2 Digester
+
```ruby
class IdentityCard
include Unidom::Common::Concerns::Sha1Digester
attr_accessor :identification_number
@@ -289,11 +337,13 @@
hex_digested = identity_card.hex_digest_identification_number
hex_digested == Unidom::Common::Numeration.hex digested # true
```
+
## ActiveRecord Migration Naming Convention
+
### Domain Models (200YMMDDHHMMSS)
<table class='table table-striped table-hover'>
<caption></caption>
<thead>
@@ -350,10 +400,22 @@
</td>
<td>The Authorization domain model engine includes the Permission and Authorizing models. 授权领域模型引擎包括权限、授权的模型。</td>
</tr>
<tr>
+ <td>[![unidom-action](https://badge.fury.io/rb/unidom-action.svg)](https://github.com/topbitdu/unidom-action)</td>
+ <td>200005DDHHMMSS</td>
+ <td>
+ - Reason
+ - State Transition
+ - Obsolescence
+ - Acting
+ </td>
+ <td>The Action domain model engine includes the Reason, State Transition, Obsolescene, and the Acting models. 审计领域模型引擎包括原因、状态迁移、废弃和行为日志的模型。</td>
+ </tr>
+
+ <tr>
<td>[![unidom-standard](https://badge.fury.io/rb/unidom-standard.svg)](https://github.com/topbitdu/unidom-standard)</td>
<td>200006DDHHMMSS</td>
<td>
- Standard
- Standard Associating
@@ -467,11 +529,24 @@
- Inventory Item Variance
</td>
<td>The Inventory domain model engine includes the Serialized Inventory Item, the Grouped Inventory Item, the Lot, and the Inventory Item Variance models. 库存领域模型引擎包括序列化库存项、分组库存项、批量和库存项变化的模型。</td>
</tr>
+ <tr>
+ <td>[![unidom-shipment](https://badge.fury.io/rb/unidom-shipment.svg)](https://github.com/topbitdu/unidom-shipment)</td>
+ <td>200210DDHHMMSS</td>
+ <td>
+ - Shipment
+ - Shipment Item
+ - Shipment Package
+ - Shipment Package Item
+ - Shipment Receipt
+ </td>
+ <td>The Shipment domain model engine includes the Shipment, Shipment Item, Shipment Package, Shipment Package Item, and Shipment Receipt model. 装运领域模型引擎包括装运、装运项、装运包裹、装运包裹项、装运收据的模型。</td>
+ </tr>
+
<tr>
<td>[![unidom-position](https://badge.fury.io/rb/unidom-position.svg)](https://github.com/topbitdu/unidom-position)</td>
<td>200402DDHHMMSS</td>
<td>
- Occupation
@@ -495,9 +570,10 @@
</tbody>
</table>
### Country Extensions (200YMM9NNNMMSS)
+
The YMM part should be identical to the relative part of the Domain Models.
The NNN is the numeric code of [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1 "codes for the names of countries, dependent territories, and special areas of geographical interest").
The numeric code of China is 156.
* unidom-certificate-china: 2001029156MMSS
* unidom-contact-china: 2001039156MMSS