cocina_display 1.12.0 → 1.12.1
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/note.rb +11 -2
- data/lib/cocina_display/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86e695462cfd5484d4bff8637d170c652a3af2f3c0fa33e0a18e115b8cac5a0a
|
|
4
|
+
data.tar.gz: 6513626e9f7cb053399390f43a45ad5b71b29919b902c267e57edff3e481b72a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 697b9effa8f7778c553350e72899a8cb9175c1bf81c86d1a12453bd1796d41d4b4af9014fdf63bbe061d343c9ccd1601b7831bbd0d03c6383f261f130130f725
|
|
7
|
+
data.tar.gz: bb3a4f506c246bb73c0b0de6a634a5db57d34cc55caf8a8135184da945de669fe843d81abbd6326f022233cbfa0aff12395284b2f598f97aba134b7f5ec8e177
|
data/lib/cocina_display/note.rb
CHANGED
|
@@ -35,7 +35,7 @@ module CocinaDisplay
|
|
|
35
35
|
# @return [Array<String>]
|
|
36
36
|
def values
|
|
37
37
|
Utils.flatten_nested_values(cocina).pluck("value")
|
|
38
|
-
.map { |value| value
|
|
38
|
+
.map { |value| cleaned_value(value) }
|
|
39
39
|
.compact_blank
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -45,7 +45,7 @@ module CocinaDisplay
|
|
|
45
45
|
Utils.flatten_nested_values(cocina).each_with_object({}) do |node, hash|
|
|
46
46
|
type = node["type"]
|
|
47
47
|
hash[type] ||= []
|
|
48
|
-
hash[type] << node["value"]
|
|
48
|
+
hash[type] << cleaned_value(node["value"])
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -110,5 +110,14 @@ module CocinaDisplay
|
|
|
110
110
|
def default_label
|
|
111
111
|
type&.capitalize || I18n.t("cocina_display.field_label.note.note")
|
|
112
112
|
end
|
|
113
|
+
|
|
114
|
+
# Remove the delimiter from the ends of the value and strip whitespace.
|
|
115
|
+
# @param value [String]
|
|
116
|
+
# @return [String]
|
|
117
|
+
def cleaned_value(value)
|
|
118
|
+
value.gsub(/\s*#{Regexp.escape(delimiter.strip)}\s*$/, " ")
|
|
119
|
+
.gsub(/^\s*#{Regexp.escape(delimiter.strip)}\s*/, " ")
|
|
120
|
+
.strip
|
|
121
|
+
end
|
|
113
122
|
end
|
|
114
123
|
end
|