Using ActiveRDF with Jena
This text explains how to:- install jruby
- install ActiveRDF and the jena adapter under jruby
- use this in a ruby script
For general information about ActiveRDF please see GettingStartedGuide.
Installing JRuby
- Download the newest jruby-bin file from the JRuby download site
- unpack it
- set your path to include the jruby binaries:
export PATH=/path/to/jruby-1.0.1/bin:$PATH
- verify that you will use the jruby binarys by checking the output of “which jruby” and “which gem”
Installing activerdf and the jena adapter
Use the gem system to install everything:gem install activerdf -y gem install activerdf_sparql -y gem install activerdf_jena -y
Using it
Create an instance of the jena adapter with simple file based persistence, and load some data into it:
this_dir = File.dirname(File.expand_path(__FILE__))
adapter = ConnectionPool.add_data_source(:type => :jena,
:model => "superfunky",
:file => this_dir + "/jena_persistence")
adapter.load("file://" + this_dir + "/test_data.rdf", :format => :rdfxml, :into => :default_model )
The jena adapter currently (3rd of August, 2007) has these features:
- adding and removing triples
- queries
- in-memory store and simple file based persistence
- loading rdf data from n3, ntriple or rdf/xml serialisations
- queries with keywords
For more information please see the RDoc, the adapter source code and the unit tests. Go to /path/to/jruby/lib/ruby/gems/1.8/gems/activerdf_jena-0.1/test/ for that.