Sha256: e561436d5b096b5b59f5fad982a7167c29ce2a6b918719634962cc9a77b649e2

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

#class String
#  alias _match match
#  def match(*args)
#    m = _match(args.first)
#    if m && m.length > 1
#      args[1..-1].each_with_index do |name, index|
#        m.instance_eval "def #{name}; self[#{index+1}] end"
#      end
#    end
#    m
#  end
#end

class FetchingAdapter < RDFLite
  ConnectionPool.register_adapter(:fetching,self)

	# fetches RDF/XML data from given url and adds it to the datastore, using the 
	# source url as context identifier.
  def fetch url
		return unless url.match(/http:\/\/(.*)/)

		# remove fragment identifier from url
		hashidx = url.rindex('#')
		url = url[0..url.rindex('#')-1] unless hashidx.nil?

		$activerdflog.debug "fetching from #{url}"

		#model = Redland::Model.new
		#parser = Redland::Parser.new('rdfxml')
		#scan = Redland::Uri.new('http://feature.librdf.org/raptor-scanForRDF')
		#enable = Redland::Literal.new('1')
		#Redland::librdf_parser_set_feature(parser, scan.uri, enable.node)
		#parser.parse_into_model(model, url)
		#triples = Redland::Serializer.ntriples.model_to_string(nil, model)

		triples = `rapper --scan "#{url}"`
		lines = triples.split($/)
		$activerdflog.debug "found #{lines.size} triples"

		context = RDFS::Resource.new(url)
		add_ntriples(triples, context)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerdf_rdflite-1.1 lib/activerdf_rdflite/fetching.rb