Sha256: b36e83f4da21785d02f3deb0d84171d34cefbf926f3b52a29cb511b82adccff1

Contents?: true

Size: 769 Bytes

Versions: 20

Compression:

Stored size: 769 Bytes

Contents

require 'rdf/rdfxml'

module Ddr::Vocab
  class RDFVocabularyParser

    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_hash)
    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

20 entries across 20 versions & 1 rubygems

Version Path
ddr-models-2.11.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.10.2 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.10.1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.10.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.10.0.rc2 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.10.0.rc1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.9.2 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.9.1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.9.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.9.0.rc1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.8.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.8.0.rc1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.7.6 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.7.5 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.7.4 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.7.3 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.7.2 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.7.1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.7.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.7.0.rc1 lib/ddr/vocab/rdf_vocabulary_parser.rb