-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use local name minter; Test localname_prefix; Add config examples
* get active triples from new ActiveTriples repository in github * add active_triples-local_name gem; add configuration for a local name minter function * change id_prefix to localname_prefix to be more accurately descriptive * write tests for localname_prefix * add configuration examples to README
- Loading branch information
Showing
10 changed files
with
202 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ source 'https://rubygems.org' | |
|
||
gemspec | ||
|
||
# GETTING FROM GEMFILE UNTIL MintLocalName CODE IS PUSHED INTO MASTER, THEN MOVE THIS BACK TO *.gemspec FILE | ||
# Use active-triple for handling of triple persistence | ||
gem "active-triples", :git => '[email protected]:no-reply/ActiveTriples.git', :branch => 'generate_id' | ||
# GETTING FROM GEMFILE UNTIL ActiveTriples master CODE IS RELEASED (>0.4.0), THEN MOVE THIS BACK TO *.gemspec FILE | ||
# Use active-triples for handling of triple persistence | ||
gem 'active-triples', :git => '[email protected]:ActiveTriples/ActiveTriples.git', :branch => 'master' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,68 +2,128 @@ | |
|
||
LD4L FOAF RDF provides tools for modeling person triples based on the FOAF ontology and persisting to a triplestore. | ||
|
||
|
||
## Installation | ||
|
||
Temporary get the gem from github until the gem is released publicly. | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
gem 'ld4l-foaf_rdf' | ||
<!-- gem 'ld4l-foaf_rdf' --> | ||
gem 'ld4l-foaf_rdf', '~> 0.0.3', :git => '[email protected]:ld4l/foaf_rdf.git' | ||
|
||
|
||
And then execute: | ||
|
||
$ bundle install | ||
|
||
<!-- | ||
Or install it yourself as: | ||
$ gem install ld4l-foaf_rdf | ||
--> | ||
|
||
|
||
## Usage | ||
|
||
**Caveat:** This gem is part of the LD4L Project and is being used in that context. There is no guarantee that the | ||
code will work in a usable way outside of its use in LD4L Use Cases. | ||
|
||
### Models | ||
### Examples | ||
|
||
The LD4L::FoafRDF gem provides model definitions using the | ||
[ActiveTriples](https://github.com/no-reply/ActiveTriples) framework extension of | ||
[ruby-rdf/rdf](https://github.com/ruby-rdf/rdf). The following models are provided: | ||
Setup required for all examples. | ||
``` | ||
require 'ld4l/foaf_rdf' | ||
1. LD4L::FoafRDF::Person - Implements the Person class in the FOAF ontology. | ||
# create an in-memory repository | ||
ActiveTriples::Repositories.add_repository :default, RDF::Repository.new | ||
``` | ||
|
||
### Ontologies | ||
Example creating a person. | ||
``` | ||
p = LD4L::FoafRDF::Person.new('p4') | ||
The listed ontologies are used to represent the primary metadata about the person. | ||
Other ontologies may also be used that aren't listed. | ||
|
||
* [FOAF](http://xmlns.com/foaf/spec/) | ||
* [RDF](http://www.w3.org/TR/rdf-syntax-grammar/) | ||
puts p.dump :ttl | ||
``` | ||
|
||
Example triples created for a person. | ||
``` | ||
<http://localhost/p4> a <http://xmlns.com/foaf/0.1/Person> . | ||
``` | ||
|
||
|
||
### Creating a Person | ||
### Configurations | ||
|
||
Start console in a terminal. | ||
* base_uri - base URI used when new resources are created (default="http://localhost/") | ||
* localname_minter - minter function to use for creating unique local names (default=nil which uses default minter in active_triples-local_name gem) | ||
|
||
*Setup for all examples.* | ||
|
||
* Restart your interactive session (e.g. irb, pry). | ||
* Use the Setup for all examples in main Examples section above. | ||
|
||
*Example usage using configured base_uri and default localname_minter.* | ||
``` | ||
bundle console | ||
LD4L::FoafRDF.configure do |config| | ||
config.base_uri = "http://example.org/" | ||
end | ||
p = LD4L::FoafRDF::Person.new(ActiveTriples::LocalName::Minter.generate_local_name( | ||
LD4L::FoafRDF::Person, 10, {:prefix=>'p'} )) | ||
puts p.dump :ttl | ||
``` | ||
NOTE: If base_uri is not used, you need to restart your interactive environment (e.g. irb, pry). Once the | ||
Person class is instantiated the first time, the base_uri for the class is set. If you ran | ||
through the main Examples, the base_uri was set to the default base_uri. | ||
|
||
In console, you can test creating a person. | ||
|
||
*Example triples created for a person with configured base_uri and default minter.* | ||
``` | ||
<http://example.org/p45c9c85b-25af-4c52-96a4-cf0d8b70a768> a <http://xmlns.com/foaf/0.1/Person> . | ||
``` | ||
# Create an in-memory repository | ||
ActiveTriples::Repositories.add_repository :default, RDF::Repository.new | ||
|
||
# Configure a base_uri for all person objects | ||
*Example usage using configured base_uri and configured localname_minter.* | ||
``` | ||
LD4L::FoafRDF.configure do |config| | ||
config.base_uri = "http://example.org/individual/" | ||
config.base_uri = "http://example.org/" | ||
config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid } | ||
end | ||
# Create a person | ||
p = LD4L::FoafRDF::Person.new('1') | ||
p.rdf_subject | ||
# => http://example.org/individual/pr1 | ||
p = LD4L::FoafRDF::Person.new(ActiveTriples::LocalName::Minter.generate_local_name( | ||
LD4L::FoafRDF::Person, 10, 'p', | ||
&LD4L::FoafRDF.configuration.localname_minter )) | ||
# View triples as tutle | ||
puts p.dump :ttl | ||
# => <http://example.org/individual/p1> a <http://xmlns.com/foaf/0.1/Person> . | ||
``` | ||
NOTE: If base_uri is not used, you need to restart your interactive environment (e.g. irb, pry). Once the | ||
Person class is instantiated the first time, the base_uri for the class is set. If you ran | ||
through the main Examples, the base_uri was set to the default base_uri. | ||
|
||
|
||
*Example triples created for a person with configured base_uri and configured minter.* | ||
``` | ||
<http://example.org/p_configured_6498ba05-8b21-4e8c-b9d4-a6d5d2180966> a <http://xmlns.com/foaf/0.1/Person> . | ||
``` | ||
|
||
|
||
### Models | ||
|
||
The LD4L::FoafRDF gem provides model definitions using the | ||
[ActiveTriples](https://github.com/ActiveTriples/ActiveTriples) framework extension of | ||
[ruby-rdf/rdf](https://github.com/ruby-rdf/rdf). The following models are provided: | ||
|
||
1. LD4L::FoafRDF::Person - Implements the Person class in the FOAF ontology. (extremely simple for holding rdf_subject only) | ||
|
||
|
||
### Ontologies | ||
|
||
The listed ontologies are used to represent the primary metadata about the person. | ||
Other ontologies may also be used that aren't listed. | ||
|
||
* [FOAF](http://xmlns.com/foaf/spec/) | ||
* [RDF](http://www.w3.org/TR/rdf-syntax-grammar/) | ||
|
||
|
||
## Contributing | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.