Class: RoadForest::MediaType::Handlers::RDFa

Inherits:
RDFHandler show all
Includes:
RDF::Normalization
Defined in:
lib/roadforest/content-handling/type-handlers/rdfa.rb

Overview

text/html;q=1;rdfa image/svg+xml;q=1;rdfa application/xhtml+xml;q=1;rdfa text/html image/svg+xml application/xhtml+xml

Constant Summary

Constants included from RDF::Normalization

RDF::Normalization::Vocabs

Instance Method Summary collapse

Methods included from RDF::Normalization

#expand_curie, #expand_curie_pair, #interned_uri, #literal, #normalize_context, #normalize_property, #normalize_resource, #normalize_statement, #normalize_term, #normalize_tuple, #normalize_uri, #relevant_prefixes_for_graph, #root_url, #uri, #vocabularies_in_graph

Methods inherited from RDFHandler

#child_for_model, #get_output

Methods inherited from Handler

#add_child_to, #build_response, #child_for_model, #get_output, #parse_for, #render_for, #update_model

Instance Method Details

#local_to_network(base_uri, rdf) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/roadforest/content-handling/type-handlers/rdfa.rb', line 148

def local_to_network(base_uri, rdf)
  raise "Invalid base uri: #{base_uri}" if base_uri.nil?
  prefixes = relevant_prefixes_for_graph(rdf)
  prefixes.keys.each do |prefix|
    prefixes[prefix.to_sym] = prefixes[prefix]
  end
  #::RDF::RDFa.debug = true
  RESTfulRDFaWriter.buffer(:base_uri => base_uri.to_s,
                           :prefixes => prefixes) do |writer|
    rdf.each_statement do |statement|
      writer << statement
    end
                           end
end

#network_to_local(base_uri, source) ⇒ Object



163
164
165
166
167
168
169
170
171
# File 'lib/roadforest/content-handling/type-handlers/rdfa.rb', line 163

def network_to_local(base_uri, source)
  raise "Invalid base uri: #{base_uri.inspect}" if base_uri.nil?
  graph = ::RDF::Graph.new
  reader = ::RDF::RDFa::Reader.new(source.to_s, :base_uri => base_uri.to_s)
  reader.each_statement do |statement|
    graph.insert(statement)
  end
  graph
end