Sha256: 0dda88c791999927874fd3ebfdba6e5f754590cb6aaf656c3502b9e0a7ea3720

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

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

14 entries across 14 versions & 1 rubygems

Version Path
geoblacklight-2.4.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-2.3.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-2.2.1 lib/geoblacklight/metadata_transformer.rb
geoblacklight-2.2.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-2.1.2 lib/geoblacklight/metadata_transformer.rb
geoblacklight-2.1.1 lib/geoblacklight/metadata_transformer.rb
geoblacklight-2.1.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-2.0.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-1.9.1 lib/geoblacklight/metadata_transformer.rb
geoblacklight-1.9.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-1.8.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-1.7.1 lib/geoblacklight/metadata_transformer.rb
geoblacklight-1.7.0 lib/geoblacklight/metadata_transformer.rb
geoblacklight-1.6.0 lib/geoblacklight/metadata_transformer.rb