unidom-common 0.2 → 0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45cf624b211946c52147a9822064f2595275a35a
4
- data.tar.gz: 2395a2969d1650d45f53d3ba88e389729f375e9e
3
+ metadata.gz: b762a8f1dd896cb9b2aedf15951e45078d187005
4
+ data.tar.gz: 12594c213dd5c99097c8b4db93d3a20fdd92f5d9
5
5
  SHA512:
6
- metadata.gz: 671a636ce38f60174a94b7a2877ecb3f75b03d31d6d388b5541cdbb8b780e72d1f8c7e8e0b164adcde148962a5bad30b2a8dd1eded3e77d8b07467c387e99a44
7
- data.tar.gz: e03c9f872b63da3ef19a647dd3959241a84e6d57bac161c45dfd7e5239784cbc820b4402e47ef7c52cb89fc2e34dc1d2d3b4730b49c6a9e933924b101f2724ce
6
+ metadata.gz: 840850a62bd7c587f1526a84a2ab3014953fab5186ed4099dc93f228bd172263727b70ed129076410b83d9b9cdec7d2b7094cd7478b1064d47387c66f8dffe65
7
+ data.tar.gz: 24bd5269ad107265bd9dbaefb9d62d36b21bea802af5716c02741f22c7c938463d6a58bc99a1b2bb90b305b72858e6b56a907c6ca8fc4840b4eb16514a598f4f
data/README.md CHANGED
@@ -1,18 +1,43 @@
1
- # Unidom Common
1
+ # Unidom Common 常用领域模型引擎
2
+
3
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
4
+ [![Gem Version](https://badge.fury.io/rb/unidom-common.svg)](https://badge.fury.io/rb/unidom-common)
2
5
 
3
6
  Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Common domain model engine includes the common models.
4
7
  Unidom (统一领域对象模型)是一系列的领域模型引擎。常用领域模型引擎包括一些常用的模型。
5
8
 
6
- ## Usage in Gemfile:
9
+ ## Usage in Gemfile
7
10
  ```ruby
8
11
  gem 'unidom-common'
9
12
  ```
10
- ## Run the Database Migration:
13
+
14
+ ## Run the Database Migration
11
15
  ```shell
12
16
  rake db:migrate
13
17
  ```
18
+ The migration enabled the PostgreSQL uuid-ossp extension.
14
19
 
15
- ## Include Concern in Models:
20
+ ## Include Concern in Models
16
21
  ```ruby
17
22
  include Unidom::Common::Concerns::ModelExtension
18
23
  ```
24
+
25
+ ## Auto Generated Methods
26
+ ```ruby
27
+ class Project < ActiveRecord::Base
28
+
29
+ include Unidom::Common::Concerns::ModelExtension
30
+
31
+ validates :name, presence: true, length: { in: 2..200 }
32
+
33
+ belongs_to :customer
34
+ belongs_to :team
35
+
36
+ # other fields: code, description
37
+
38
+ end
39
+
40
+ Project.coded_as('JIRA').valid_at(Time.now).alive(true) # Same as Project.coded_as('JIRA').valid_at.alive
41
+ team.projects.valid_during('2015-01-01'..'2015-12-31').dead
42
+ Project.included_by([ id_1, id_2 ]).excluded_by id_3
43
+ ```
@@ -72,6 +72,7 @@ module Unidom
72
72
  class_eval do
73
73
  if columns_hash[name].null
74
74
  validates name.to_sym, allow_blank: true, length: { maximum: columns_hash[name].limit }
75
+ scope "#{name}_length_is".to_sym, ->(length) { where "LENGTH(#{name}) = :length", length: length }
75
76
  else
76
77
  validates name.to_sym, presence: true, length: { is: columns_hash[name].limit }
77
78
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Common
3
- VERSION = '0.2'.freeze
3
+ VERSION = '0.3'.freeze
4
4
  end
5
5
  end
data/lib/unidom/common.rb CHANGED
@@ -3,5 +3,6 @@ require 'unidom/common/engine'
3
3
  module Unidom
4
4
  module Common
5
5
  NULL_UUID = '00000000-0000-0000-0000-000000000000'.freeze
6
+ SELF = '~'.freeze
6
7
  end
7
8
  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: '0.2'
4
+ version: '0.3'
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-01-22 00:00:00.000000000 Z
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency