Class: WaxTasks::Collection
- Inherits:
-
Object
- Object
- WaxTasks::Collection
- Defined in:
- lib/wax_tasks/collection.rb,
lib/wax_tasks/collection/images.rb,
lib/wax_tasks/collection/metadata.rb
Defined Under Namespace
Constant Summary collapse
- IMAGE_DERIVATIVE_DIRECTORY =
'img/derivatives'
- DEFAULT_VARIANTS =
{ 'thumbnail' => 250, 'fullwidth' => 1140 }.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#iiif_derivative_source ⇒ Object
readonly
Returns the value of attribute iiif_derivative_source.
-
#imagedata_source ⇒ Object
readonly
Returns the value of attribute imagedata_source.
-
#metadata_source ⇒ Object
readonly
Returns the value of attribute metadata_source.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#page_source ⇒ Object
readonly
Returns the value of attribute page_source.
-
#search_fields ⇒ Object
readonly
Returns the value of attribute search_fields.
-
#simple_derivative_source ⇒ Object
readonly
Returns the value of attribute simple_derivative_source.
Instance Method Summary collapse
- #clobber_derivatives ⇒ Object
- #clobber_pages ⇒ Object
- #image_variants ⇒ Object
-
#initialize(name, config, source, collections_dir, ext) ⇒ Collection
constructor
A new instance of Collection.
Methods included from Images
#add_font_matter_to_json_files, #add_iiif_results_to_records, #iiif_builder, #items_from_imagedata, #pre_process_pdfs, #write_iiif_derivatives, #write_simple_derivatives
Methods included from Metadata
#consolidate_records, #csv_string, #json_string, #records_from_metadata, #records_from_pages, #search_fields=, #update_metadata, #yaml_string
Constructor Details
#initialize(name, config, source, collections_dir, ext) ⇒ Collection
Returns a new instance of Collection.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wax_tasks/collection.rb', line 21 def initialize(name, config, source, collections_dir, ext) @name = name @config = config @page_extension = ext @site_source = source @page_source = Utils.safe_join source, collections_dir, "_#{@name}" @metadata_source = Utils.safe_join source, '_data', config.dig('metadata', 'source') @imagedata_source = Utils.safe_join source, '_data', config.dig('images', 'source') @iiif_derivative_source = Utils.safe_join source, IMAGE_DERIVATIVE_DIRECTORY, 'iiif' @simple_derivative_source = Utils.safe_join source, IMAGE_DERIVATIVE_DIRECTORY, 'simple' @search_fields = %w[pid label thumbnail permalink collection] @image_variants = image_variants end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/wax_tasks/collection.rb', line 9 def config @config end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
9 10 11 |
# File 'lib/wax_tasks/collection.rb', line 9 def ext @ext end |
#iiif_derivative_source ⇒ Object (readonly)
Returns the value of attribute iiif_derivative_source.
9 10 11 |
# File 'lib/wax_tasks/collection.rb', line 9 def iiif_derivative_source @iiif_derivative_source end |
#imagedata_source ⇒ Object (readonly)
Returns the value of attribute imagedata_source.
9 10 11 |
# File 'lib/wax_tasks/collection.rb', line 9 def imagedata_source @imagedata_source end |
#metadata_source ⇒ Object (readonly)
Returns the value of attribute metadata_source.
9 10 11 |
# File 'lib/wax_tasks/collection.rb', line 9 def @metadata_source end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/wax_tasks/collection.rb', line 9 def name @name end |
#page_source ⇒ Object (readonly)
Returns the value of attribute page_source.
9 10 11 |
# File 'lib/wax_tasks/collection.rb', line 9 def page_source @page_source end |
#search_fields ⇒ Object (readonly)
Returns the value of attribute search_fields.
9 10 11 |
# File 'lib/wax_tasks/collection.rb', line 9 def search_fields @search_fields end |
#simple_derivative_source ⇒ Object (readonly)
Returns the value of attribute simple_derivative_source.
9 10 11 |
# File 'lib/wax_tasks/collection.rb', line 9 def simple_derivative_source @simple_derivative_source end |
Instance Method Details
#clobber_derivatives ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/wax_tasks/collection.rb', line 52 def clobber_derivatives [@iiif_derivative_source, @simple_derivative_source].each do |dir| if Dir.exist? dir puts Rainbow("Removing derivatives from #{dir}").cyan FileUtils.remove_dir dir, true end end end |
#clobber_pages ⇒ Object
44 45 46 47 48 |
# File 'lib/wax_tasks/collection.rb', line 44 def clobber_pages return unless Dir.exist? @page_source puts Rainbow("Removing pages from #{@page_source}").cyan FileUtils.remove_dir @page_source, true end |
#image_variants ⇒ Object
37 38 39 40 |
# File 'lib/wax_tasks/collection.rb', line 37 def image_variants vars = @config.dig('images', 'variants') || {} DEFAULT_VARIANTS.merge vars end |