Sha256: 689131081e97c09f8436024800113e30fa6c4403936e38248d5b3e7297318cb7
Contents?: true
Size: 1.37 KB
Versions: 10
Compression:
Stored size: 1.37 KB
Contents
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
10 entries across 10 versions & 1 rubygems