unidom-common 1.8.1 → 1.9

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: a39c274e0f9c5c3572704431ab88e4011c098c94
4
- data.tar.gz: 7c87c54ad829788f50d9cac1b2c77487e17e52a5
3
+ metadata.gz: ad1d0c055e4f13bc289e6240df3dae2a26709b39
4
+ data.tar.gz: 2a7990041421f9e424064f6c49196c9b363c7348
5
5
  SHA512:
6
- metadata.gz: 5b2bfaee716b742cc492ff05a5f52a7b8bda9d12f63c4f4e4b99491ebbb476bc0bc99315d92e92d522e9f9b5219d7f3f35369f9f5a0be7d810fe6010ef072202
7
- data.tar.gz: d25023c343991eefb5d1239f4ae6f39ff3bf3912a61c6efce80e0f2e68af38a4686fe70f0626c9b013150bc8ded5763f905b5b121e71d67fb119fe99a8d5fed9
6
+ metadata.gz: e35ed9517822efd61fa2dcfa76ccb92506c03d379dff91843b2d80f173a3622db60c6110ab0c1bf98078478c9b70c04573ff488471f3b7ac02681fa6a9e78f38
7
+ data.tar.gz: 9a9bfcc2f17fd5bfac5d4a0249a5b8f6a7ebdf33d5841f6a84e60ee495cc902d4253d9493cdfe290d90e27d80195d1b3d8d14f12960256e4ef5d9fd9bc4b5a4e
data/README.md CHANGED
@@ -810,3 +810,22 @@ The numeric code of China is 156.
810
810
  * unidom-certificate-china: 2001029156MMSS
811
811
  * unidom-contact-china: 2001039156MMSS
812
812
  * unidom-geo-china: 2001049156MMSS
813
+
814
+
815
+
816
+ ## Configuration
817
+
818
+ unidom-common and its relative Ruby gems are configurable. Create your own ``config/initializers/unidom.rb`` file in your project as following:
819
+ ```ruby
820
+ Unidom::Common.configure do |options|
821
+
822
+ # The migrations inside the following namespaces will be ignored. The models inside the following namespaces won't be defined.
823
+ options[:neglected_namespaces] = %w{
824
+ Unidom::Party
825
+ Unidom::Visitor
826
+ }
827
+
828
+ end
829
+ ```
830
+ The Unidom::Party::Person, the Unidom::Visitor::User, and other models under the listed namespaces won't be defined. Their migrations won't run.
831
+ But the models under the Unidom::Party::China namespace, if there is any, are defined, and their migrations will run as usual.
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application controller 是模块内所有控制器的基类。
3
+
1
4
  class Unidom::Common::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::Common::ApplicationJob < ActiveJob::Base
2
5
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application mailer 是模块内所有电子邮件发送类的基类。
3
+
1
4
  class Unidom::Common::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::Common::ApplicationRecord < ActiveRecord::Base
2
5
  self.abstract_class = true
3
6
  end
@@ -16,7 +16,6 @@ module Unidom
16
16
  #FROM_DATE = '1970-01-01'.freeze
17
17
  #THRU_DATE = '3000-01-01'.freeze
18
18
 
19
- =begin
20
19
  mattr_accessor :options
21
20
 
22
21
  def self.configure
@@ -25,18 +24,17 @@ module Unidom
25
24
  yield options
26
25
 
27
26
  default_options = {
28
- ignored_migration_namespaces: []
27
+ neglected_namespaces: []
29
28
  }
30
29
  self.options = default_options.merge options
31
30
 
32
31
  puts 'Unidom::Common:'
33
- if self.options[:ignored_migration_namespaces].present?
34
- puts '-- ignored_migration_namespaces'
35
- puts " -> #{self.options[:ignored_migration_namespaces].join ', '}"
32
+ if self.options[:neglected_namespaces].present?
33
+ puts '-- neglected_namespaces'
34
+ puts " -> #{self.options[:neglected_namespaces].join ', '}"
36
35
  end
37
36
 
38
37
  end
39
- =end
40
38
 
41
39
  end
42
40
  end
@@ -22,7 +22,7 @@ module Unidom::Common::EngineExtension
22
22
 
23
23
  if migration_enabled
24
24
  initializer :append_migrations do |app|
25
- config.paths['db/migrate'].expanded.each { |expanded_path| app.config.paths['db/migrate'] << expanded_path } unless app.root.to_s.match root.to_s
25
+ config.paths['db/migrate'].expanded.each { |expanded_path| app.config.paths['db/migrate'] << expanded_path } unless Unidom::Common::Neglection.namespace_neglected?(self.class.name)||app.root.to_s.match(root.to_s)
26
26
  end
27
27
  end
28
28
 
@@ -0,0 +1,7 @@
1
+ class Unidom::Common::Neglection
2
+
3
+ def self.namespace_neglected?(class_name)
4
+ Unidom::Common.options[:neglected_namespaces].include? class_name.to_s.deconstantize
5
+ end
6
+
7
+ end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Common
3
- VERSION = '1.8.1'.freeze
3
+ VERSION = '1.9'.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.8.1
4
+ version: '1.9'
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-12 00:00:00.000000000 Z
11
+ date: 2017-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -119,6 +119,7 @@ files:
119
119
  - lib/unidom/common/data_helper.rb
120
120
  - lib/unidom/common/engine.rb
121
121
  - lib/unidom/common/engine_extension.rb
122
+ - lib/unidom/common/neglection.rb
122
123
  - lib/unidom/common/numeration.rb
123
124
  - lib/unidom/common/version.rb
124
125
  - lib/unidom/common/yaml_helper.rb