cocina_display 2.4.0 → 2.5.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: f74e1deeabaf3c4c9535967c1903bc6b393aa365a5ef9d917a977db60538397b
4
- data.tar.gz: 2b56b34bbabd4f7c8d0fe94d668fd1753de48009888c1f18eece1c429dafe3c8
3
+ metadata.gz: b15ae80346f651c784e00b9816ba3ebd6f218adbc2b7a2d16967f7acf45342a7
4
+ data.tar.gz: 25787267b855ec6eeb746c8a380185adbef5368a266b682c62fece9d6f6fc482
5
5
  SHA512:
6
- metadata.gz: 74c89bf0c7e40e8dcdcf4c60be91002c8e563bd4a5a796e17a255cb739fcdd3088788bc31d5cd62a6b0e1af22a0155fd90ab6db4ffcca1e2302d770dae4ab764
7
- data.tar.gz: 0e47b6097c557bc1c73d360a5fc37d55aa7f58db6173f4f0fb8851c493f2095e9181355c41b984522066a6d7649d97827a707315708239ebf958cdcd4455baee
6
+ metadata.gz: 92c26cb2591f000a3bb9e5e88c1afcdf67eeaf0c2f9eb8816fe2f3cdd6fff6a0c500464f28c7f78e1a7bbabfd5adba17f9ba837ce2f8b4fcbf5898d9eaa12c90
7
+ data.tar.gz: f719a4a177460eecb13272c76bc669bc6546b0a0a30271108a998d055a4036d3fc442a07279e11d3e0baa79df340e40c2ba838b5e76752cffa09f21fafd02933
@@ -20,14 +20,25 @@ module CocinaDisplay
20
20
 
21
21
  # Structured data for all individual files in the object.
22
22
  # Traverses nested FileSet structure to return a flattened array.
23
+ # Optionally filter by filename or MIME type regex, or by role.
24
+ # Filters are combined with AND logic (all must match).
25
+ # @param filename [String, nil] Regular expression to match against filenames.
26
+ # @param mime_type [String, nil] Regular expression to match against MIME types.
27
+ # @param use [String, nil] Usage type to match against (e.g., "thumbnail").
23
28
  # @return [Array<CocinaDisplay::Structural::File>]
24
29
  # @example
25
30
  # record.files.each do |file|
26
31
  # puts file.filename #=> "image1.jpg"
27
32
  # puts file.size #=> 123456
28
33
  # end
29
- def files
30
- filesets.flat_map(&:files)
34
+ # @example Filter to only thumbnail JP2 files
35
+ # record.files(filename: /\.jp2$/, use: "thumbnail")
36
+ def files(filename: nil, mime_type: nil, use: nil)
37
+ results = filesets.flat_map(&:files)
38
+ results.filter! { |file| file.filename =~ filename } if filename
39
+ results.filter! { |file| file.mime_type =~ mime_type } if mime_type
40
+ results.filter! { |file| file.use == use } if use
41
+ results
31
42
  end
32
43
 
33
44
  # All unique MIME types of files in this object.
@@ -2,5 +2,5 @@
2
2
 
3
3
  # :nodoc:
4
4
  module CocinaDisplay
5
- VERSION = "2.4.0" # :nodoc:
5
+ VERSION = "2.5.0" # :nodoc:
6
6
  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.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Budak
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-04-22 00:00:00.000000000 Z
10
+ date: 2026-05-13 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: janeway-jsonpath