Sha256: 82d6518bd404d6321f95523830ca30edc9a4689497e57fbcd578b8d651947367

Contents?: true

Size: 822 Bytes

Versions: 13

Compression:

Stored size: 822 Bytes

Contents

require 'rdf/rdfxml'

module Ddr::Vocab
  class RDFVocabularyParser

    warn "[DEPRECATION] `#{self.name}` is deprecated."

    attr_reader :source, :prefix

    def initialize(source, prefix = "")
      @source = source
      @prefix = prefix
    end

    def term_names
      @term_names ||= terms.collect { |t| t[:resource].to_s.sub(prefix, "") }.freeze
    end

    def term_symbols
      term_names.map(&:to_sym)
    end

    def terms
      properties.map(&:to_h)
    end

    def properties
      RDF::Query.execute(graph, properties_query)
    end

    def properties_query
      {:resource => {
         RDF.type => RDF.Property,
         RDF::RDFS.label => :label,
         RDF::RDFS.comment => :comment
       }
      }
    end

    def graph
      @graph ||= RDF::Graph.load(source).freeze
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ddr-core-1.17.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.16.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.15.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.14.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.13.2 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.13.1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.13.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.12.2 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.12.1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.12.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.11.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.10.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-core-1.9.0 lib/ddr/vocab/rdf_vocabulary_parser.rb