unidom-common 1.3 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +76 -0
- data/app/models/unidom/common/concerns/model_extension.rb +8 -0
- data/lib/unidom/common/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46f0e637b8fede019f80dea128b1aaff90f7901d
|
4
|
+
data.tar.gz: b7604abc60c3c05f6163368ea9e28d6cb4cba41d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca5afb8e0c42bd8da40546735edaa919357fefe4f0745161abc30b8738596d59c5d020be9ed210c770355a32b2c3f1cf0a9495c43a20bbf49b7e80ee556e0695
|
7
|
+
data.tar.gz: ed2bc11249d6934302d5e202b7e5806bc132df713ba7c66be62075d535b856cfa32e23f7a39684ce115515c524176675ef32915e4b31f64480807b3dcb5aa570
|
data/README.md
CHANGED
@@ -7,28 +7,43 @@
|
|
7
7
|
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Common domain model engine includes the common models.
|
8
8
|
Unidom (统一领域对象模型)是一系列的领域模型引擎。常用领域模型引擎包括一些常用的模型。
|
9
9
|
|
10
|
+
|
11
|
+
|
10
12
|
## Recent Update
|
13
|
+
|
11
14
|
Check out the [Road Map](ROADMAP.md) to find out what's the next.
|
12
15
|
Check out the [Change Log](CHANGELOG.md) to find out what's new.
|
13
16
|
|
17
|
+
|
18
|
+
|
14
19
|
## Usage in Gemfile
|
20
|
+
|
15
21
|
```ruby
|
16
22
|
gem 'unidom-common'
|
17
23
|
```
|
18
24
|
|
25
|
+
|
26
|
+
|
19
27
|
## Run the Database Migration
|
28
|
+
|
20
29
|
```shell
|
21
30
|
rake db:migrate
|
22
31
|
```
|
23
32
|
The migration versions starts with 200001.
|
24
33
|
The migration enabled the PostgreSQL uuid-ossp extension.
|
25
34
|
|
35
|
+
|
36
|
+
|
26
37
|
## Include Concern in Models
|
38
|
+
|
27
39
|
```ruby
|
28
40
|
include Unidom::Common::Concerns::ModelExtension
|
29
41
|
```
|
30
42
|
|
43
|
+
|
44
|
+
|
31
45
|
## Model Extension concern
|
46
|
+
|
32
47
|
```ruby
|
33
48
|
class Project < ActiveRecord::Base
|
34
49
|
|
@@ -39,9 +54,17 @@ class Project < ActiveRecord::Base
|
|
39
54
|
|
40
55
|
belongs_to :customer
|
41
56
|
belongs_to :team
|
57
|
+
belongs_to :place
|
42
58
|
|
43
59
|
# other fields: code, description
|
44
60
|
|
61
|
+
def kick_off(in: nil)
|
62
|
+
assert_present! :in, in
|
63
|
+
# An argument error is raised if in is blank.
|
64
|
+
|
65
|
+
self.place = in
|
66
|
+
end
|
67
|
+
|
45
68
|
end
|
46
69
|
|
47
70
|
Project.coded_as('JIRA').valid_at(Time.now).alive(true) # Same as Project.coded_as('JIRA').valid_at.alive
|
@@ -54,7 +77,10 @@ Project.created_not_before('2015-01-01 00:00:00')
|
|
54
77
|
Project.audition_transited_to('A').transited_to('C')
|
55
78
|
```
|
56
79
|
|
80
|
+
|
81
|
+
|
57
82
|
## No-SQL Columns
|
83
|
+
|
58
84
|
```ruby
|
59
85
|
class Project < ActiveRecord::Base
|
60
86
|
|
@@ -81,7 +107,10 @@ project.enabled? # true
|
|
81
107
|
Project.notation_boolean_column_where(:enabled, true) # All enabled projects
|
82
108
|
```
|
83
109
|
|
110
|
+
|
111
|
+
|
84
112
|
## Numeration
|
113
|
+
|
85
114
|
```ruby
|
86
115
|
binary = 'some string'
|
87
116
|
hex = Unidom::Common::Numeration.hex binary # "736f6d6520737472696e67"
|
@@ -91,7 +120,10 @@ text = Unidom::Common::Numeration.rev_hex hex # "some string"
|
|
91
120
|
# convert a hex string to its text value
|
92
121
|
```
|
93
122
|
|
123
|
+
|
124
|
+
|
94
125
|
## AES 256 Cryptor
|
126
|
+
|
95
127
|
```ruby
|
96
128
|
class IdentityCard
|
97
129
|
|
@@ -126,7 +158,10 @@ decrypted = identity_card.decrypt_identification_number
|
|
126
158
|
# The AES 256 Cryptor also has the #hex_encrypt and the #hex_decrypt methods
|
127
159
|
```
|
128
160
|
|
161
|
+
|
162
|
+
|
129
163
|
## MD 5 Digester
|
164
|
+
|
130
165
|
```ruby
|
131
166
|
class IdentityCard
|
132
167
|
|
@@ -153,7 +188,10 @@ hex_digested = identity_card.hex_digest_identification_number
|
|
153
188
|
hex_digested == Unidom::Common::Numeration.hex digested # true
|
154
189
|
```
|
155
190
|
|
191
|
+
|
192
|
+
|
156
193
|
## SHA 256 Digester
|
194
|
+
|
157
195
|
```ruby
|
158
196
|
class IdentityCard
|
159
197
|
|
@@ -180,7 +218,10 @@ hex_digested = identity_card.hex_digest_identification_number
|
|
180
218
|
hex_digested == Unidom::Common::Numeration.hex digested # true
|
181
219
|
```
|
182
220
|
|
221
|
+
|
222
|
+
|
183
223
|
## SHA 384 Digester
|
224
|
+
|
184
225
|
```ruby
|
185
226
|
class IdentityCard
|
186
227
|
|
@@ -207,7 +248,10 @@ hex_digested = identity_card.hex_digest_identification_number
|
|
207
248
|
hex_digested == Unidom::Common::Numeration.hex digested # true
|
208
249
|
```
|
209
250
|
|
251
|
+
|
252
|
+
|
210
253
|
## SHA 512 Digester
|
254
|
+
|
211
255
|
```ruby
|
212
256
|
class IdentityCard
|
213
257
|
|
@@ -235,7 +279,9 @@ hex_digested == Unidom::Common::Numeration.hex digested # true
|
|
235
279
|
```
|
236
280
|
|
237
281
|
|
282
|
+
|
238
283
|
## SHA 1 Digester
|
284
|
+
|
239
285
|
```ruby
|
240
286
|
class IdentityCard
|
241
287
|
|
@@ -263,7 +309,9 @@ hex_digested == Unidom::Common::Numeration.hex digested # true
|
|
263
309
|
```
|
264
310
|
|
265
311
|
|
312
|
+
|
266
313
|
## SHA 2 Digester
|
314
|
+
|
267
315
|
```ruby
|
268
316
|
class IdentityCard
|
269
317
|
|
@@ -291,7 +339,9 @@ hex_digested == Unidom::Common::Numeration.hex digested # true
|
|
291
339
|
```
|
292
340
|
|
293
341
|
|
342
|
+
|
294
343
|
## ActiveRecord Migration Naming Convention
|
344
|
+
|
295
345
|
### Domain Models (200YMMDDHHMMSS)
|
296
346
|
|
297
347
|
<table class='table table-striped table-hover'>
|
@@ -351,6 +401,18 @@ hex_digested == Unidom::Common::Numeration.hex digested # true
|
|
351
401
|
<td>The Authorization domain model engine includes the Permission and Authorizing models. 授权领域模型引擎包括权限、授权的模型。</td>
|
352
402
|
</tr>
|
353
403
|
|
404
|
+
<tr>
|
405
|
+
<td>[![unidom-action](https://badge.fury.io/rb/unidom-action.svg)](https://github.com/topbitdu/unidom-action)</td>
|
406
|
+
<td>200005DDHHMMSS</td>
|
407
|
+
<td>
|
408
|
+
- Reason
|
409
|
+
- State Transition
|
410
|
+
- Obsolescence
|
411
|
+
- Acting
|
412
|
+
</td>
|
413
|
+
<td>The Action domain model engine includes the Reason, State Transition, Obsolescene, and the Acting models. 审计领域模型引擎包括原因、状态迁移、废弃和行为日志的模型。</td>
|
414
|
+
</tr>
|
415
|
+
|
354
416
|
<tr>
|
355
417
|
<td>[![unidom-standard](https://badge.fury.io/rb/unidom-standard.svg)](https://github.com/topbitdu/unidom-standard)</td>
|
356
418
|
<td>200006DDHHMMSS</td>
|
@@ -469,6 +531,19 @@ hex_digested == Unidom::Common::Numeration.hex digested # true
|
|
469
531
|
<td>The Inventory domain model engine includes the Serialized Inventory Item, the Grouped Inventory Item, the Lot, and the Inventory Item Variance models. 库存领域模型引擎包括序列化库存项、分组库存项、批量和库存项变化的模型。</td>
|
470
532
|
</tr>
|
471
533
|
|
534
|
+
<tr>
|
535
|
+
<td>[![unidom-shipment](https://badge.fury.io/rb/unidom-shipment.svg)](https://github.com/topbitdu/unidom-shipment)</td>
|
536
|
+
<td>200210DDHHMMSS</td>
|
537
|
+
<td>
|
538
|
+
- Shipment
|
539
|
+
- Shipment Item
|
540
|
+
- Shipment Package
|
541
|
+
- Shipment Package Item
|
542
|
+
- Shipment Receipt
|
543
|
+
</td>
|
544
|
+
<td>The Shipment domain model engine includes the Shipment, Shipment Item, Shipment Package, Shipment Package Item, and Shipment Receipt model. 装运领域模型引擎包括装运、装运项、装运包裹、装运包裹项、装运收据的模型。</td>
|
545
|
+
</tr>
|
546
|
+
|
472
547
|
|
473
548
|
<tr>
|
474
549
|
<td>[![unidom-position](https://badge.fury.io/rb/unidom-position.svg)](https://github.com/topbitdu/unidom-position)</td>
|
@@ -497,6 +572,7 @@ hex_digested == Unidom::Common::Numeration.hex digested # true
|
|
497
572
|
</table>
|
498
573
|
|
499
574
|
### Country Extensions (200YMM9NNNMMSS)
|
575
|
+
|
500
576
|
The YMM part should be identical to the relative part of the Domain Models.
|
501
577
|
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").
|
502
578
|
The numeric code of China is 156.
|
@@ -136,6 +136,10 @@ module Unidom::Common::Concerns::ModelExtension
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
+
def assert_present!(name, value)
|
140
|
+
raise ArgumentError.new("The #{name} argument is required.") if value.blank?
|
141
|
+
end
|
142
|
+
|
139
143
|
end
|
140
144
|
|
141
145
|
module ClassMethods
|
@@ -174,6 +178,10 @@ module Unidom::Common::Concerns::ModelExtension
|
|
174
178
|
end
|
175
179
|
end
|
176
180
|
|
181
|
+
def assert_present!(name, value)
|
182
|
+
raise ArgumentError.new("The #{name} argument is required.") if value.blank?
|
183
|
+
end
|
184
|
+
|
177
185
|
end
|
178
186
|
|
179
187
|
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
|
+
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: 2016-09-
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|