Sha256: c05a937e0026911dd363f10f0160a8b5b00e39b1b5441e7afa2ea4bea79e430b
Contents?: true
Size: 949 Bytes
Versions: 3
Compression:
Stored size: 949 Bytes
Contents
require 'solr' require 'rexml/document' require "nokogiri" require 'yaml' module Solrizer::Fedora::Extractor # # Extracts content-model and hydra-type from RELS-EXT datastream # def extract_rels_ext( text, solr_doc=Solr::Document.new ) # TODO: only read in this file once if defined?(RAILS_ROOT) config_path = File.join(RAILS_ROOT, "config") else config_path = File.join(File.dirname(__FILE__), "..", "..", "..", "config") end map = YAML.load(File.open(File.join(config_path, "hydra_types.yml"))) doc = Nokogiri::XML(text) doc.xpath( '//foo:hasModel', 'foo' => 'info:fedora/fedora-system:def/model#' ).each do |element| cmodel = element.attributes['resource'].to_s solr_doc << Solr::Field.new( :cmodel_t => cmodel ) if map.has_key?(cmodel) solr_doc << Solr::Field.new( :hydra_type_t => map[cmodel] ) end end return solr_doc end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
solrizer-fedora-1.0.0 | lib/solrizer/fedora/extractor.rb |
solrizer-fedora-0.1.1 | lib/solrizer/fedora/extractor.rb |
solrizer-fedora-0.1.0 | lib/solrizer/fedora/extractor.rb |