Skip to content

Instantly share code, notes, and snippets.

View bhuga's full-sized avatar

Ben Lavender bhuga

View GitHub Profile
#!/usr/bin/env ruby1.9
#
$:.unshift('./lib')
require 'linkeddata/repository'
require 'spira'
repo = LinkedData::Repository.new
uri = RDF::URI('http://www.bbc.co.uk/programmes/b00jnwlc#programme')
@bhuga
bhuga / gist:406468
Created May 19, 2010 16:00
JRuby enumerator bug
# Demonstrates a JRuby difference with RDF enumerators
require 'rdf'
require 'rdf/ntriples'
include RDF
s = Statement.new(FOAF.age, FOAF.age, FOAF.age)
r = Repository.new
r.insert(s)
# Note that as in the SIOC reference documents, the extended SIOC types
# ontology is referred to as sioc_t.
It would seem that 'reference implementations' of existing ontologies are
actually quite difficult in Spira.
sioc:topic references an RDF Resource. That Resource may optionally be a
sioc_t:Category or sioc_t:Tag. sioc_t:Category is a subclass of skos.Concept,
but sioc_t:Tag is its own thing.
#!/usr/bin/env jruby
libs = %w{jena-2.6.2 arq-2.8.3 icu4j-3.4.4 iri-0.8 log4j-1.2.14 stax-api-1.0.1 wstx-asl-3.2.9 xercesImpl-2.7.1 slf4j-api-1.5.8 slf4j-log4j12-1.5.8}
libdir = "/Users/ben/jena/ARQ-2.8.3/lib"
libs.each do | lib |
require File.join(libdir, "#{lib}.jar")
end
require '/Users/ben/jena/spinrdf-1.1.1/lib/spinrdf-1.1.1.jar'
require 'rdf'
require 'spira'
require 'rdf/ntriples'
class Person
include Spira::Resource
property :name, :predicate => FOAF.name
property :nick, :predicate => FOAF.nick
end
ben:rdf ben$ irb
>> require 'rdf'
=> true
>> s = RDF::NTriples.unserialize '<http://openlibrary.org/b/OL3M> <http://RDVocab.info/Elements/titleProper> "Jhūlā." '
=> #<RDF::Statement:0x90bbb8(<http://openlibrary.org/b/OL3M> <http://RDVocab.info/Elements/titleProper> "Jhūlā." .)>
>> RDF::NTriples.serialize(s)
=> "<http://openlibrary.org/b/OL3M> <http://RDVocab.info/Elements/titleProper> "Jh\305\253l\304\201." .\n"
>> exit
RSpec:
should support #predicates
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
#!/usr/bin/env ruby
require 'rdf'
require 'do_sqlite3'
require 'rdf/do'
$:.unshift '~/repos/RDFObjects/lib'
require 'rdf_objects'
rdfobject = RDFObject::Resource.new('http://example.org/1234')
# sample heroku rackup
http://rdfdo.heroku.com/postgres
http://rdfdo.heroku.com/sqlite3
$:.unshift(Dir.glob("./.bundle/gems/bundler/gems/rdf-spec*gemspec*/lib").first)
require 'spec'
app = proc do |env|
require 'spira'
Spira.add_repository(:person, ::RDF::Repository)
class Person
include Spira::Resource
default_source :person