kithe 2.6.0 → 2.7.0

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
  SHA256:
3
- metadata.gz: f0ca2d6002aec0accb7264e06f3abcb71f33cf5673fa3ef27bfa035cbca67195
4
- data.tar.gz: 9c5ffce36b1ff7a318059babe307627e23ccc00f6997f22a1fdc0d547cfd8a0f
3
+ metadata.gz: 9f8937387847f42ce3ae1327cd25ac029e38be0a5b821ef0dc45aeeef04d6de7
4
+ data.tar.gz: 1417b0de61a7a78e1f9ad8b162d766e667b52f89d18b87878390ffbd05b8011b
5
5
  SHA512:
6
- metadata.gz: 42129dea71f6944d2a70ca69cde8c5f1802c8915ce32cf1b237dbc6223edfcd9cefe776255cb2321c1978da8906a322e88ca443240915b6b2ee1eee53063cd42
7
- data.tar.gz: 44478b610e5eb8abda0b385932fb8528c3f6b962f77be9168391d940dac26b739c4c9ec81f1b0912123f178c19b2e2837b1cc6e68483b7c8c59d67e40f1bb8dc
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. We haven't quite figured out our preferred sane approach for sharing Javascript via kithe.
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?
@@ -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. Members are by default ordered by position, then created_at.
36
- has_many :members, -> { order(position: :asc, created_at: :asc) },
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'
@@ -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.application.config.eager_load
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
- def descendants
21
- preload_sti unless preloaded
22
- super
23
- end
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
@@ -1,3 +1,3 @@
1
1
  module Kithe
2
- VERSION = '2.6.0'
2
+ VERSION = '2.7.0'
3
3
  end
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.6.0
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-08-11 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails