From eb24770e1ab08c2e9a9f1af00762d5ca21ef25e6 Mon Sep 17 00:00:00 2001 From: "E. Lynette Rayle" Date: Fri, 29 Jul 2016 15:28:56 -0400 Subject: [PATCH] Update to AT 0.10.0 and RDF 2.0.2 --- .travis.yml | 8 +++--- Gemfile | 2 ++ README.md | 4 +++ ld4l-foaf_rdf.gemspec | 6 +---- lib/ld4l/foaf_rdf.rb | 18 +------------ lib/ld4l/foaf_rdf/agent.rb | 2 +- lib/ld4l/foaf_rdf/person.rb | 2 +- lib/ld4l/foaf_rdf/version.rb | 2 +- spec/ld4l/foaf_rdf/agent_rdf_spec.rb | 34 +++++++++++++----------- spec/ld4l/foaf_rdf/configuration_spec.rb | 10 +++---- spec/ld4l/foaf_rdf/person_rdf_spec.rb | 34 +++++++++++++----------- spec/ld4l/foaf_rdf_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 13 files changed, 59 insertions(+), 67 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a3fe48..59caf09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Gemfile b/Gemfile index 9e9ddcc..338f1e7 100644 --- a/Gemfile +++ b/Gemfile @@ -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"] diff --git a/README.md b/README.md index 28d871a..eb446b8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ld4l-foaf_rdf.gemspec b/ld4l-foaf_rdf.gemspec index ceea037..bde4e34 100644 --- a/ld4l-foaf_rdf.gemspec +++ b/ld4l-foaf_rdf.gemspec @@ -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)/}) @@ -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 = [ @@ -35,4 +32,3 @@ Gem::Specification.new do |spec| "README.md" ] end - diff --git a/lib/ld4l/foaf_rdf.rb b/lib/ld4l/foaf_rdf.rb index 3f06b01..516d4dc 100644 --- a/lib/ld4l/foaf_rdf.rb +++ b/lib/ld4l/foaf_rdf.rb @@ -27,28 +27,12 @@ def self.configure # RDF vocabularies - # none - uses RDF::FOAF vocabulary + # none - uses RDF::Vocab::FOAF vocabulary # autoload classes autoload :Configuration, 'ld4l/foaf_rdf/configuration' autoload :Person, 'ld4l/foaf_rdf/person' autoload :Agent, 'ld4l/foaf_rdf/agent' - - def self.class_from_string(class_name, container_class=Kernel) - container_class = container_class.name if container_class.is_a? Module - container_parts = container_class.split('::') - (container_parts + class_name.split('::')).flatten.inject(Kernel) do |mod, class_name| - if mod == Kernel - Object.const_get(class_name) - elsif mod.const_defined? class_name.to_sym - mod.const_get(class_name) - else - container_parts.pop - class_from_string(class_name, container_parts.join('::')) - end - end - end - end end diff --git a/lib/ld4l/foaf_rdf/agent.rb b/lib/ld4l/foaf_rdf/agent.rb index cd031ca..b364310 100644 --- a/lib/ld4l/foaf_rdf/agent.rb +++ b/lib/ld4l/foaf_rdf/agent.rb @@ -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 diff --git a/lib/ld4l/foaf_rdf/person.rb b/lib/ld4l/foaf_rdf/person.rb index 3f41b93..3001526 100644 --- a/lib/ld4l/foaf_rdf/person.rb +++ b/lib/ld4l/foaf_rdf/person.rb @@ -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 diff --git a/lib/ld4l/foaf_rdf/version.rb b/lib/ld4l/foaf_rdf/version.rb index cbbd105..95d1cd8 100644 --- a/lib/ld4l/foaf_rdf/version.rb +++ b/lib/ld4l/foaf_rdf/version.rb @@ -1,5 +1,5 @@ module LD4L module FoafRDF - VERSION = "0.1.0" + VERSION = "0.2.0" end end diff --git a/spec/ld4l/foaf_rdf/agent_rdf_spec.rb b/spec/ld4l/foaf_rdf/agent_rdf_spec.rb index 904c56a..623ef72 100644 --- a/spec/ld4l/foaf_rdf/agent_rdf_spec.rb +++ b/spec/ld4l/foaf_rdf/agent_rdf_spec.rb @@ -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 @@ -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 @@ -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')} @@ -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 } @@ -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 diff --git a/spec/ld4l/foaf_rdf/configuration_spec.rb b/spec/ld4l/foaf_rdf/configuration_spec.rb index 04b71df..f00c1c7 100644 --- a/spec/ld4l/foaf_rdf/configuration_spec.rb +++ b/spec/ld4l/foaf_rdf/configuration_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/spec/ld4l/foaf_rdf/person_rdf_spec.rb b/spec/ld4l/foaf_rdf/person_rdf_spec.rb index 2f0d74f..ee6eabe 100644 --- a/spec/ld4l/foaf_rdf/person_rdf_spec.rb +++ b/spec/ld4l/foaf_rdf/person_rdf_spec.rb @@ -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 @@ -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 @@ -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')} @@ -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 } @@ -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 diff --git a/spec/ld4l/foaf_rdf_spec.rb b/spec/ld4l/foaf_rdf_spec.rb index 7f01420..fdcfa9d 100644 --- a/spec/ld4l/foaf_rdf_spec.rb +++ b/spec/ld4l/foaf_rdf_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 512cc63..159d1ce 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,7 +5,7 @@ Bundler.setup require 'ld4l/foaf_rdf' -require 'pry' +require 'pry' unless ENV["CI"] Dir['./spec/support/**/*.rb'].each { |f| require f }