RubyKpi
With RubyKpi it is possible to access a SmartM3 Smart Space building a KP (Knowledge Processor). The primitives provided by this package are those to join/leave a smart space, to insert, remove, update and retrieve knowledge.
Installation
Add this line to your application's Gemfile:
gem 'ruby_kpi'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ruby_kpi
Usage
To instantiate a KP: mykp = KP.new(SIB_ip, SIB_port, SS, [debug])
To join or leave a smart space: status = mykp.join_sib()
and status = mykp.leave_sib()
The definition of a triple can be done with: Triple.new(subject, predicate, object)
where subject and predicate must be URI instances, while the object can be a URI or a Literal. The URI class can also be instantiated with nil as a parameter, in order to match the "any" pattern.
Once a triple or a triple pattern has been defined, it is possible to insert/remove one or more triples with: status = mykp.insert([t1]) status = mykp.remove([t2])
or it is possible to update one or more triples with: status = mykp.update([t1], [t2])
A triple pattern can also be used to made a query: status, results = mykp.rdf_query(t1)
or to subscribe to a triple insertion/removal: status, sub_id, results = mykp.rdf_subscribe(t, MyHandler)
where MyHandler is a class that implements the method handle to operate on added and removed triples.
Queries and subscriptions can also be done with SPARQL: q = "SELECT ?s ?p ?o WHERE { ?s ?p ?o }" status, results = mykp.sparql_query(q, MyHandler) status, sub_id, results = mykp.sparql_subscribe(q, MyHandler)
A subscription can be closed with: status = mykp.unsubscribe(sub_id)
Contributing
- Fork it ( https://github.com/[my-github-username]/ruby_kpi/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request