0.0
No commit activity in last 3 years
No release in over 3 years
RDF for SQLite is a container gem for getting the simplest RDF-based applications off the ground. It uses quite a few modular gems and fixes a little inconsistency between RDF.rb and ActiveModel. This basically boils down to RDF.rb + ActiveModel + Spira + SQLite3 to create a pretty straightforward repository, serializer, parser, and ORM.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

RDF for SQLite¶ ↑

RDF for SQLite is a container gem for getting the simplest RDF-based applications off the ground. It uses quite a few modular gems and fixes a little inconsistency between RDF.rb and ActiveModel. The gems are:

  • rdf

  • data_objects

  • do_sqlite3

  • rdf-do

  • spira

  • active_model

This basically boils down to RDF.rb + ActiveModel + Spira + SQLite3 to create a pretty straightforward repository, serializer, parser, and ORM.

To get a simple model built, this will work:

class Person
  include RDFForSQLite

  # Choose a useful base URI
  base_uri "http://example.org/people"

  property :name,  :predicate => FOAF.name

  validate :presence_of_name

  protected
    def presence_of_name
      assert_set :name
    end

end

A full example using Sinatra looks like this:

require 'rubygems'
require 'sinatra'
require 'haml'
require 'rdf_for_sqlite'

configure do
  set :repo, RDF::DataObjects::Repository.new('sqlite3:/tmp/demo.db')
  Spira.add_repository(:default, settings.repo)
end

class Concept

  include RDFForSQLite

  class << self
    def find_or_create_by_name(name)
      concept = Concept.for(concept_name(name))
      return concept if concept.exist?
      concept.name = name
      concept.save!
      concept
    end

    protected
      def concept_name(name)
        concept_name = name.downcase.gsub(/\s+/, '_')
      end

  end

  base_uri "http://example.org/example/concepts"

  property :name, :predicate => SKOS.prefLabel
  property :description, :predicate => SKOS.definition
  property :scope, :predicate => SKOS.scopeNote

end

get "/" do
  haml :home
end

post '/concepts' do
  concept = Concept.find_or_create_by_name(params[:concept][:name])
  concept.update_attributes(params[:concept])
  content_type :json
  concept.to_json
end

Installation¶ ↑

Install with:

[sudo] gem install rdf_for_sqlite

Status¶ ↑

This project is a work in progress. It is designed mostly to get a project going quickly with some models. I use RDF.rb because it’s so incredibly modular and easy to customize. This gem just assumes that a few RDF technologies will be needed. So, in that sense, this is a stupid gem to create. However, if looking for a recipe to get started with a little RDF data, this might be a place to start.

Note on Patches/Pull Requests¶ ↑

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but

    bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 David Richards

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.