Class: Assembly::ContentMetadata
- Inherits:
-
Object
- Object
- Assembly::ContentMetadata
- Defined in:
- lib/assembly-objectfile/content_metadata.rb,
lib/assembly-objectfile/content_metadata/file.rb,
lib/assembly-objectfile/content_metadata/config.rb,
lib/assembly-objectfile/content_metadata/file_set.rb,
lib/assembly-objectfile/content_metadata/file_set_builder.rb,
lib/assembly-objectfile/content_metadata/nokogiri_builder.rb
Overview
This class generates content metadata for image files
Defined Under Namespace
Modules: Types Classes: Config, File, FileSet, FileSetBuilder, NokogiriBuilder
Class Method Summary collapse
-
.create_content_metadata(druid:, objects:, auto_labels: true, add_exif: false, bundle: :default, style: :simple_image, add_file_attributes: false, file_attributes: {}, preserve_common_paths: false, flatten_folder_structure: false, include_root_xml: nil) ⇒ Object
Generates image content XML metadata for a repository object.
- .object_level_type(style) ⇒ Object
- .special_dpg_folder?(folder) ⇒ Boolean
Class Method Details
.create_content_metadata(druid:, objects:, auto_labels: true, add_exif: false, bundle: :default, style: :simple_image, add_file_attributes: false, file_attributes: {}, preserve_common_paths: false, flatten_folder_structure: false, include_root_xml: nil) ⇒ Object
Generates image content XML metadata for a repository object. This method only produces content metadata for images and does not depend on a specific folder structure. Note that it is class level method.
Example:
Assembly::ContentMetadata.(:druid=>'druid:nx288wh8889',:style=>:simple_image,:objects=>object_files,:add_file_attributes=>false)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/assembly-objectfile/content_metadata.rb', line 54 def self.(druid:, objects:, auto_labels: true, add_exif: false, bundle: :default, style: :simple_image, add_file_attributes: false, file_attributes: {}, preserve_common_paths: false, flatten_folder_structure: false, include_root_xml: nil) common_path = find_common_path(objects) unless preserve_common_paths # find common paths to all files provided if needed filesets = FileSetBuilder.build(bundle: bundle, objects: objects, style: style) config = Config.new(auto_labels: auto_labels, flatten_folder_structure: flatten_folder_structure, add_file_attributes: add_file_attributes, file_attributes: file_attributes, add_exif: add_exif, type: object_level_type(style)) builder = NokogiriBuilder.build(druid: druid, filesets: filesets, common_path: common_path, config: config) result = if include_root_xml == false builder.doc.root.to_xml else builder.to_xml end result end |
.object_level_type(style) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/assembly-objectfile/content_metadata.rb', line 100 def self.object_level_type(style) puts "WARNING - the style #{style} is now deprecated and should not be used." if DEPRECATED_STYLES.include? style case style when :simple_image 'image' when :file 'file' when :simple_book, :book_with_pdf, :book_as_image 'book' when :map 'map' when :'3d' '3d' else raise "Supplied style (#{style}) not valid" end end |
.special_dpg_folder?(folder) ⇒ Boolean
85 86 87 |
# File 'lib/assembly-objectfile/content_metadata.rb', line 85 def self.special_dpg_folder?(folder) SPECIAL_DPG_FOLDERS.include?(folder) end |