Skip to content

Commit

Permalink
Merge da349bc into 31d901c
Browse files Browse the repository at this point in the history
  • Loading branch information
elrayle committed Jul 30, 2016
2 parents 31d901c + da349bc commit 92c0db7
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 49 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ script: "bundle exec rspec spec"
sudo: false
cache: bundler
rvm:
- 2.1
- 2.2.2
- 2.2.4
- 2.3.0
- 2.3.1
- jruby-9.0.4.0
- rbx-2
- rbx
matrix:
allow_failures:
- rvm: jruby-9.0.4.0
- rvm: rbx-2
- rvm: rbx
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ source 'https://rubygems.org'

gemspec

gem 'activesupport', '< 5.0.0' if RUBY_VERSION =~ /2\.1\..*/
gem 'pry-byebug' unless ENV["CI"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Or install it yourself as:

$ gem install ld4l-foaf_rdf

## Primary Dependencies

* [ActiveTriples 0.10.0](https://github.com/ActiveTriples/ActiveTriples/tree/v0.10.0)
* [RDF 2.0.2](https://github.com/ruby-rdf/rdf/tree/2.0.2)

## Usage

Expand Down
5 changes: 1 addition & 4 deletions ld4l-foaf_rdf.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
spec.description = %q{LD4L FOAF RDF provides tools for modeling a person triples based on the FOAF ontology and persisting to a triplestore.}
spec.homepage = "https://github.com/ld4l/foaf_rdf"
spec.license = "APACHE2"
spec.required_ruby_version = '>= 1.9.3'
spec.required_ruby_version = '>= 2.1'

spec.files = `git ls-files -z`.split("\x0")
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
Expand All @@ -22,12 +22,9 @@ Gem::Specification.new do |spec|
spec.add_dependency('active-triples')
spec.add_dependency('active_triples-local_name')

spec.add_development_dependency('pry')
spec.add_development_dependency('pry-byebug')
spec.add_development_dependency('rdoc')
spec.add_development_dependency('rspec')
spec.add_development_dependency('coveralls')
spec.add_development_dependency('guard-rspec')
spec.add_development_dependency('webmock')

spec.extra_rdoc_files = [
Expand Down
2 changes: 1 addition & 1 deletion lib/ld4l/foaf_rdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def self.configure


# RDF vocabularies
# none - uses RDF::FOAF vocabulary
# none - uses RDF::Vocab::FOAF vocabulary

# autoload classes
autoload :Configuration, 'ld4l/foaf_rdf/configuration'
Expand Down
2 changes: 1 addition & 1 deletion lib/ld4l/foaf_rdf/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Agent < ActiveTriples::Resource
class << self; attr_reader :localname_prefix end
@localname_prefix="a"

configure :type => RDF::FOAF.Agent, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
configure :type => RDF::Vocab::FOAF.Agent, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default

property :label, :predicate => RDF::RDFS.label
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ld4l/foaf_rdf/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Person < ActiveTriples::Resource
class << self; attr_reader :localname_prefix end
@localname_prefix="p"

configure :type => RDF::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
configure :type => RDF::Vocab::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
end
end
end
2 changes: 1 addition & 1 deletion lib/ld4l/foaf_rdf/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module LD4L
module FoafRDF
VERSION = "0.1.0"
VERSION = "0.2.0"
end
end
34 changes: 18 additions & 16 deletions spec/ld4l/foaf_rdf/agent_rdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@

describe 'when changing subject' do
before do
subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland'))
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject)
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land')
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland'))
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject)
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land')
subject.set_subject! RDF::URI('http://example.org/moomin')
end

it 'should update graph subjects' do
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland')))).to be true
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland')))).to be true
end

it 'should update graph objects' do
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject))).to be true
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject))).to be true
end

it 'should leave other uris alone' do
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land'))).to be true
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land'))).to be true
end
end

Expand All @@ -57,8 +57,8 @@
# -------------------------------------------------

describe 'type' do
it "should be an RDF::FOAF.Agent" do
expect(subject.type.first.value).to eq RDF::FOAF.Agent.value
it "should be an RDF::Vocab::FOAF.Agent" do
expect(subject.type.first.value).to eq RDF::Vocab::FOAF.Agent.value
end
end

Expand Down Expand Up @@ -139,7 +139,7 @@

describe '#destroy!' do
before do
subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
end

subject { LD4L::FoafRDF::Agent.new('456')}
Expand Down Expand Up @@ -196,18 +196,18 @@
before do
class DummyPerson < ActiveTriples::Resource
configure :type => RDF::URI('http://example.org/Person')
property :foafname, :predicate => RDF::FOAF.name
property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
property :foafname, :predicate => RDF::Vocab::FOAF.name
property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
end

class DummyDocument < ActiveTriples::Resource
configure :type => RDF::URI('http://example.org/Document')
property :title, :predicate => RDF::DC.title
property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
property :title, :predicate => RDF::Vocab::DC.title
property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
end

LD4L::FoafRDF::Agent.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
LD4L::FoafRDF::Agent.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
end

