Sha256: 4f10bdc5c2b9fddacbfda8e5f1716a4300497cb42d6f421bcabf77c78f50f7b0
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true module Geoblacklight module MetadataTransformer ## # Abstract class for transforming geospatial metadata class Base ## # @param [GeoCombine::Metadata] metadata metadata Object # @see GeoCombine::Metadata def initialize(metadata) @metadata = metadata # Access the Nokogiri::XML Document from the metadata Object fail EmptyMetadataError, 'Failed to retrieve the metadata' if @metadata.blank? end ## # Returns HTML for the metadata transformed into HTML using GeoCombine # @see GeoCombine::Metadata#to_html # @return [String] the transformed metadata in the HTML def transform cleaned_metadata.to_html rescue => e raise TransformError, e.message end private ## # Clean top-level HTML elements from GeoCombine HTML Documents (e. g. <html> and <body>) # @return [Nokogiri::XML::Document] the Nokogiri XML Document for the cleaned HTML def cleaned_metadata transformed_doc = Nokogiri::XML(@metadata.to_html) if transformed_doc.xpath('//body').children.empty? fail TransformError, \ 'Failed to extract the <body> child elements from the transformed metadata' end transformed_doc.xpath('//body').children rescue => e raise TransformError, e.message end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
geoblacklight-4.0.0 | lib/geoblacklight/metadata_transformer/base.rb |
geoblacklight-4.0.0.pre.rc3 | lib/geoblacklight/metadata_transformer/base.rb |