unidom-category 1.5.4 → 1.5.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: 7388581cb56b65f5dfcc15ef3dcf6d5b72222e2c
4
- data.tar.gz: 6724a0d4670f5b15859c0bce6734998054aff417
3
+ metadata.gz: 3cf9e49d71c90a9c481326d894c7732dd9d11448
4
+ data.tar.gz: 90fa319d17a4d5f8c2839195efe789004a16aa41
5
5
  SHA512:
6
- metadata.gz: 01edeb37121ae0ab666556da562305beda1bff30d0d4bd14e98df689284246600d8915ad973f3d4df849351a1effac93addf21683d0b4e212f0373cbb4ac54d5
7
- data.tar.gz: 502c136c531bfe9d127179ee67c940b612a9243f5ed185aea34d3efc49b7b8de836b046604539a1620ebc0af11af66621e5fe60d725101f8dd41231e7126f132
6
+ metadata.gz: 7e1523a1109f18d34975673eb6b0389e01a22d5070c835193d3ef48efdd630648511a3b4d378cd66efe1673d16af83b7456eb9f93ed9dae2e7d8a34bfc8e5dcd
7
+ data.tar.gz: 29701235a9a5351867cfe96b8f19176286169f72c475b82e028b809d54455233bc45ee034d98b9ebabd3cdc1835d9600a6198afd03ac4b9ae8f7e0604b1df717
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Unidom Category 类别领域模型引擎
2
2
 
