Sha256: 6617e459127cb7cc44d3a38b687f2b350d2843e068721095532b153eb28d228a

Contents?: true

Size: 1.08 KB

Versions: 20

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true
require 'geo_combine'

module Geoblacklight
  module MetadataTransformer
    ##
    # Exceptions raised for the types of geospatial metadata
    class TypeError < EncodingError; end
    ##
    # Exceptions raised when parsing geospatial metadata in the XML
    class ParseError < EncodingError; end
    ##
    # Exception raised when the geospatial metadata content is empty
    class EmptyMetadataError < ParseError; end
    ##
    # Exceptions raised when transforming the metadata into the HTML
    class TransformError < EncodingError; end

    ##
    # Initialize a new MetadataTransformer instance
    # @param [Geoblacklight::Metadata::Base] metadata string or File path to the raw metadata
    # @return [Geoblacklight::MetadataTransformer::BaseTransformer]
    def self.instance(metadata)
      type = metadata.class.name.split('::').last
      begin
        klass = "Geoblacklight::MetadataTransformer::#{type.capitalize}".constantize
      rescue
        raise TypeError, "Metadata type #{type} is not supported"
      end

      klass.new(metadata)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
geoblacklight-3.8.1 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.8.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-4.0.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-4.0.0.pre.rc3 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.7.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-4.0.0.pre.rc2 lib/geoblacklight/metadata_transformer.rb
geoblacklight-4.0.0.pre.rc1 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.6.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.5.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-4.0.0.pre.alpha.3 lib/geoblacklight/metadata_transformer.rb
geoblacklight-4.0.0.pre.alpha.2 lib/geoblacklight/metadata_transformer.rb
geoblacklight-4.0.0.pre.alpha.1 lib/geoblacklight/metadata_transformer.rb
geoblacklight-4.0.0.pre.alpha lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.4.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.3.1 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.3.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.2.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.1.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.0.1 lib/geoblacklight/metadata_transformer.rb
geoblacklight-3.0.0 lib/geoblacklight/metadata_transformer.rb