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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fe55cd9eb6b6f323f8a64418420a91a3d3cc99baa677a006e72608d3e05ccaf
4
- data.tar.gz: 167d25b42b8a490d4c8bd3e7fbdf8756560b9bcbdc9c684bc17db854dce3897a
3
+ metadata.gz: e9a96dd80fc482ea07bd35456a0cf8445b722354cd6fe1fda10460398a0d7846
4
+ data.tar.gz: 0ccb6788a1ac0f88a47202767f1a5acb7dc12031cc4293ec27e09ded198b8daf
5
5
  SHA512:
6
- metadata.gz: f1cb5e7242f6fffcda9b0be4894f24251470b919204faf355f694f245863acd9a9c5e1ce9f67abd3c3cfb9b3ba01a8b7235d45ce8a9b22349ee8d03d1e7dbe67
7
- data.tar.gz: fe8af824a5dc4f5af3719d12a109eff834cd260f647d668eba452c8aa88bbe61ac7b33c81206cbd1ec95169e260c312934843f820ee556a5c0452fc767bdb42a
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
- obj.flat_map { |item| obj_extractor(item, path) }
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[:parent] << 'can not be an Asset instance'
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[:parent] << 'is invalid for Collection instances'
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
@@ -2,5 +2,5 @@ module Kithe
2
2
  # not sure why rubygems turned our alphas into 2.0.0.pre.alpha1, inserting
3
3
  # "pre". We need to do same thing with betas to get version orderings
4
4
  # appropriate.
5
- VERSION = '2.0.3'
5
+ VERSION = '2.1.0'
6
6
  end
@@ -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.3
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-01-11 00:00:00.000000000 Z
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.5.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.5.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
@@ -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