unidom-common 1.7.2 → 1.8

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: 28a8fc2b74ee9eec8f6e875a18e986da12400624
4
- data.tar.gz: f1834cc03640dffc69917c2e14e44677355ca9ef
3
+ metadata.gz: 160b4063d0e765826d03c06552720324af909359
4
+ data.tar.gz: f22d9696f68bb1b47da5e12a91115dfb60ab54f5
5
5
  SHA512:
6
- metadata.gz: d12d9206fe0ebd406d80df3184380081407a7bde2bc32a6f4cf7fb9da495379c968f1e3c3f17cff6c9153c56c2467b51f86c3050ba928ff93c12a81c5467a494
7
- data.tar.gz: 327c616410e7d17a5d5afbb1caad676f85c833e236b72f2755a88272ed4651882a1223f872a28bc72517a2fc237831329c83ee4e274cda4bd690afb156009754
6
+ metadata.gz: 2c57580fa426e2980b8ec027bb3970c19023d984dd1cec6cbef4767c7c8a12e4daaa8d56622811be0716e9485bff01612d4aadc3e1b8d4d5f6d55f10a1e4a681
7
+ data.tar.gz: 0ccfdb1bebf50723b19942db1632970e2c41b3f3ba723d0f9cf1eab9f8fe8af87962f62f056cbe35a8e1d97a296cf6d88df4a118c0eb88de56fe65db316b7255
data/README.md CHANGED
@@ -519,6 +519,19 @@ hex_digested == Unidom::Common::Numeration.hex digested # true
519
519
 
520
520
 
521
521
 
522
+ ## Engine Extension concern
523
+
524
+ ```ruby
525
+ module EngineName
526
+ class Engine < ::Rails::Engine
527
+ include Unidom::Common::EngineExtension
528
+ enable_initializer enum_enabled: true, migration_enabled: true
529
+ end
530
+ end
531
+ ```
532
+
533
+
534
+
522
535
  ## ActiveRecord Migration Naming Convention
523
536
 
524
537
  ### Domain Models (200YMMDDHHMMSS)
@@ -16,7 +16,7 @@ module Unidom::Common::Concerns::ModelExtension
16
16
  scope :transited_to, ->(states) { where state: states }
17
17
 
18
18
  scope :valid_at, ->(now: Time.now) { where "? BETWEEN #{includer.table_name}.opened_at AND #{includer.table_name}.closed_at", now }
19
- scope :valid_duration, ->(range) { where "(#{includer.table_name}.opened_at BETWEEN ? AND ?) OR (#{includer.table_name}.closed_at <= ? AND #{includer.table_name}.closed_at >= ?)", range.min, range.max, range.max, range.min }
19
+ scope :valid_duration, ->(range) { where "(#{includer.table_name}.opened_at BETWEEN ? AND ?) OR (#{includer.table_name}.closed_at <= ? AND #{includer.table_name}.closed_at >= ?)", range.min, range.max, range.max, range.min }
20
20
 
21
21
  scope :alive, ->(living: true) { where defunct: !living }
22
22
  scope :dead, ->(defunct: true) { where defunct: defunct }
@@ -0,0 +1,29 @@
1
+ module Unidom::Common::EngineExtension
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ #included do |includer|
6
+ #end
7
+
8
+ module ClassMethods
9
+
10
+ def enable_initializer(enum_enabled: false, migration_enabled: false)
11
+
12
+ if enum_enabled
13
+ require 'unidom/common/yaml_helper'
14
+ initializer :load_config_initializers do |app|
15
+ Unidom::Common::YamlHelper.load_enum config: app.config, root: config.root
16
+ end
17
+ end
18
+
19
+ if migration_enabled
20
+ initializer :append_migrations do |app|
21
+ config.paths['db/migrate'].expanded.each { |expanded_path| app.config.paths['db/migrate'] << expanded_path } unless app.root.to_s.match root.to_s
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Common
3
- VERSION = '1.7.2'.freeze
3
+ VERSION = '1.8'.freeze
4
4
  end
5
5
  end
data/lib/unidom/common.rb CHANGED
@@ -4,6 +4,8 @@ require 'unidom/common/numeration'
4
4
 
5
5
  require 'unidom/common/yaml_helper'
6
6
 
7
+ require 'unidom/common/engine_extension'
8
+
7
9
  module Unidom
8
10
  module Common
9
11
 
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.7.2
4
+ version: '1.8'
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-12-09 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -118,6 +118,7 @@ files:
118
118
  - lib/unidom/common.rb
119
119
  - lib/unidom/common/data_helper.rb
120
120
  - lib/unidom/common/engine.rb
121
+ - lib/unidom/common/engine_extension.rb
121
122
  - lib/unidom/common/numeration.rb
122
123
  - lib/unidom/common/version.rb
123
124
  - lib/unidom/common/yaml_helper.rb