cocina_display 2.9.1 → 2.11.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/lib/cocina_display/concerns/structural.rb +6 -2
- data/lib/cocina_display/utils.rb +11 -6
- data/lib/cocina_display/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3cdd3c641ebe565578770ae4f79867ccc886bdaefa17b2bfa966cc17c262c58b
|
|
4
|
+
data.tar.gz: 2d0e16f879c06393a3e74c2e323896384040721c95f73bc2e65fb428c4c9d94a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98248c3a9f4a68ef0e8fac5261f979702e66c529f086d9287d111d580af06bc517536b5636fb0e5d1ca02588264af17c91e9185630c5f35f287c60af5cc6de77
|
|
7
|
+
data.tar.gz: b6c79b6672639e13f31f446ca239d11434be0ba152656f93bd328ce576271d3e6db6ace9adec9b136d40cd325fce562d0d30317cabf5b4afe37d505962a5e93f
|
|
@@ -99,7 +99,7 @@ module CocinaDisplay
|
|
|
99
99
|
def virtual_object?
|
|
100
100
|
return false if filesets.any?
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
member_enumeration.any?
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
# DRUIDs of members of this virtual object.
|
|
@@ -108,7 +108,11 @@ module CocinaDisplay
|
|
|
108
108
|
def virtual_object_members
|
|
109
109
|
return [] unless virtual_object?
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
member_enumeration.map { |druid| druid.delete_prefix("druid:") }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def member_enumeration
|
|
115
|
+
@member_enumeration ||= path("$.structural.hasMemberOrders.*.members.*")
|
|
112
116
|
end
|
|
113
117
|
|
|
114
118
|
# DRUIDs of virtual objects this object is a part of.
|
data/lib/cocina_display/utils.rb
CHANGED
|
@@ -52,26 +52,31 @@ module CocinaDisplay
|
|
|
52
52
|
|
|
53
53
|
# Recursively remove empty values from a hash, including nested hashes and arrays.
|
|
54
54
|
# @param [Hash, String, NilClass] node The object to process
|
|
55
|
+
# @param [Array<String>] preserve_keys Keys that should be kept even if their value is blank
|
|
55
56
|
# @return [Hash, String] The hash with empty values removed, string if the node you pass in is a string
|
|
56
57
|
# @example
|
|
57
58
|
# hash = { "name" => "", "age" => nil, "address => { "city" => "Anytown", "state" => [] } }
|
|
58
59
|
# # Utils.remove_empty_values(hash)
|
|
59
60
|
# #=> { "address" => { "city" => "Anytown" } }
|
|
60
|
-
def self.deep_compact_blank(node)
|
|
61
|
+
def self.deep_compact_blank(node, preserve_keys: [])
|
|
61
62
|
return node unless node.is_a?(Hash)
|
|
62
63
|
|
|
64
|
+
preserve_keys = preserve_keys.map(&:to_s)
|
|
65
|
+
|
|
63
66
|
node.each_with_object({}) do |(key, value), output|
|
|
67
|
+
preserve_key = preserve_keys.include?(key.to_s)
|
|
68
|
+
|
|
64
69
|
case value
|
|
65
70
|
when Hash
|
|
66
|
-
nested = deep_compact_blank(value)
|
|
67
|
-
output[key] = nested
|
|
71
|
+
nested = deep_compact_blank(value, preserve_keys: preserve_keys)
|
|
72
|
+
output[key] = nested if !nested.empty? || preserve_key
|
|
68
73
|
when Array
|
|
69
|
-
compacted_array = value.map { |v| deep_compact_blank(v) }.compact_blank
|
|
70
|
-
output[key] = compacted_array
|
|
74
|
+
compacted_array = value.map { |v| deep_compact_blank(v, preserve_keys: preserve_keys) }.compact_blank
|
|
75
|
+
output[key] = compacted_array if !compacted_array.empty? || preserve_key
|
|
71
76
|
when TrueClass, FalseClass
|
|
72
77
|
output[key] = value
|
|
73
78
|
else
|
|
74
|
-
output[key] = value if value.present?
|
|
79
|
+
output[key] = value if value.present? || preserve_key
|
|
75
80
|
end
|
|
76
81
|
end
|
|
77
82
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cocina_display
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Budak
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: janeway-jsonpath
|
|
@@ -326,7 +326,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
326
326
|
- !ruby/object:Gem::Version
|
|
327
327
|
version: '0'
|
|
328
328
|
requirements: []
|
|
329
|
-
rubygems_version:
|
|
329
|
+
rubygems_version: 4.0.6
|
|
330
330
|
specification_version: 4
|
|
331
331
|
summary: Helpers for rendering Cocina metadata
|
|
332
332
|
test_files: []
|