subject { LD4L::FoafRDF::Agent.new }
Expand Down Expand Up @@ -260,8 +260,10 @@ class DummyDocument < ActiveTriples::Resource
document1.creator = [person1, person2]
document2.creator = person1
person1.knows = person2
person2.knows = person1
subject.item = [document1]
expect(subject.item.first.creator.first.knows.first.foafname).to eq ['Bob']
expect(subject.item.first.creator.first.knows.first.foafname)
.to satisfy { |names| ['Alice', 'Bob'].include? names.first }
end
end
end
10 changes: 5 additions & 5 deletions spec/ld4l/foaf_rdf/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
context "when base_uri is not configured" do
before do
class DummyPerson < LD4L::FoafRDF::Person
configure :type => RDF::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
configure :type => RDF::Vocab::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
end
end
after do
Expand All @@ -24,7 +24,7 @@ class DummyPerson < LD4L::FoafRDF::Person
config.base_uri = "http://localhost/test_slash/"
end
class DummyPerson < LD4L::FoafRDF::Person
configure :type => RDF::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
configure :type => RDF::Vocab::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
end
end
after do
Expand All @@ -43,7 +43,7 @@ class DummyPerson < LD4L::FoafRDF::Person
config.base_uri = "http://localhost/test_no_slash"
end
class DummyPerson < LD4L::FoafRDF::Person
configure :type => RDF::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
configure :type => RDF::Vocab::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
end
end
after do
Expand Down Expand Up @@ -86,7 +86,7 @@ class DummyPerson < LD4L::FoafRDF::Person
context "when minter is nil" do
before do
class DummyPerson < LD4L::FoafRDF::Person
configure :type => RDF::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
configure :type => RDF::Vocab::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
end
end
after do
Expand All @@ -108,7 +108,7 @@ class DummyPerson < LD4L::FoafRDF::Person
config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid }
end
class DummyPerson < LD4L::FoafRDF::Person
configure :type => RDF::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
configure :type => RDF::Vocab::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
end
end
after do
Expand Down
34 changes: 18 additions & 16 deletions spec/ld4l/foaf_rdf/person_rdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@

describe 'when changing subject' do
before do
subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland'))
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject)
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land')
subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland'))
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject)
subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land')
subject.set_subject! RDF::URI('http://example.org/moomin')
end

it 'should update graph subjects' do
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland')))).to be true
expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, RDF::Literal('Comet in Moominland')))).to be true
end

it 'should update graph objects' do
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject))).to be true
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.isPartOf, subject.rdf_subject))).to be true
end

it 'should leave other uris alone' do
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land'))).to be true
expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::Vocab::DC.relation, 'http://example.org/moomin_land'))).to be true
end
end

Expand All @@ -58,8 +58,8 @@
# -------------------------------------------------

describe 'type' do
it "should be an RDF::FOAF.Person" do
expect(subject.type.first.value).to eq RDF::FOAF.Person.value
it "should be an RDF::Vocab::FOAF.Person" do
expect(subject.type.first.value).to eq RDF::Vocab::FOAF.Person.value
end
end

Expand Down Expand Up @@ -128,7 +128,7 @@

describe '#destroy!' do
before do
subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
subject << RDF::Statement(RDF::Vocab::DC.LicenseDocument, RDF::Vocab::DC.title, 'LICENSE')
end

subject { LD4L::FoafRDF::Person.new('456')}
Expand Down Expand Up @@ -185,18 +185,18 @@
before do
class DummyPerson < ActiveTriples::Resource
configure :type => RDF::URI('http://example.org/Person')
property :foafname, :predicate => RDF::FOAF.name
property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
property :foafname, :predicate => RDF::Vocab::FOAF.name
property :publications, :predicate => RDF::Vocab::FOAF.publications, :class_name => 'DummyDocument'
property :knows, :predicate => RDF::Vocab::FOAF.knows, :class_name => DummyPerson
end

class DummyDocument < ActiveTriples::Resource
configure :type => RDF::URI('http://example.org/Document')
property :title, :predicate => RDF::DC.title
property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
property :title, :predicate => RDF::Vocab::DC.title
property :creator, :predicate => RDF::Vocab::DC.creator, :class_name => 'DummyPerson'
end

LD4L::FoafRDF::Person.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
LD4L::FoafRDF::Person.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument
end

subject { LD4L::FoafRDF::Person.new }
Expand Down Expand Up @@ -249,8 +249,10 @@ class DummyDocument < ActiveTriples::Resource
document1.creator = [person1, person2]
document2.creator = person1
person1.knows = person2
person2.knows = person1
subject.item = [document1]
expect(subject.item.first.creator.first.knows.first.foafname).to eq ['Bob']
expect(subject.item.first.creator.first.knows.first.foafname)
.to satisfy { |names| ['Alice', 'Bob'].include? names.first }
end
end
end
2 changes: 1 addition & 1 deletion spec/ld4l/foaf_rdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid }
end
class DummyPerson < LD4L::FoafRDF::Person
configure :type => RDF::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
configure :type => RDF::Vocab::FOAF.Person, :base_uri => LD4L::FoafRDF.configuration.base_uri, :repository => :default
end
end
after do
Expand Down

0 comments on commit 92c0db7

Please sign in to comment.