3
+ [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/unidom-category/frames)
3
4
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
5
+
4
6
  [![Gem Version](https://badge.fury.io/rb/unidom-category.svg)](https://badge.fury.io/rb/unidom-category)
5
7
  [![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-category.svg)](https://gemnasium.com/github.com/topbitdu/unidom-category)
6
8
 
@@ -58,31 +60,47 @@ include Unidom::Category::Concerns::AsDescendantCategory
58
60
 
59
61
  ### As Category concern
60
62
 
61
- The As Category concern do the following tasks for the includer automatically:
62
- 1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Category::Categorizing'``
63
- 2. Define the #categorize! method as: ``categorize!(categorized, at: Time.now, primary: true)``
63
+ The As Category concern do the following tasks for the includer automatically:
64
+ 1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Category::Categorizing'``
65
+ 2. Define the #categorize! method as: ``categorize!(categorized, at: Time.now, primary: true)``
64
66
  3. Define the #categorize? method as: ``categorize?(categorized, at: Time.now, primary: true)``
65
67
 
66
68
  ### As Categorized concern
67
69
 
68
- The As Categorized concern do the following tasks for the includer automatically:
69
- 1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Unidom::Category::Categorizing', as: :categorized``
70
- 2. Define the has_many :categories macro as: ``has_many :categories, through: :categorizings, source: :category``
71
- 3. Define the #is_categorized! method as: ``is_categorized!(into: nil, at: Time.now, primary: true)``
70
+ The As Categorized concern do the following tasks for the includer automatically:
71
+ 1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Unidom::Category::Categorizing', as: :categorized``
72
+ 2. Define the has_many :categories macro as: ``has_many :categories, through: :categorizings, source: :category``
73
+ 3. Define the #is_categorized! method as: ``is_categorized!(into: nil, at: Time.now, primary: true)``
72
74
  4. Define the #is_categorized? method as: ``is_categorized?(into: nil, at: Time.now, primary: true)``
73
75
 
74
76
  ### As Ancestor Category concern
75
77
 
76
- The As Ancestor Category concern do the following tasks for the includer automatically:
77
- 1. Define the has_many :descendant_category_rollups macro as: ``has_many :descendant_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :ancestor_category_id, source: :ancestor_category``
78
- 2. Define the has_many :descendant_categories macro as: ``has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups``
79
- 3. Define the #roll_up! method as: ``roll_up!(it, at: Time.now, primary: true)``
78
+ The As Ancestor Category concern do the following tasks for the includer automatically:
79
+ 1. Define the has_many :descendant_category_rollups macro as: ``has_many :descendant_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :ancestor_category_id, source: :ancestor_category``
80
+ 2. Define the has_many :descendant_categories macro as: ``has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups``
81
+ 3. Define the #roll_up! method as: ``roll_up!(it, at: Time.now, primary: true)``
80
82
  4. Define the #roll_up? method as: ``roll_up?(it, at: Time.now, primary: true)``
81
83
 
82
84
  ### As Descendant Category concern
83
85
 
84
- The As Descendant Category concern do the following tasks for the includer automatically:
85
- 1. Define the has_many :ancestor_category_rollups macro as: ``has_many :ancestor_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :descendant_category_id, source: :descendant_category``
86
- 2. Define the has_many :ancestor_categories macro as: ``has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups``
87
- 3. Define the #is_rolled_up! as: ``is_rolled_up!(it, at: Time.now, primary: true)``
86
+ The As Descendant Category concern do the following tasks for the includer automatically:
87
+ 1. Define the has_many :ancestor_category_rollups macro as: ``has_many :ancestor_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :descendant_category_id, source: :descendant_category``
88
+ 2. Define the has_many :ancestor_categories macro as: ``has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups``
89
+ 3. Define the #is_rolled_up! as: ``is_rolled_up!(it, at: Time.now, primary: true)``
88
90
  4. Define the #is_rolled_up? as: ``is_rolled_up?(it, at: Time.now, primary: true)``
91
+
92
+
93
+
94
+ ## Disable the Model & Migration
95
+
96
+ If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
97
+ ```ruby
98
+ # config/initializers/unidom.rb
99
+ Unidom::Common.configure do |options|
100
+
101
+ options[:neglected_namespaces] = %w{
102
+ Unidom::Category
103
+ }
104
+
105
+ end
106
+ ```
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application controller 是模块内所有控制器的基类。
3
+
1
4
  class Unidom::Category::ApplicationController < ActionController::Base
2
5
  protect_from_forgery with: :exception
3
6
  end
@@ -1,2 +1,5 @@
1
+ ##
2
+ # Application job 是模块内所有异步任务的基类。
3
+
1
4
  class Unidom::Category::ApplicationJob < ActiveJob::Base
2
5
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application mailer 是模块内所有电子邮件发送类的基类。
3
+
1
4
  class Unidom::Category::ApplicationMailer < ActionMailer::Base
2
5
  default from: 'from@example.com'
3
6
  layout 'mailer'
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application record 是模块内所有模型的抽象基类。
3
+
1
4
  class Unidom::Category::ApplicationRecord < ActiveRecord::Base
2
5
  self.abstract_class = true
3
6
  end
@@ -13,12 +13,8 @@ class Unidom::Category::Categorizing < Unidom::Category::ApplicationRecord
13
13
  scope :category_is, ->(category) { where category_id: to_id(category) }
14
14
  scope :categorized_is, ->(categorized) { where categorized: categorized }
15
15
 
16
- #def self.categorize!(category, categorized, opened_at = Time.now)
17
- # self.categorized_is(categorized).category_is(category).valid_at.alive.first_or_create! elemental: true, opened_at: opened_at
18
- #end
19
-
20
16
  def self.categorize!(categorized, into: nil, at: Time.now)
21
17
  categorized_is(categorized).category_is(into).valid_at.alive.first_or_create! elemental: true, opened_at: at
22
18
  end
23
19
 
24
- end
20
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::Categorizing'
@@ -19,4 +19,4 @@ class Unidom::Category::Category < Unidom::Category::ApplicationRecord
19
19
  scope :code_length_is, ->(length) { where 'LENGTH(code) = :code_length', code_length: length }
20
20
  scope :code_starting_with, ->(prefix) { where 'code LIKE :prefix_expression', prefix_expression: prefix+'%' }
21
21
 
22
- end
22
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::Category'
@@ -29,8 +29,11 @@ class Unidom::Category::CategoryRollup < Unidom::Category::ApplicationRecord
29
29
  end
30
30
  }
31
31
 
32
+ ##
33
+ # 将 it 归为 into 的下级分类,时间是 at ,缺省为当前时间。如:
34
+ # Unidom::Category::CategoryRollup.roll_up! moto, into: vehicle
32
35
  def self.roll_up!(it, into: nil, at: Time.now)
33
36
  self.descendant_category_is(it).ancestor_category_is(into).valid_at(now: at).alive.first_or_create! opened_at: at
34
37
  end
35
38
 
36
- end
39
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::CategoryRollup'
@@ -15,4 +15,4 @@ class Unidom::Category::CategoryScheme < Unidom::Category::ApplicationRecord
15
15
 
16
16
  scope :owned_by, ->(owner) { where owner: owner }
17
17
 
18
- end
18
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::CategoryScheme'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Category
3
- VERSION = '1.5.4'.freeze
3
+ VERSION = '1.5.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-category
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.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: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '1.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '1.9'
27
27
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
28
  The Category domain model engine includes Category and its relative models. Unidom
29
29
  (统一领域对象模型)是一系列的领域模型引擎。类别领域模型引擎包括类别及其相关的模型。