Sha256: 945c79a7c332b30746dcbe256261c3ea9dbd03f360a42df1a1d0aa55f322668c

Contents?: true

Size: 847 Bytes

Versions: 106

Compression:

Stored size: 847 Bytes

Contents

require 'rdf/rdfxml'

module Ddr
  module 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
end

Version data entries

106 entries across 106 versions & 1 rubygems

Version Path
ddr-models-2.6.2 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.6.1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.6.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.6.0.rc4 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.6.0.rc3 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.6.0.rc2 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.6.0.rc1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.5.3 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.5.2 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.5.1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.5.0 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.5.0.rc1 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.4.16 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.4.15 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.4.14 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.4.13 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.4.12 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-2.4.11 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-3.0.8 lib/ddr/vocab/rdf_vocabulary_parser.rb
ddr-models-3.0.7 lib/ddr/vocab/rdf_vocabulary_parser.rb