Sha256: 4485504898d1fdfa1a40f3debf05b867616b6b7db712209e4f26bc9ec7689f99

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

require 'nokogiri'
require 'json'
require 'json-schema'
require 'sanitize'

module GeoCombine

  ##
  # TODO: Create a parse method that can interpret the type of metadata being
  # passed in.
  #
  # def self.parse metadata
  # end

  ##
  # Abstract class for GeoCombine objects
  class Metadata
    attr_reader :metadata

    ##
    # Creates a new GeoCombine::Metadata object, where metadata parameter is can
    # be a File path or String of XML
    # @param [String] metadata can be a File path 
    # "./tmp/edu.stanford.purl/bb/338/jh/0716/iso19139.xml" or a String of XML
    # metadata
    def initialize metadata
      metadata = File.read metadata if File.readable? metadata
      metadata = Nokogiri::XML(metadata) if metadata.instance_of? String
      @metadata = metadata
    end

    ##
    # Perform an XSLT tranformation on metadata using an object's XSL
    # @return fields additional GeoBlacklight fields to be passed to
    # GeoCombine::Geoblacklight on its instantiation
    # @return [GeoCombine::Geoblacklight] the data transformed into
    # geoblacklight schema, returned as a GeoCombine::Geoblacklight
    def to_geoblacklight fields = {}
      GeoCombine::Geoblacklight.new(xsl_geoblacklight.apply_to(@metadata), fields)
    end

    ##
    # Perform an XSLT transformation to HTML using an object's XSL
    # @return [String] the xml transformed to an HTML String
    def to_html
      xsl_html.transform(@metadata).to_html
    end
  end
end

# Require translation mixins
require 'geo_combine/formats'
require 'geo_combine/subjects'
require 'geo_combine/geometry_types'

# Require helper mixins
require 'geo_combine/formatting'

# Require additional classes
require 'geo_combine/fgdc'
require 'geo_combine/geoblacklight'
require 'geo_combine/iso19139'
require 'geo_combine/esri_open_data'

# Require gem files
require 'geo_combine/version'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geo_combine-0.1.0 lib/geo_combine.rb