kithe 2.6.0 → 2.7.0
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 +4 -4
- data/README.md +1 -1
- data/app/models/kithe/model.rb +2 -3
- data/lib/kithe/engine.rb +19 -0
- data/lib/kithe/sti_preload.rb +13 -5
- data/lib/kithe/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f8937387847f42ce3ae1327cd25ac029e38be0a5b821ef0dc45aeeef04d6de7
|
4
|
+
data.tar.gz: 1417b0de61a7a78e1f9ad8b162d766e667b52f89d18b87878390ffbd05b8011b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfd282cf508978df374b23f51ee90f3389b5f5a061ad15a03bb12555776232c0bc8f9f825cc9ea9854dac0954528829d0eccc430aa76fb9eb30694c16f83fc84
|
7
|
+
data.tar.gz: 7d6833edbdb186b547d5d4f57e38fa39224ad797cbfd760c309d9a23bdb3ad8488b0c19aeb7cfe6f799ae946342f9e38172055df231e2a2272c992f6dc376333
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ So you want to start an app that uses kithe. We should later provide better 'get
|
|
46
46
|
|
47
47
|
* Kithe view support generally assumes your app uses bootstrap 4, and uses [simple form](https://github.com/plataformatec/simple_form) configured with bootstrap settings. See https://github.com/plataformatec/simple_form#bootstrap . So you should install simple_form and bootstrap 4.
|
48
48
|
|
49
|
-
* Specific additional pre-requisites/requirements can sometimes be found in individual feature docs. And include the Javascript from [cocoon](https://github.com/nathanvda/cocoon), for form support for repeatable-field editing forms.
|
49
|
+
* Specific additional pre-requisites/requirements can sometimes be found in individual feature docs. And include the Javascript from [cocoon](https://github.com/nathanvda/cocoon), for form support for repeatable-field editing forms. (Only needs cocoon-compatible javascript, so you can use via NPM package without actually using the cocoon gem!)
|
50
50
|
|
51
51
|
|
52
52
|
## Why kithe?
|
data/app/models/kithe/model.rb
CHANGED
@@ -32,9 +32,8 @@ class Kithe::Model < ActiveRecord::Base
|
|
32
32
|
# this should only apply to Works, but we define it here so we can preload it
|
33
33
|
# when fetching all Kithe::Model. And it's to Kithe::Model so it can include
|
34
34
|
# both Works and Assets. We do some app-level validation to try and make it used
|
35
|
-
# as intended.
|
36
|
-
has_many :members,
|
37
|
-
class_name: "Kithe::Model", foreign_key: :parent_id,
|
35
|
+
# as intended.
|
36
|
+
has_many :members, class_name: "Kithe::Model", foreign_key: :parent_id,
|
38
37
|
inverse_of: :parent, dependent: :destroy
|
39
38
|
|
40
39
|
belongs_to :parent, class_name: "Kithe::Model", inverse_of: :members, optional: true
|
data/lib/kithe/engine.rb
CHANGED
@@ -15,6 +15,25 @@ require "kithe/config_base"
|
|
15
15
|
|
16
16
|
module Kithe
|
17
17
|
class Engine < ::Rails::Engine
|
18
|
+
|
19
|
+
# Rails Single-table-inheritance auto-load workaround, further worked around
|
20
|
+
# for Rails 7.
|
21
|
+
#
|
22
|
+
# https://github.com/rails/rails/issues/46625
|
23
|
+
# https://github.com/rails/rails/issues/45307
|
24
|
+
#
|
25
|
+
# Descendants wont' be pre-loaded during initialization, but this is the best
|
26
|
+
# we can do.
|
27
|
+
initializer ("kithe.preload_single_table_inheritance") do
|
28
|
+
unless false && Rails.configuration.cache_classes && Rails.configuration.eager_load
|
29
|
+
Rails.configuration.to_prepare do
|
30
|
+
Kithe::Model.preload_sti unless Kithe::Model.preloaded
|
31
|
+
rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid => e
|
32
|
+
Rails.logger.debug("Could not pre-load Kithe::Models Single-Table Inheritance descendents: #{e.inspect}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
18
37
|
config.generators do |g|
|
19
38
|
g.test_framework :rspec, :fixture => false
|
20
39
|
g.fixture_replacement :factory_bot, :dir => 'spec/factories'
|
data/lib/kithe/sti_preload.rb
CHANGED
@@ -8,8 +8,13 @@ module Kithe
|
|
8
8
|
# on particular inheritance hieararchies.
|
9
9
|
#
|
10
10
|
# We include in our Kithe::Model, which uses Single-Table Inheritance
|
11
|
+
#
|
12
|
+
# BUT NOTE: What's in Rails Guide right now actually breaks in Rails 7.
|
13
|
+
#
|
14
|
+
# We've messed with based on https://github.com/rails/rails/issues/45307 et al.
|
15
|
+
#
|
11
16
|
module StiPreload
|
12
|
-
unless Rails.
|
17
|
+
unless Rails.configuration.cache_classes && Rails.configuration.eager_load
|
13
18
|
extend ActiveSupport::Concern
|
14
19
|
|
15
20
|
included do
|
@@ -17,10 +22,13 @@ module Kithe
|
|
17
22
|
end
|
18
23
|
|
19
24
|
class_methods do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
25
|
+
|
26
|
+
# For Rails 7, this now breaks; we work around with an after_initialize hook
|
27
|
+
# in ./kithe/engine.rb . See more links there.
|
28
|
+
# def descendants
|
29
|
+
# preload_sti unless preloaded
|
30
|
+
# super
|
31
|
+
# end
|
24
32
|
|
25
33
|
# Constantizes all types present in the database. There might be more on
|
26
34
|
# disk, but that does not matter in practice as far as the STI API is
|
data/lib/kithe/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kithe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|