kithe 2.0.3 → 2.1.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 +2 -0
- data/app/indexing/kithe/indexer/obj_extract.rb +2 -1
- data/app/models/kithe/validators/model_parent.rb +2 -2
- data/lib/kithe/engine.rb +8 -1
- data/lib/kithe/version.rb +1 -1
- data/lib/shrine/plugins/kithe_determine_mime_type.rb +9 -0
- metadata +4 -5
- data/lib/kithe/patch_fx.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9a96dd80fc482ea07bd35456a0cf8445b722354cd6fe1fda10460398a0d7846
|
4
|
+
data.tar.gz: 0ccb6788a1ac0f88a47202767f1a5acb7dc12031cc4293ec27e09ded198b8daf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46bcc8b60dd795e4f6e063aef6c7702184d853f2266f3fb5db4636074379faf3a45a1baae83e0d0358cea6fa8c8620a43727d9ee90cffb511c28e371072fe8ad
|
7
|
+
data.tar.gz: d4250716ef0b4c32c2b993a1989290a59afdb56be2159a8f814bd3b62bfe5e853845188b3200bc1c9be2f8c8f5bad950276e1286324d9f28d890e50c2ccf7a86
|
data/README.md
CHANGED
@@ -35,6 +35,8 @@ Some guide documentation is available to explain each of kithe's major functiona
|
|
35
35
|
* Kithe objects use UUIDv4's as internal primary keys, but also provide a "friendlier_id" with a shorter unique alphanumeric identifier for URLs and other UI. By default they are supplied by a postgres stored procedure, but your code can set them to whatever you like.
|
36
36
|
|
37
37
|
* [Form support](./guides/forms.md): Dealing with complex and _repeatable_ data, as our modelling layer allows, can be tricky in an HTML form. We supply javascript-backed Rails form input help for repeatable and compound/nested data.
|
38
|
+
* An extension to Rails "strong parameters" that make some common patterns for
|
39
|
+
embedded JSON attributes more convenient, [Kithe::Parameters](./app/models/kithe/parameters.rb).
|
38
40
|
|
39
41
|
* [File handling](./guides/file_handling.md): Handling files is at the core of digital repository use cases. We need a file handling framework that is flexible, predictable and reliable, and architected for performance. We try to give you one based on the [shrine](https://shrinerb.com) file attachment toolkit for ruby.
|
40
42
|
|
@@ -48,7 +48,8 @@ module Kithe
|
|
48
48
|
first, *rest = *path
|
49
49
|
|
50
50
|
result = if obj.kind_of?(Array)
|
51
|
-
|
51
|
+
first_path_element = path.shift # remove it from path
|
52
|
+
obj.flat_map { |item| obj_extractor(item, [first_path_element]) }
|
52
53
|
elsif obj.kind_of?(Hash)
|
53
54
|
obj[first]
|
54
55
|
else
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class Kithe::Validators::ModelParent < ActiveModel::Validator
|
2
2
|
def validate(record)
|
3
3
|
if record.parent.present? && (record.parent.class <= Kithe::Asset)
|
4
|
-
record.errors
|
4
|
+
record.errors.add(:parent, 'can not be an Asset instance')
|
5
5
|
end
|
6
6
|
|
7
7
|
if record.parent.present? && record.class <= Kithe::Collection
|
8
|
-
record.errors
|
8
|
+
record.errors.add(:parent, 'is invalid for Collection instances')
|
9
9
|
end
|
10
10
|
|
11
11
|
# TODO avoid recursive parents, maybe using a postgres CTE for efficiency?
|
data/lib/kithe/engine.rb
CHANGED
@@ -9,7 +9,6 @@ require 'shrine'
|
|
9
9
|
# https://github.com/teoljungberg/fx/issues/33
|
10
10
|
# https://github.com/teoljungberg/fx/pull/53
|
11
11
|
require 'fx'
|
12
|
-
require 'kithe/patch_fx'
|
13
12
|
|
14
13
|
# not auto-loaded, let's just load it for backwards compat though
|
15
14
|
require "kithe/config_base"
|
@@ -22,5 +21,13 @@ module Kithe
|
|
22
21
|
g.assets false
|
23
22
|
g.helper false
|
24
23
|
end
|
24
|
+
|
25
|
+
# the fx gem lets us include stored procedures in schema.rb. For it to work
|
26
|
+
# in kithe's case, the stored procedures have to be *first* in schema.rb,
|
27
|
+
# so they can then be referenced as default value for columns in tables
|
28
|
+
# subsequently created. We configure that here, forcing it for any app, yes, sorry.
|
29
|
+
Fx.configure do |config|
|
30
|
+
config.dump_functions_at_beginning_of_schema = true
|
31
|
+
end
|
25
32
|
end
|
26
33
|
end
|
data/lib/kithe/version.rb
CHANGED
@@ -19,6 +19,12 @@ class Shrine
|
|
19
19
|
# Ensure that if mime-type can't be otherwise determined, it is assigned
|
20
20
|
# "application/octet-stream", basically the type for generic binary.
|
21
21
|
class KitheDetermineMimeType
|
22
|
+
# marcel version 1.0 says audio/x-flac, whereas previous versions
|
23
|
+
# said audio/flac, which we prefer. Let's fix it.
|
24
|
+
RPELACE_CONTENT_TYPES = {
|
25
|
+
"audio/x-flac" => "audio/flac"
|
26
|
+
}
|
27
|
+
|
22
28
|
def self.load_dependencies(uploader, *)
|
23
29
|
uploader.plugin :determine_mime_type, analyzer: -> (io, analyzers) do
|
24
30
|
mime_type = analyzers[:marcel].call(io)
|
@@ -30,6 +36,9 @@ class Shrine
|
|
30
36
|
|
31
37
|
mime_type = "application/octet-stream" if mime_type.blank?
|
32
38
|
|
39
|
+
# Are there any we prefer an alternate spelling of?
|
40
|
+
mime_type = RPELACE_CONTENT_TYPES.fetch(mime_type, mime_type)
|
41
|
+
|
33
42
|
mime_type
|
34
43
|
end
|
35
44
|
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.0
|
4
|
+
version: 2.1.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: 2021-
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -188,7 +188,7 @@ dependencies:
|
|
188
188
|
requirements:
|
189
189
|
- - ">="
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
-
version: 0.
|
191
|
+
version: 0.6.0
|
192
192
|
- - "<"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '1'
|
@@ -198,7 +198,7 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - ">="
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 0.
|
201
|
+
version: 0.6.0
|
202
202
|
- - "<"
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '1'
|
@@ -376,7 +376,6 @@ files:
|
|
376
376
|
- lib/kithe/config_base.rb
|
377
377
|
- lib/kithe/engine.rb
|
378
378
|
- lib/kithe/indexable_settings.rb
|
379
|
-
- lib/kithe/patch_fx.rb
|
380
379
|
- lib/kithe/sti_preload.rb
|
381
380
|
- lib/kithe/version.rb
|
382
381
|
- lib/shrine/plugins/kithe_accept_remote_url.rb
|
data/lib/kithe/patch_fx.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# fx is a gem that lets Rails schema.rb capture postgres functions and triggers
|
2
|
-
#
|
3
|
-
# For it to work for our use case, we need it to define functions BEFORE tables when
|
4
|
-
# doing a `rake db:schema:load`, so we can refer to functions as default values in our
|
5
|
-
# tables.
|
6
|
-
#
|
7
|
-
# This is a known issue in fx, with a PR, but isn't yet merged/released, so we hack
|
8
|
-
# in a patch to force it. Better than forking.
|
9
|
-
#
|
10
|
-
# Based on: https://github.com/teoljungberg/fx/pull/53/
|
11
|
-
#
|
12
|
-
# We try to write future-compat code assuming that will be merged eventually....
|
13
|
-
|
14
|
-
require 'fx'
|
15
|
-
|
16
|
-
if Fx.configuration.respond_to?(:dump_functions_at_beginning_of_schema)
|
17
|
-
# we have the feature!
|
18
|
-
|
19
|
-
Fx.configure do |config|
|
20
|
-
config.dump_functions_at_beginning_of_schema = true
|
21
|
-
end
|
22
|
-
|
23
|
-
else
|
24
|
-
# Fx does not have the feature, we have to patch it in
|
25
|
-
|
26
|
-
require 'fx/schema_dumper/function'
|
27
|
-
|
28
|
-
module Fx
|
29
|
-
module SchemaDumper
|
30
|
-
module Function
|
31
|
-
def tables(stream)
|
32
|
-
functions(stream)
|
33
|
-
super
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|