Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gusgollings/418796 to your computer and use it in GitHub Desktop.
Save gusgollings/418796 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'spira'
require 'rack/linkeddata'
use Rack::LinkedData::ContentNegotiation, :default => 'text/turtle'
include RDF
# FIXME: why is this needed?
Spira.add_repository! :default, Repository.new
class Person
include Spira::Resource
property :name, :predicate => FOAF.name, :type => String
property :homepage, :predicate => FOAF.homepage
end
njh = Person.new(
RDF::URI('http://www.aelius.com/njh#me'),
:name => 'Nicholas Humfrey',
:homepage => URI('http://www.aelius.com/njh/')
)
get '/njh' do
njh
end
# Then try:
#
# curl -H 'Accept: text/turtle' http://127.0.0.1:4567/njh
# curl -H 'Accept: application/rdf+xml' http://127.0.0.1:4567/njh
# curl -H 'Accept: application/json' http://127.0.0.1:4567/njh
#
# or
#
# curl -H 'Accept: application/rdf+xml;q=0.1,text/plain' http://127.0.0.1:4567/njh
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment