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 940d813..338f1e7 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,5 @@ source 'https://rubygems.org' gemspec -gem 'active-triples', :github => 'ActiveTriples/ActiveTriples', :branch => 'fix206_exclude_othersubj_preds' +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 e4524f3..cf09206 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,11 @@ Or install it yourself as: $ gem install ld4l-ore_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 **Caveat:** This gem is part of the LD4L Project and is being used in that context. There is no guarantee that the @@ -167,7 +172,7 @@ aggregation_uris = LD4L::OreRDF::FindAggregations.call # Find all and return title and description aggregation_properties = LD4L::OreRDF::FindAggregations.call( - :properties => { :title => RDF::DC.title, :description => RDF::DC.description } ) + :properties => { :title => RDF::Vocab::DC.title, :description => RDF::Vocab::DC.description } ) ``` diff --git a/ld4l-ore_rdf.gemspec b/ld4l-ore_rdf.gemspec index ddd64f5..4bcb699 100644 --- a/ld4l-ore_rdf.gemspec +++ b/ld4l-ore_rdf.gemspec @@ -13,25 +13,21 @@ Gem::Specification.new do |spec| spec.description = %q{LD4L ORE RDF provides tools for modeling list triples based on the ORE ontology and persisting to a triplestore.} spec.homepage = "https://github.com/ld4l/ore_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)/}) - spec.add_dependency('rdf', '= 1.99.0') - + spec.add_dependency('rdf') spec.add_dependency('active-triples') spec.add_dependency('active_triples-local_name') spec.add_dependency('active_triples-solrizer') spec.add_dependency('ld4l-foaf_rdf') spec.add_dependency('doubly_linked_list') - 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 = [ diff --git a/lib/ld4l/ore_rdf.rb b/lib/ld4l/ore_rdf.rb index dd37d76..296c4b4 100644 --- a/lib/ld4l/ore_rdf.rb +++ b/lib/ld4l/ore_rdf.rb @@ -6,9 +6,6 @@ require 'doubly_linked_list' require 'ld4l/foaf_rdf' require 'ld4l/ore_rdf/version' -require 'ld4l/ore_rdf/vocab/ore' -require 'ld4l/ore_rdf/vocab/iana' -require 'ld4l/ore_rdf/vocab/dcterms' module LD4L module OreRDF @@ -31,12 +28,6 @@ def self.configure end - # RDF vocabularies - autoload :DCTERMS, 'ld4l/ore_rdf/vocab/dcterms' - autoload :IANA, 'ld4l/ore_rdf/vocab/iana' - autoload :ORE, 'ld4l/ore_rdf/vocab/ore' - - # autoload classes autoload :Configuration, 'ld4l/ore_rdf/configuration' diff --git a/lib/ld4l/ore_rdf/models/aggregation_resource.rb b/lib/ld4l/ore_rdf/models/aggregation_resource.rb index 32657a7..3e8d7d3 100644 --- a/lib/ld4l/ore_rdf/models/aggregation_resource.rb +++ b/lib/ld4l/ore_rdf/models/aggregation_resource.rb @@ -18,29 +18,29 @@ class << self; attr_reader :localname_prefix end # TODO DOWNSIDE: items and aggregators could get out of sync. Then which is right? Could be a problem with the first option too. - configure :type => RDFVocabularies::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default + configure :type => RDF::Vocab::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default # extended properties for LD4L implementation - property :title, :predicate => RDF::DC.title do |index| + property :title, :predicate => RDF::Vocab::DC.title do |index| index.data_type = :text index.as :indexed, :sortable end - property :description, :predicate => RDF::DC.description do |index| + property :description, :predicate => RDF::Vocab::DC.description do |index| index.data_type = :text index.as :indexed end - property :owner, :predicate => RDFVocabularies::DCTERMS.creator, :class_name => LD4L::FoafRDF::Person do |index| + property :owner, :predicate => RDF::Vocab::DC.creator, :class_name => LD4L::FoafRDF::Person do |index| index.data_type = :string index.as :stored, :indexed end # properties from ORE.Aggregation - property :aggregates, :predicate => RDFVocabularies::ORE.aggregates, :cast => false do |index| + property :aggregates, :predicate => RDF::Vocab::ORE.aggregates, :cast => false do |index| index.data_type = :text index.as :stored, :indexed, :multiValued end - property :first_proxy_, :predicate => RDFVocabularies::IANA.first, :class_name => LD4L::OreRDF::ProxyResource - property :last_proxy_, :predicate => RDFVocabularies::IANA.last, :class_name => LD4L::OreRDF::ProxyResource + property :first_proxy_, :predicate => RDF::Vocab::IANA.first, :class_name => LD4L::OreRDF::ProxyResource + property :last_proxy_, :predicate => RDF::Vocab::IANA.last, :class_name => LD4L::OreRDF::ProxyResource def first_proxy= value diff --git a/lib/ld4l/ore_rdf/models/proxy_resource.rb b/lib/ld4l/ore_rdf/models/proxy_resource.rb index 76555f2..8bfdb41 100644 --- a/lib/ld4l/ore_rdf/models/proxy_resource.rb +++ b/lib/ld4l/ore_rdf/models/proxy_resource.rb @@ -6,13 +6,13 @@ class << self; attr_reader :localname_prefix end @localname_prefix="px" # configure :base_uri => LD4L::OreRDF.configuration.base_uri, repository => :default - configure :type => RDFVocabularies::ORE.Proxy, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default + configure :type => RDF::Vocab::ORE.Proxy, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default - property :proxy_for_, :predicate => RDFVocabularies::ORE.proxyFor, :cast => false - property :proxy_in_, :predicate => RDFVocabularies::ORE.proxyIn, :class_name => LD4L::OreRDF::AggregationResource - property :next_proxy_, :predicate => RDFVocabularies::IANA.next, :class_name => LD4L::OreRDF::ProxyResource - property :prev_proxy_, :predicate => RDFVocabularies::IANA.prev, :class_name => LD4L::OreRDF::ProxyResource - property :contributor, :predicate => RDF::DC.contributor, :class_name => LD4L::FoafRDF::Person # TODO User who added this item to the Aggregation (default=Aggregation's owner) + property :proxy_for_, :predicate => RDF::Vocab::ORE.proxyFor, :cast => false + property :proxy_in_, :predicate => RDF::Vocab::ORE.proxyIn, :class_name => LD4L::OreRDF::AggregationResource + property :next_proxy_, :predicate => RDF::Vocab::IANA.next, :class_name => LD4L::OreRDF::ProxyResource + property :prev_proxy_, :predicate => RDF::Vocab::IANA.prev, :class_name => LD4L::OreRDF::ProxyResource + property :contributor, :predicate => RDF::Vocab::DC.contributor, :class_name => LD4L::FoafRDF::Person # TODO User who added this item to the Aggregation (default=Aggregation's owner) def proxy_for= value @@ -90,8 +90,8 @@ def self.get_range( aggregation, start=0, limit=nil ) graph = ActiveTriples::Repositories.repositories[repository] query = RDF::Query.new({ :proxy => { - RDF.type => RDFVocabularies::ORE.Proxy, - RDFVocabularies::ORE.proxyIn => aggregation_resource, + RDF.type => RDF::Vocab::ORE.Proxy, + RDF::Vocab::ORE.proxyIn => aggregation_resource, } }) diff --git a/lib/ld4l/ore_rdf/services/aggregation/find.rb b/lib/ld4l/ore_rdf/services/aggregation/find.rb index deee4ce..5ee8791 100644 --- a/lib/ld4l/ore_rdf/services/aggregation/find.rb +++ b/lib/ld4l/ore_rdf/services/aggregation/find.rb @@ -6,8 +6,8 @@ class FindAggregations # Find aggregations matching the specified criteria. # # @param [Hash] options the options to use to find aggregations - # @option options [Hash] :criteria for finding aggregations (ex. RDF::DC.title=>'My Aggregation') (default - nil for all aggregations) - # @option options [Hash] :properties to return with the aggregation uri (ex. :first_proxy=>RDFVocabularies::IANA.first) (default - nil aggregation uri only) + # @option options [Hash] :criteria for finding aggregations (ex. RDF::Vocab::DC.title=>'My Aggregation') (default - nil for all aggregations) + # @option options [Hash] :properties to return with the aggregation uri (ex. :first_proxy=>RDF::Vocab::IANA.first) (default - nil aggregation uri only) # @option options [Symbol] :repository to search (default - :default) # @option options [TrueClass,FalseClass] :resume if true, find and resume; otherwise, find only (default - false) # @@ -31,7 +31,7 @@ def self.call( options={} ) raise ArgumentError, 'criteria must be a hash of attribute-value pairs for searching for aggregations' unless criteria.nil? || criteria.kind_of?(Hash) criteria = criteria ? criteria.dup : {} - criteria[RDF.type] = RDFVocabularies::ORE.Aggregation + criteria[RDF.type] = RDF::Vocab::ORE.Aggregation # properties are ignored when resume==true because all properties are returned as part of the resumed aggregations properties = options[:properties] || nil diff --git a/lib/ld4l/ore_rdf/services/proxy/find.rb b/lib/ld4l/ore_rdf/services/proxy/find.rb index 2facfcf..1939a06 100644 --- a/lib/ld4l/ore_rdf/services/proxy/find.rb +++ b/lib/ld4l/ore_rdf/services/proxy/find.rb @@ -7,8 +7,8 @@ class FindProxies # # @param [Hash] options the options to use to find proxies # @option options [String, RDF::URI, LD4L::OreRDF::AggregationResource] :aggregation - limit proxies found to this aggregation (required) - # @option options [Hash] :criteria for finding proxies (ex. RDF::DC.proxy_in=>RDF::URI('http://example.org/ag123')) (default - nil for all proxies in the aggregation) - # @option options [Hash] :properties to return with the proxy uri (ex. :proxy_for=>RDFVocabularies::ORE.proxyFor) (default - nil aggregation uri only) + # @option options [Hash] :criteria for finding proxies (ex. RDF::Vocab::ORE.proxy_in=>RDF::URI('http://example.org/ag123')) (default - nil for all proxies in the aggregation) + # @option options [Hash] :properties to return with the proxy uri (ex. :proxy_for=>RDF::Vocab::ORE.proxyFor) (default - nil aggregation uri only) # @option options [Symbol] :repository to search (default - :default) # @option options [TrueClass,FalseClass] :resume if true, find and resume; otherwise, find only (default - false) # @@ -50,8 +50,8 @@ def self.call( options={} ) raise ArgumentError, 'criteria must be a hash of attribute-value pairs for searching for proxies' unless criteria.nil? || criteria.kind_of?(Hash) criteria = criteria ? criteria.dup : {} - criteria[RDF.type] = RDFVocabularies::ORE.Proxy - criteria[RDFVocabularies::ORE.proxyIn] = aggregation + criteria[RDF.type] = RDF::Vocab::ORE.Proxy + criteria[RDF::Vocab::ORE.proxyIn] = aggregation # properties are ignored when resume==true because all properties are returned as part of the resumed proxies properties = options[:properties] || nil diff --git a/lib/ld4l/ore_rdf/version.rb b/lib/ld4l/ore_rdf/version.rb index 221f61b..c433f1d 100644 --- a/lib/ld4l/ore_rdf/version.rb +++ b/lib/ld4l/ore_rdf/version.rb @@ -1,5 +1,5 @@ module LD4L module OreRDF - VERSION = "0.2.0" + VERSION = "0.3.0" end end diff --git a/lib/ld4l/ore_rdf/vocab/co.rb b/lib/ld4l/ore_rdf/vocab/co.rb deleted file mode 100644 index fdaf4a1..0000000 --- a/lib/ld4l/ore_rdf/vocab/co.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rdf' -module RDFVocabularies - class CO < RDF::Vocabulary("http://purl.org/co#") - - # Class definitions - term :Set # used for unordered lists - term :List # used for ordered lists - term :Element # used for items in an unordered list - term :ListItem # used for items in an ordered list - - # Property definitions for CO.Set and CO.List - property :size # xsd:nonNegativeInteger -- count of all Elements/ListItems in this list - property :item # URI of each ListItem in this List - - # Property definitions for CO.List - property :firstItem # URI to first ListItem in an ordered list - property :lastItem # URI to last ListItem in an ordered list - - # Property definitions for CO.Element and CO.ListItem - property :itemContent # URI to any content - - # Property definitions for CO.ListItem - property :index # xsd:positiveInteger -- index of each ListItem starting at 1 counting up - property :nextItem # URI to a ListItem - property :previousItem # URI to a ListItem - end -end diff --git a/lib/ld4l/ore_rdf/vocab/dcterms.rb b/lib/ld4l/ore_rdf/vocab/dcterms.rb deleted file mode 100644 index 4d034ad..0000000 --- a/lib/ld4l/ore_rdf/vocab/dcterms.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'rdf' -module RDFVocabularies - class DCTERMS < RDF::Vocabulary("http://purl.org/dc/terms/") - property :format - end -end diff --git a/lib/ld4l/ore_rdf/vocab/iana.rb b/lib/ld4l/ore_rdf/vocab/iana.rb deleted file mode 100644 index 2844dda..0000000 --- a/lib/ld4l/ore_rdf/vocab/iana.rb +++ /dev/null @@ -1,9 +0,0 @@ -# require 'rdf' -module RDFVocabularies - class IANA < RDF::Vocabulary("http://www.iana.org/assignments/relation/") - property :first # URI of first item - An IRI that refers to the furthest preceding resource in a series of resources. - property :last # URI of last item - An IRI that refers to the furthest following resource in a series of resources. - property :next # URI of next item - Indicates that the link's context is a part of a series, and that the next in the series is the link target. - property :prev # URI of previous item - Indicates that the link's context is a part of a series, and that the previous in the series is the link target. - end -end diff --git a/lib/ld4l/ore_rdf/vocab/ore.rb b/lib/ld4l/ore_rdf/vocab/ore.rb deleted file mode 100644 index 224e842..0000000 --- a/lib/ld4l/ore_rdf/vocab/ore.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rdf' -module RDFVocabularies - class ORE < RDF::Vocabulary("http://www.openarchives.org/ore/terms/") - - # Class definitions - term :Aggregation - term :Proxy - - # Property definitions ORE.Aggregation - property :aggregates # URI of each list item in this Aggregation - - # Property definitions for ORE.Proxy - property :proxyFor # URI of list item - property :proxyIn # URI of aggregating list - end -end diff --git a/spec/ld4l/ore_rdf/configuration_spec.rb b/spec/ld4l/ore_rdf/configuration_spec.rb index df701be..320b6c8 100644 --- a/spec/ld4l/ore_rdf/configuration_spec.rb +++ b/spec/ld4l/ore_rdf/configuration_spec.rb @@ -11,7 +11,7 @@ context "when base_uri is not configured" do before do class DummyAggregation < LD4L::OreRDF::AggregationResource - configure :type => RDFVocabularies::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default + configure :type => RDF::Vocab::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default end end after do @@ -28,7 +28,7 @@ class DummyAggregation < LD4L::OreRDF::AggregationResource config.base_uri = "http://localhost/test_slash/" end class DummyAggregation < LD4L::OreRDF::AggregationResource - configure :type => RDFVocabularies::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default + configure :type => RDF::Vocab::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default end end after do @@ -47,7 +47,7 @@ class DummyAggregation < LD4L::OreRDF::AggregationResource config.base_uri = "http://localhost/test_no_slash" end class DummyAggregation < LD4L::OreRDF::AggregationResource - configure :type => RDFVocabularies::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default + configure :type => RDF::Vocab::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default end end after do @@ -90,7 +90,7 @@ class DummyAggregation < LD4L::OreRDF::AggregationResource context "when minter is nil" do before do class DummyAggregation < LD4L::OreRDF::AggregationResource - configure :type => RDFVocabularies::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default + configure :type => RDF::Vocab::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default end end after do @@ -112,7 +112,7 @@ class DummyAggregation < LD4L::OreRDF::AggregationResource config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid } end class DummyAggregation < LD4L::OreRDF::AggregationResource - configure :type => RDFVocabularies::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default + configure :type => RDF::Vocab::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default end end after do diff --git a/spec/ld4l/ore_rdf/models/aggregation_resource_spec.rb b/spec/ld4l/ore_rdf/models/aggregation_resource_spec.rb index 549c9ae..700128e 100644 --- a/spec/ld4l/ore_rdf/models/aggregation_resource_spec.rb +++ b/spec/ld4l/ore_rdf/models/aggregation_resource_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 @@ -58,7 +58,7 @@ describe 'type' do it "should be an ORE.Aggregation" do - expect(subject.type.first.value).to eq RDFVocabularies::ORE.Aggregation.value + expect(subject.type.first.value).to eq RDF::Vocab::ORE.Aggregation.value end end @@ -139,9 +139,7 @@ subject.aggregates = bib1 subject.aggregates << bib2 subject.aggregates << bib3 - expect(subject.aggregates[0]).to eq bib1 - expect(subject.aggregates[1]).to eq bib2 - expect(subject.aggregates[2]).to eq bib3 + expect(subject.aggregates).to match_array [bib1,bib2,bib3] end it "should be changeable" do @@ -169,8 +167,8 @@ else # < ActiveTriples 0.8 aggregates = subject.aggregates.dup end - aggregates[0] = new_bib1 - aggregates[2] = new_bib3 + aggregates[aggregates.index(orig_bib1)] = new_bib1 + aggregates[aggregates.index(orig_bib3)] = new_bib3 subject.aggregates = aggregates expect(subject.aggregates).to include new_bib1 @@ -194,8 +192,8 @@ subject.aggregates.swap(orig_bib1, new_bib1) subject.aggregates.swap(orig_bib3, new_bib3) else # < ActiveTriples 0.8 - subject.aggregates[0] = new_bib1 - subject.aggregates[2] = new_bib3 + aggregates[aggregates.index(orig_bib1)] = new_bib1 + aggregates[aggregates.index(orig_bib3)] = new_bib3 end expect(subject.aggregates).to include new_bib1 expect(subject.aggregates).to include orig_bib2 @@ -243,19 +241,19 @@ end it 'should return a solr doc with all fields' do - object_profile = "{\"id\":\"http://example.org/moomin\",\"title\":[\"My Resources\"],\"description\":[\"Resources that I like\"],\"owner\":\"http://example.org/person1\",\"aggregates\":[\"http://example.org/resource_1\",\"http://example.org/resource_2\",\"http://example.org/resource_3\"],\"first_proxy_\":\"#{proxies.first.id}\",\"last_proxy_\":\"#{proxies.last.id}\"}" + object_profile = /{\"id\":\"http:\/\/example.org\/moomin\",\"title\":\[\"My Resources\"\],\"description\":\[\"Resources that I like\"\],\"owner\":\"http:\/\/example.org\/person1\",\"aggregates\":\[\"http:\/\/example.org\/resource_[123]\",\"http:\/\/example.org\/resource_[123]\",\"http:\/\/example.org\/resource_[123]\"\],\"first_proxy_\":\"#{Regexp.quote(proxies.first.id)}\",\"last_proxy_\":\"#{Regexp.quote(proxies.last.id)}\"}/ proxy_ids = proxies.collect { |p| p.id } - expected_solr_doc = {:id=>"http://example.org/moomin", - :at_model_ssi=>"LD4L::OreRDF::AggregationResource", - :object_profile_ss=>object_profile, - :title_ti=>"My Resources", - :title_ssort=>"My Resources", - :description_ti=>"Resources that I like", - :owner_ssi=>"http://example.org/person1", - :aggregates_tsim=> - ["http://example.org/resource_1", "http://example.org/resource_2", "http://example.org/resource_3"], - :item_proxies_ssm=>proxy_ids } - expect(@aggregation.aggregation_resource.generate_solr_document(@aggregation.proxy_resources)).to eq expected_solr_doc + + solr_doc = @aggregation.aggregation_resource.generate_solr_document(@aggregation.proxy_resources).to_hash + expect(solr_doc[:id]).to eq "http://example.org/moomin" + expect(solr_doc[:at_model_ssi]).to eq "LD4L::OreRDF::AggregationResource" + expect(solr_doc[:title_ti]).to eq "My Resources" + expect(solr_doc[:title_ssort]).to eq "My Resources" + expect(solr_doc[:description_ti]).to eq "Resources that I like" + expect(solr_doc[:owner_ssi]).to eq "http://example.org/person1" + expect(solr_doc[:aggregates_tsim]).to match_array ["http://example.org/resource_1", "http://example.org/resource_2", "http://example.org/resource_3"] + expect(solr_doc[:item_proxies_ssm]).to match_array proxy_ids + expect(solr_doc[:object_profile_ss]).to match object_profile end end @@ -442,9 +440,7 @@ end results = [] vci_array.each { |vci| results << vci.proxy_for_.first } - expect(results).to include "http://example.org/individual/b1" - expect(results).to include "http://example.org/individual/b2" - expect(results).to include "http://example.org/individual/b3" + expect(results).to match_array ["http://example.org/individual/b1","http://example.org/individual/b2","http://example.org/individual/b3"] expect(vci_array.size).to eq(3) end @@ -596,7 +592,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::OreRDF::AggregationResource.new('123') } @@ -662,29 +658,29 @@ context 'with unmodeled data' do before do - subject << RDF::Statement(subject.rdf_subject, RDF::DC.contributor, 'Tove Jansson') - subject << RDF::Statement(subject.rdf_subject, RDF::DC.relation, RDF::URI('http://example.org/moomi')) + subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.contributor, 'Tove Jansson') + subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.relation, RDF::URI('http://example.org/moomi')) node = RDF::Node.new - subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::DC.relation, node) - subject << RDF::Statement(node, RDF::DC.title, 'bnode') + subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::Vocab::DC.relation, node) + subject << RDF::Statement(node, RDF::Vocab::DC.title, 'bnode') end it 'should include data with URIs as attribute names' do - expect(subject.attributes[RDF::DC.contributor.to_s]).to eq ['Tove Jansson'] + expect(subject.attributes[RDF::Vocab::DC.contributor.to_s]).to eq ['Tove Jansson'] end it 'should return generic Resources' do - expect(subject.attributes[RDF::DC.relation.to_s].first).to be_a ActiveTriples::Resource + expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first).to be_a ActiveTriples::Resource end it 'should build deep data for Resources' do - expect(subject.attributes[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation). - first.get_values(RDF::DC.title)).to eq ['bnode'] + expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation). + first.get_values(RDF::Vocab::DC.title)).to eq ['bnode'] end it 'should include deep data in serializable_hash' do - expect(subject.serializable_hash[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation). - first.get_values(RDF::DC.title)).to eq ['bnode'] + expect(subject.serializable_hash[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation). + first.get_values(RDF::Vocab::DC.title)).to eq ['bnode'] end end @@ -724,8 +720,8 @@ describe '#set_value' do it 'should set a value in the graph' do - subject.set_value(RDF::DC.title, 'Comet in Moominland') - subject.query(:subject => subject.rdf_subject, :predicate => RDF::DC.title).each_statement do |s| + subject.set_value(RDF::Vocab::DC.title, 'Comet in Moominland') + subject.query(:subject => subject.rdf_subject, :predicate => RDF::Vocab::DC.title).each_statement do |s| expect(s.object.to_s).to eq 'Comet in Moominland' end end @@ -741,12 +737,12 @@ else # < ActiveTriples 0.8 error_name = RuntimeError end - expect{subject.set_value(RDF::DC.title, Object.new)}.to raise_error(error_name,/value must be an RDF URI, Node, Literal, or a valid datatype. See RDF::Literal.*/) + expect{subject.set_value(RDF::Vocab::DC.title, Object.new)}.to raise_error(error_name,/value must be an RDF URI, Node, Literal, or a valid datatype. See RDF::Literal.*/) end it "should be able to accept a subject" do - expect{subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::DC.title, 'Comet in Moominland')}.not_to raise_error - expect(subject.query(:subject => RDF::URI("http://opaquenamespace.org/jokes"), :predicate => RDF::DC.title).statements.to_a.length).to eq 1 + expect{subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::Vocab::DC.title, 'Comet in Moominland')}.not_to raise_error + expect(subject.query(:subject => RDF::URI("http://opaquenamespace.org/jokes"), :predicate => RDF::Vocab::DC.title).statements.to_a.length).to eq 1 end end describe '#get_values' do @@ -755,16 +751,16 @@ end it 'should return values for a predicate uri' do - expect(subject.get_values(RDF::DC.title)).to eq ['Comet in Moominland', 'Finn Family Moomintroll'] + expect(subject.get_values(RDF::Vocab::DC.title)).to match_array ['Comet in Moominland', 'Finn Family Moomintroll'] end it 'should return values for a registered predicate symbol' do - expect(subject.get_values(:title)).to eq ['Comet in Moominland', 'Finn Family Moomintroll'] + expect(subject.get_values(:title)).to match_array ['Comet in Moominland', 'Finn Family Moomintroll'] end it "should return values for other subjects if asked" do expect(subject.get_values(RDF::URI("http://opaquenamespace.org/jokes"),:title)).to eq [] - subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::DC.title, 'Comet in Moominland') + subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::Vocab::DC.title, 'Comet in Moominland') expect(subject.get_values(RDF::URI("http://opaquenamespace.org/jokes"),:title)).to eq ["Comet in Moominland"] end end @@ -808,13 +804,13 @@ describe 'editing the graph' do it 'should write properties when statements are added' do - subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, 'Comet in Moominland') + subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, 'Comet in Moominland') expect(subject.title).to include 'Comet in Moominland' end it 'should delete properties when statements are removed' do - subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, 'Comet in Moominland') - subject.delete RDF::Statement.new(subject.rdf_subject, RDF::DC.title, 'Comet in Moominland') + subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, 'Comet in Moominland') + subject.delete RDF::Statement.new(subject.rdf_subject, RDF::Vocab::DC.title, 'Comet in Moominland') expect(subject.title).to eq [] end end @@ -823,18 +819,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::OreRDF::AggregationResource.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument + LD4L::OreRDF::AggregationResource.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument end subject { LD4L::OreRDF::AggregationResource.new } @@ -887,8 +883,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/ore_rdf/models/proxy_resource_spec.rb b/spec/ld4l/ore_rdf/models/proxy_resource_spec.rb index f43a721..7c66066 100644 --- a/spec/ld4l/ore_rdf/models/proxy_resource_spec.rb +++ b/spec/ld4l/ore_rdf/models/proxy_resource_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 RDFVocabularies::ORE.Proxy" do - expect(subject.type.first.value).to eq RDFVocabularies::ORE.Proxy.value + it "should be an RDF::Vocab::ORE.Proxy" do + expect(subject.type.first.value).to eq RDF::Vocab::ORE.Proxy.value end end @@ -555,7 +555,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::OreRDF::ProxyResource.new('123') } @@ -621,29 +621,29 @@ context 'with unmodeled data' do before do - subject << RDF::Statement(subject.rdf_subject, RDF::DC.creator, 'Tove Jansson') - subject << RDF::Statement(subject.rdf_subject, RDF::DC.relation, RDF::URI('http://example.org/moomi')) + subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.creator, 'Tove Jansson') + subject << RDF::Statement(subject.rdf_subject, RDF::Vocab::DC.relation, RDF::URI('http://example.org/moomi')) node = RDF::Node.new - subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::DC.relation, node) - subject << RDF::Statement(node, RDF::DC.title, 'bnode') + subject << RDF::Statement(RDF::URI('http://example.org/moomi'), RDF::Vocab::DC.relation, node) + subject << RDF::Statement(node, RDF::Vocab::DC.title, 'bnode') end it 'should include data with URIs as attribute names' do - expect(subject.attributes[RDF::DC.creator.to_s]).to eq ['Tove Jansson'] + expect(subject.attributes[RDF::Vocab::DC.creator.to_s]).to eq ['Tove Jansson'] end it 'should return generic Resources' do - expect(subject.attributes[RDF::DC.relation.to_s].first).to be_a ActiveTriples::Resource + expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first).to be_a ActiveTriples::Resource end it 'should build deep data for Resources' do - expect(subject.attributes[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation). - first.get_values(RDF::DC.title)).to eq ['bnode'] + expect(subject.attributes[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation). + first.get_values(RDF::Vocab::DC.title)).to eq ['bnode'] end it 'should include deep data in serializable_hash' do - expect(subject.serializable_hash[RDF::DC.relation.to_s].first.get_values(RDF::DC.relation). - first.get_values(RDF::DC.title)).to eq ['bnode'] + expect(subject.serializable_hash[RDF::Vocab::DC.relation.to_s].first.get_values(RDF::Vocab::DC.relation). + first.get_values(RDF::Vocab::DC.title)).to eq ['bnode'] end end @@ -702,13 +702,13 @@ describe 'editing the graph' do it 'should write properties when statements are added' do - subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::ORE.proxyFor, 'Comet in Moominland') + subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::ORE.proxyFor, 'Comet in Moominland') expect(subject.proxy_for).to include 'Comet in Moominland' end it 'should delete properties when statements are removed' do - subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::ORE.proxyFor, 'Comet in Moominland') - subject.delete RDF::Statement.new(subject.rdf_subject, RDFVocabularies::ORE.proxyFor, 'Comet in Moominland') + subject << RDF::Statement.new(subject.rdf_subject, RDF::Vocab::ORE.proxyFor, 'Comet in Moominland') + subject.delete RDF::Statement.new(subject.rdf_subject, RDF::Vocab::ORE.proxyFor, 'Comet in Moominland') expect(subject.proxy_for_).to eq [] end end @@ -717,18 +717,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::OreRDF::ProxyResource.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument + LD4L::OreRDF::ProxyResource.property :item, :predicate => RDF::Vocab::DC.relation, :class_name => DummyDocument end subject { LD4L::OreRDF::ProxyResource.new } @@ -781,8 +781,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/ore_rdf/services/aggregation/add_aggregated_resource_spec.rb b/spec/ld4l/ore_rdf/services/aggregation/add_aggregated_resource_spec.rb index d490b73..e8021ed 100644 --- a/spec/ld4l/ore_rdf/services/aggregation/add_aggregated_resource_spec.rb +++ b/spec/ld4l/ore_rdf/services/aggregation/add_aggregated_resource_spec.rb @@ -22,8 +22,7 @@ it "should add a single resource to an existing set" do subject.aggregates = "http://example.org/individual/b1" LD4L::OreRDF::AddAggregatedResource.call( subject, RDF::URI("http://example.org/individual/b2") ) - expect(subject.aggregates[0]).to eq "http://example.org/individual/b1" - expect(subject.aggregates[1]).to eq "http://example.org/individual/b2" + expect(subject.aggregates).to match_array ["http://example.org/individual/b1","http://example.org/individual/b2"] end it "should generate the resource instance for a single resource" do diff --git a/spec/ld4l/ore_rdf/services/aggregation/find_spec.rb b/spec/ld4l/ore_rdf/services/aggregation/find_spec.rb index 5248d83..41f645b 100644 --- a/spec/ld4l/ore_rdf/services/aggregation/find_spec.rb +++ b/spec/ld4l/ore_rdf/services/aggregation/find_spec.rb @@ -100,7 +100,7 @@ end it "should find aggregation by literal criteria (aka title)" do - aggregations = LD4L::OreRDF::FindAggregations.call(:criteria => { RDF::DC.title => "Aggregation 2"}) + aggregations = LD4L::OreRDF::FindAggregations.call(:criteria => { RDF::Vocab::DC.title => "Aggregation 2"}) expect(aggregations).not_to include "http::/example.org/ag1" expect(aggregations).to include "http::/example.org/ag2" expect(aggregations).not_to include "http::/example.org/ag3" @@ -109,7 +109,7 @@ it "should find aggregation by rdf uri criteria (aka aggregates)" do aggregations = LD4L::OreRDF::FindAggregations.call( - :criteria => { RDFVocabularies::ORE.aggregates => "http://example.org/individual/b32"}) + :criteria => { RDF::Vocab::ORE.aggregates => "http://example.org/individual/b32"}) expect(aggregations).not_to include "http::/example.org/ag1" expect(aggregations).not_to include "http::/example.org/ag2" expect(aggregations).to include "http::/example.org/ag3" @@ -117,7 +117,7 @@ end it "should return empty array when criteria (aka title) doesn't match any aggregations" do - aggregations = LD4L::OreRDF::FindAggregations.call(:criteria => { RDF::DC.title => "NON-EXISTENT TITLE"}) + aggregations = LD4L::OreRDF::FindAggregations.call(:criteria => { RDF::Vocab::DC.title => "NON-EXISTENT TITLE"}) expect(aggregations).to eq [] end @@ -142,15 +142,15 @@ it "should return values for specified literal property in results when criteria specified" do aggregations = LD4L::OreRDF::FindAggregations.call( - :criteria => { RDF::DC.title => "Aggregation 2" }, - :properties => { :description => RDF::DC.description } ) + :criteria => { RDF::Vocab::DC.title => "Aggregation 2" }, + :properties => { :description => RDF::Vocab::DC.description } ) expect(aggregations).to eq ( { RDF::URI("http::/example.org/ag2") => { :description => RDF::Literal("Test description of aggregation 2.") } } ) end it "should return values for specified properties in results when criteria not specified" do aggregations = LD4L::OreRDF::FindAggregations.call( - :properties => { :title => RDF::DC.title, :description => RDF::DC.description } ) + :properties => { :title => RDF::Vocab::DC.title, :description => RDF::Vocab::DC.description } ) expect(aggregations.size).to eq 3 expect(aggregations).to have_key RDF::URI("http::/example.org/ag1") expect(aggregations).to have_key RDF::URI("http::/example.org/ag2") diff --git a/spec/ld4l/ore_rdf/services/proxy/find_spec.rb b/spec/ld4l/ore_rdf/services/proxy/find_spec.rb index 4b48d3c..0873263 100644 --- a/spec/ld4l/ore_rdf/services/proxy/find_spec.rb +++ b/spec/ld4l/ore_rdf/services/proxy/find_spec.rb @@ -108,7 +108,7 @@ it "should find proxies by criteria (aka proxy_for)" do proxies = LD4L::OreRDF::FindProxies.call( :aggregation => 'http::/example.org/ag2', - :criteria => { RDFVocabularies::ORE.proxyFor => "http://example.org/individual/b22" } ) + :criteria => { RDF::Vocab::ORE.proxyFor => "http://example.org/individual/b22" } ) expect(proxies.size).to eq 1 expect(proxies.first).to be_a_kind_of RDF::URI pr = LD4L::OreRDF::ProxyResource.new(proxies.first) diff --git a/spec/ld4l/ore_rdf_spec.rb b/spec/ld4l/ore_rdf_spec.rb index c0b101c..e28f3d1 100644 --- a/spec/ld4l/ore_rdf_spec.rb +++ b/spec/ld4l/ore_rdf_spec.rb @@ -13,7 +13,7 @@ config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid } end class DummyAggregation < LD4L::OreRDF::AggregationResource - configure :type => RDFVocabularies::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default + configure :type => RDF::Vocab::ORE.Aggregation, :base_uri => LD4L::OreRDF.configuration.base_uri, :repository => :default end end after do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6a096bf..1353e70 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,7 +5,7 @@ Bundler.setup require 'ld4l/ore_rdf' -require 'pry' +require 'pry' unless ENV["CI"] Dir['./spec/support/**/*.rb'].each { |f| require f }