Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Sinatra extension for Linked Data content negotiation.
Ruby
branch: develop

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
doc
lib/sinatra
spec
.gitignore
.travis.yml
.yardopts
AUTHORS
CREDITS
Gemfile
README
README.md
Rakefile
UNLICENSE
VERSION
sinatra-linkeddata.gemspec

README.md

Linked Data Content Negotiation for Sinatra Applications

This is a Sinatra extension that provides Linked Data content negotiation for Sinatra applications.

Gem Version Build Status

Features

Examples

Adding Linked Data content negotiation to a classic Sinatra application

#!/usr/bin/env ruby -rubygems
require 'sinatra'
require 'sinatra/linkeddata'

get '/hello' do
  RDF::Graph.new do |graph|
    graph << [RDF::Node.new, RDF::DC.title, "Hello, world!"]
  end
end

Adding Linked Data content negotiation to a modular Sinatra application

#!/usr/bin/env ruby -rubygems
require 'sinatra/base'
require 'sinatra/linkeddata'

module My
  class Application < Sinatra::Base
    register Sinatra::LinkedData

    get '/hello' do
      RDF::Graph.new do |graph|
        graph << [RDF::Node.new, RDF::DC.title, "Hello, world!"]
      end
    end
  end
end

My::Application.run! :host => '127.0.0.1', :port => 4567

Adding Linked Data content negotiation to a Rackup application

#!/usr/bin/env rackup
require 'sinatra/base'
require 'sinatra/linkeddata'

module My
  class Application < Sinatra::Base
    register Sinatra::LinkedData

    get '/hello' do
      RDF::Graph.new do |graph|
        graph << [RDF::Node.new, RDF::DC.title, "Hello, world!"]
      end
    end
  end
end

run My::Application

Testing Linked Data content negotiation using rackup and curl

$ rackup doc/examples/config.ru

$ curl -iH "Accept: application/n-triples" http://localhost:9292/hello
$ curl -iH "Accept: application/turtle" http://localhost:9292/hello
$ curl -iH "Accept: application/rdf+xml" http://localhost:9292/hello
$ curl -iH "Accept: application/json" http://localhost:9292/hello
$ curl -iH "Accept: application/trix" http://localhost:9292/hello
$ curl -iH "Accept: */*" http://localhost:9292/hello

Description

Sinatra::LinkedData is a thin Sinatra-specific wrapper around the Rack::LinkedData middleware, which implements Linked Data content negotiation for Rack applications.

At the moment the Sinatra extension simply corresponds to doing the following manually in a Sinatra application:

require 'rack/linkeddata'

module My
  class Application < Sinatra::Base
    use     Rack::LinkedData::ContentNegotiation
    helpers Sinatra::LinkedData::Helpers
    include RDF
    include LinkedData
  end
end

See the Rack::LinkedData documentation for more information on the operation and details of the content negotiation.

Documentation

http://rubydoc.info/github/ruby-rdf/sinatra-linkeddata/

  • {Sinatra::LinkedData}

Dependencies

Installation

The recommended installation method is via RubyGems. To install the latest official release of the gem, do:

% [sudo] gem install sinatra-linkeddata

Download

To get a local working copy of the development repository, do:

% git clone git://github.com/ruby-rdf/sinatra-linkeddata.git

Alternatively, you can download the latest development version as a tarball as follows:

% wget http://github.com/ruby-rdf/sinatra-linkeddata/tarball/master

Contributing

This repository uses Git Flow to mange development and release activity. All submissions must be on a feature branch based on the develop branch to ease staging and integration.

  • Do your best to adhere to the existing coding conventions and idioms.
  • Don't use hard tabs, and don't leave trailing whitespace on any line.
  • Do document every method you add using YARD annotations. Read the tutorial or just look at the existing code for examples.
  • Don't touch the .gemspec, VERSION or AUTHORS files. If you need to change them, do so on your private branch only.
  • Do feel free to add yourself to the CREDITS file and the corresponding list in the the README. Alphabetical order applies.
  • Do note that in order for us to merge any non-trivial changes (as a rule of thumb, additions larger than about 15 lines of code), we need an explicit public domain dedication on record from you.

References

Authors

Contributing

This repository uses Git Flow to mange development and release activity. All submissions must be on a feature branch based on the develop branch to ease staging and integration.

  • Do your best to adhere to the existing coding conventions and idioms.
  • Don't use hard tabs, and don't leave trailing whitespace on any line.
  • Do document every method you add using YARD annotations. Read the tutorial or just look at the existing code for examples.
  • Don't touch the .gemspec, VERSION or AUTHORS files. If you need to change them, do so on your private branch only.
  • Do feel free to add yourself to the CREDITS file and the corresponding list in the the README. Alphabetical order applies.
  • Do note that in order for us to merge any non-trivial changes (as a rule of thumb, additions larger than about 15 lines of code), we need an explicit public domain dedication on record from you.

License

Sinatra::LinkedData is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.

Something went wrong with that request. Please try again.