From e9b2ee83c31b361eaf5f15237726b0b0cecd99e6 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 18 Nov 2022 09:16:07 +0100 Subject: [PATCH 01/45] add media_types to get media_type as Array --- lib/ontologies_api_client/base.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ontologies_api_client/base.rb b/lib/ontologies_api_client/base.rb index d764d7e..74273f6 100644 --- a/lib/ontologies_api_client/base.rb +++ b/lib/ontologies_api_client/base.rb @@ -6,7 +6,15 @@ class Base attr_accessor :context, :links class << self - attr_accessor :media_type, :act_as_media_type, :include_attrs, :include_attrs_full, :attrs_always_present + attr_accessor :act_as_media_type, :include_attrs, :include_attrs_full, :attrs_always_present + def media_types + Array(@media_type) + end + + def media_type + media_types.first + end + end ## From e12e769cdc0f320844f74244e8848165d6018b07 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 18 Nov 2022 09:16:51 +0100 Subject: [PATCH 02/45] get the map classes using media_types and no more media_type --- lib/ontologies_api_client/base.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ontologies_api_client/base.rb b/lib/ontologies_api_client/base.rb index 74273f6..ff4aba6 100644 --- a/lib/ontologies_api_client/base.rb +++ b/lib/ontologies_api_client/base.rb @@ -39,8 +39,11 @@ def self.map_classes map = {} classes = LinkedData::Client::Models.constants.map {|c| LinkedData::Client::Models.const_get(c)} classes.each do |media_type_cls| - next if map[media_type_cls] || !media_type_cls.respond_to?(:media_type) || !media_type_cls.ancestors.include?(LinkedData::Client::Base) - map[media_type_cls.media_type] = media_type_cls + next if map[media_type_cls] || !media_type_cls.respond_to?(:media_types) || !media_type_cls.ancestors.include?(LinkedData::Client::Base) + media_type_cls.media_types.each do |type| + next if map[type] + map[type] = media_type_cls + end media_type_cls.act_as_media_type.each {|mt| map[mt] = media_type_cls} if media_type_cls.act_as_media_type end return map From c320f447da70a2c5330dfe95c9ffce80f5e85c3a Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 18 Nov 2022 09:18:44 +0100 Subject: [PATCH 03/45] add skos:Concept media type for Class model --- lib/ontologies_api_client/models/class.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ontologies_api_client/models/class.rb b/lib/ontologies_api_client/models/class.rb index e26c9c1..f5b4708 100644 --- a/lib/ontologies_api_client/models/class.rb +++ b/lib/ontologies_api_client/models/class.rb @@ -6,7 +6,7 @@ module Client module Models class Class < LinkedData::Client::Base HTTP = LinkedData::Client::HTTP - @media_type = "http://www.w3.org/2002/07/owl#Class" + @media_type = %w[http://www.w3.org/2002/07/owl#Class http://www.w3.org/2004/02/skos/core#Concept] @include_attrs = "prefLabel,definition,synonym,obsolete,hasChildren" @include_attrs_full = "prefLabel,definition,synonym,obsolete,properties,hasChildren,children" @attrs_always_present = :prefLabel, :definition, :synonym, :obsolete, :properties, :hasChildren, :children From 5851f0fae15d0053105d74fa6e0145450a7f7a34 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 6 Jul 2023 17:21:43 -0700 Subject: [PATCH 04/45] Configure a PURL prefix for test purposes --- config/config.test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.test.rb b/config/config.test.rb index af6837b..cb4b62c 100644 --- a/config/config.test.rb +++ b/config/config.test.rb @@ -9,5 +9,6 @@ config.apikey = ENV['UT_APIKEY'] # config.apikey = 'xxxxx-xxxxx-xxxxxxxxxx' config.links_attr = 'links' + config.purl_prefix = 'https://purl.bioontology.org/ontology' config.cache = false end From d5d32838213715d4b355e3c7244dacd9253a9ba3 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 6 Jul 2023 17:24:34 -0700 Subject: [PATCH 05/45] Fix some RuboCop warnings --- config/config.test.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/config/config.test.rb b/config/config.test.rb index cb4b62c..5e4d75b 100644 --- a/config/config.test.rb +++ b/config/config.test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # config.rb is required for testing # unit test makes calls to bioportal api so it needs a valid API key which can # be set via ENV variable UT_APIKEY @@ -5,10 +7,10 @@ abort('UT_APIKEY env variable is set to an empty value. Canceling tests') unless ENV['UT_APIKEY'].size > 5 LinkedData::Client.config do |config| - config.rest_url = 'https://data.bioontology.org' - config.apikey = ENV['UT_APIKEY'] -# config.apikey = 'xxxxx-xxxxx-xxxxxxxxxx' - config.links_attr = 'links' + config.rest_url = 'https://data.bioontology.org' + config.apikey = ENV['UT_APIKEY'] + # config.apikey = 'xxxxx-xxxxx-xxxxxxxxxx' + config.links_attr = 'links' config.purl_prefix = 'https://purl.bioontology.org/ontology' - config.cache = false + config.cache = false end From e3d96cad81c65e35733c077834e75e4b41752254 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 10 Jul 2023 16:23:16 -0700 Subject: [PATCH 06/45] Add faraday-follow_redirects gem --- Gemfile | 1 + Gemfile.lock | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 1d035b1..e1eb8ea 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source 'https://rubygems.org' gemspec +gem 'faraday-follow_redirects', '~> 0.3' gem 'rake' gem 'rubocop', '~> 1.43' gem 'pry' diff --git a/Gemfile.lock b/Gemfile.lock index 9cf0f9d..1dfabcf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,6 +34,8 @@ GEM faraday-excon (2.1.0) excon (>= 0.27.4) faraday (~> 2.0) + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) faraday-multipart (1.0.4) multipart-post (~> 2) faraday-net_http (3.0.2) @@ -87,6 +89,7 @@ PLATFORMS x86_64-linux DEPENDENCIES + faraday-follow_redirects (~> 0.3) ontologies_api_client! pry rake From 8a1ec9711e32361ac0e41145826b1c413cf42860 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 10 Jul 2023 16:24:43 -0700 Subject: [PATCH 07/45] Fix some RuboCop warnings --- Gemfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index e1eb8ea..6af2b3e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,11 @@ +# frozen_string_literal: true + source 'https://rubygems.org' gemspec gem 'faraday-follow_redirects', '~> 0.3' +gem 'pry' gem 'rake' gem 'rubocop', '~> 1.43' -gem 'pry' -gem 'test-unit' \ No newline at end of file +gem 'test-unit' From 36a3ae8777c436967009138bf980d1c45d405e4f Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 10 Jul 2023 17:03:08 -0700 Subject: [PATCH 08/45] Add unit tests for the purl method --- test/models/test_class.rb | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/test/models/test_class.rb b/test/models/test_class.rb index e5abe44..2a38c15 100644 --- a/test/models/test_class.rb +++ b/test/models/test_class.rb @@ -1,3 +1,6 @@ +# frozen_string_literal: true + +require 'faraday/follow_redirects' require_relative '../test_case' class ClassTest < LinkedData::Client::TestCase @@ -13,4 +16,58 @@ def test_find assert_equal ontology, cls.links['ontology'] assert_true cls.hasChildren end + + # Test PURL generation for a class in an OWL format ontology + def test_purl_owl + cls = LinkedData::Client::Models::Class.find( + 'http://bioontology.org/ontologies/Activity.owl#Activity', + 'https://data.bioontology.org/ontologies/BRO' + ) + refute_nil cls + + res = fetch_response(cls.purl) + assert_equal 200, res.status + assert_equal 'https://bioportal.bioontology.org/ontologies/BRO'\ + '?p=classes&conceptid=http%3A%2F%2Fbioontology.org%2Fontologies%2FActivity.owl%23Activity', + res.env[:url].to_s + end + + # Test PURL generation for a class in a UMLS format ontology + def test_purl_umls + cls = LinkedData::Client::Models::Class.find( + 'http://purl.bioontology.org/ontology/SNOMEDCT/64572001', + 'https://bioportal.bioontology.org/ontologies/SNOMEDCT' + ) + refute_nil cls + + res = fetch_response(cls.purl) + assert_equal 200, res.status + assert_equal 'https://bioportal.bioontology.org/ontologies/SNOMEDCT?p=classes&conceptid=64572001', + res.env[:url].to_s + end + + # Test PURL generation for a class in an OBO format ontology + def test_purl_obo + cls = LinkedData::Client::Models::Class.find( + 'http://purl.obolibrary.org/obo/DOID_4', + 'https://bioportal.bioontology.org/ontologies/DOID' + ) + refute_nil cls + + res = fetch_response(cls.purl) + assert_equal 200, res.status + assert_equal 'https://bioportal.bioontology.org/ontologies/DOID'\ + '?p=classes&conceptid=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FDOID_4', + res.env[:url].to_s + end + + private + + def fetch_response(url) + conn = Faraday.new do |f| + f.response :follow_redirects + f.adapter Faraday.default_adapter + end + conn.get(url) + end end From 68ecfae5a796f3dc21fcbbdbd32f0b3cc8372499 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 10 Jul 2023 17:23:46 -0700 Subject: [PATCH 09/45] Configure a PURL host --- config/config.test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.test.rb b/config/config.test.rb index 5e4d75b..1a9395f 100644 --- a/config/config.test.rb +++ b/config/config.test.rb @@ -11,6 +11,7 @@ config.apikey = ENV['UT_APIKEY'] # config.apikey = 'xxxxx-xxxxx-xxxxxxxxxx' config.links_attr = 'links' + config.purl_host = 'purl.bioontology.org' config.purl_prefix = 'https://purl.bioontology.org/ontology' config.cache = false end From 1ad08c423e9c3e520ec0654cdb95c58898d16511 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 10 Jul 2023 17:27:52 -0700 Subject: [PATCH 10/45] Modify purl method to check class IDs for purl_host Resolves #28 --- lib/ontologies_api_client/models/class.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ontologies_api_client/models/class.rb b/lib/ontologies_api_client/models/class.rb index 20d1b78..7c4984f 100644 --- a/lib/ontologies_api_client/models/class.rb +++ b/lib/ontologies_api_client/models/class.rb @@ -47,7 +47,7 @@ def to_jsonld def purl return "" if self.links.nil? - return self.id if self.id.include?("purl.") + return self.id if self.id.include? LinkedData::Client.settings[:purl_host] ont = self.explore.ontology encoded_id = Addressable::URI.encode_component(self.id, Addressable::URI::CharacterClasses::UNRESERVED) From d1c46e61496081792a0c5fc86e4dd9fc0fe241ce Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 12 Jul 2023 16:53:24 -0700 Subject: [PATCH 11/45] Provide default value for purl_host --- lib/ontologies_api_client/config.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ontologies_api_client/config.rb b/lib/ontologies_api_client/config.rb index 25805a8..0816b09 100644 --- a/lib/ontologies_api_client/config.rb +++ b/lib/ontologies_api_client/config.rb @@ -27,6 +27,7 @@ def config(&block) @settings.cache ||= false @settings.enable_long_request_log ||= false @settings.purl_prefix ||= "http://purl.example.org" + @settings.purl_host ||= 'purl.example.org' # Remove trailing slash @settings.rest_url = @settings.rest_url.chomp("/") From daf3b4c0fbd3f98ae122725fb2c0c66356a07969 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 12 Jul 2023 16:59:49 -0700 Subject: [PATCH 12/45] Fix some RuboCop warnings --- lib/ontologies_api_client/config.rb | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/ontologies_api_client/config.rb b/lib/ontologies_api_client/config.rb index 0816b09..e66d0cb 100644 --- a/lib/ontologies_api_client/config.rb +++ b/lib/ontologies_api_client/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'ostruct' require 'faraday' require 'faraday/excon' @@ -16,28 +18,30 @@ module Client def config(&block) return if @settings_run + @settings_run = true yield @settings if block_given? # Set defaults - @settings.rest_url ||= "http://stagedata.bioontology.org" - @settings.apikey ||= "4ea81d74-8960-4525-810b-fa1baab576ff" - @settings.links_attr ||= "links" + @settings.rest_url ||= 'http://stagedata.bioontology.org' + @settings.apikey ||= '4ea81d74-8960-4525-810b-fa1baab576ff' + @settings.links_attr ||= 'links' @settings.cache ||= false @settings.enable_long_request_log ||= false - @settings.purl_prefix ||= "http://purl.example.org" + @settings.purl_prefix ||= 'http://purl.example.org' @settings.purl_host ||= 'purl.example.org' # Remove trailing slash - @settings.rest_url = @settings.rest_url.chomp("/") - @settings.purl_prefix = @settings.purl_prefix.chomp("/") + @settings.rest_url = @settings.rest_url.chomp('/') + @settings.purl_prefix = @settings.purl_prefix.chomp('/') @settings_run = true end def config_connection(options = {}) return if @settings_run_connection + store = options[:cache_store] @settings.conn = Faraday.new(@settings.rest_url) do |faraday| if @settings.enable_long_request_log @@ -58,10 +62,10 @@ def config_connection(options = {}) begin require_relative 'middleware/faraday-object-cache' faraday.use :object_cache, store: store - puts "=> faraday caching enabled" + puts '=> faraday caching enabled' puts "=> faraday cache store: #{store.class}" rescue LoadError - puts "=> WARNING: faraday http cache gem is not available, caching disabled" + puts '=> WARNING: faraday http cache gem is not available, caching disabled' end end @@ -69,9 +73,9 @@ def config_connection(options = {}) faraday.request :url_encoded faraday.adapter :excon faraday.headers = { - "Accept" => "application/json", - "Authorization" => "apikey token=#{@settings.apikey}", - "User-Agent" => "NCBO API Ruby Client v0.1.0" + 'Accept' => 'application/json', + 'Authorization' => "apikey token=#{@settings.apikey}", + 'User-Agent' => 'NCBO API Ruby Client v0.1.0' } end @settings_run_connection = true @@ -81,4 +85,4 @@ def connection_configured? @settings_run_connection end end -end \ No newline at end of file +end From 207276412ed4ec95af67ab89500c4fd62daf8184 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 13 Jul 2023 10:48:55 -0700 Subject: [PATCH 13/45] Move gem version to a module --- lib/ontologies_api_client/config.rb | 2 +- lib/ontologies_api_client/version.rb | 7 +++++++ ontologies_api_client.gemspec | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 lib/ontologies_api_client/version.rb diff --git a/lib/ontologies_api_client/config.rb b/lib/ontologies_api_client/config.rb index e66d0cb..a08a8ec 100644 --- a/lib/ontologies_api_client/config.rb +++ b/lib/ontologies_api_client/config.rb @@ -75,7 +75,7 @@ def config_connection(options = {}) faraday.headers = { 'Accept' => 'application/json', 'Authorization' => "apikey token=#{@settings.apikey}", - 'User-Agent' => 'NCBO API Ruby Client v0.1.0' + 'User-Agent' => "NCBO API Ruby Client v#{LinkedData::Client::VERSION}" } end @settings_run_connection = true diff --git a/lib/ontologies_api_client/version.rb b/lib/ontologies_api_client/version.rb new file mode 100644 index 0000000..2ad8406 --- /dev/null +++ b/lib/ontologies_api_client/version.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module LinkedData + module Client + VERSION = '2.2.2' + end +end diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 4190b07..a3a7b6d 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative 'lib/ontologies_api_client/version' + Gem::Specification.new do |gem| gem.authors = ['Paul R Alexander'] gem.email = ['support@bioontology.org'] @@ -14,7 +16,7 @@ Gem::Specification.new do |gem| gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.name = 'ontologies_api_client' gem.require_paths = ['lib'] - gem.version = '2.2.2' + gem.version = LinkedData::Client::VERSION gem.add_dependency('activesupport', '6.1.7.3') gem.add_dependency('addressable', '~> 2.8') From 1009cb9893aa007a1fc8578df589b61f7b3eee61 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Fri, 14 Jul 2023 12:38:19 -0700 Subject: [PATCH 14/45] Move faraday-follow_redirects to a dev dependency --- Gemfile | 1 - ontologies_api_client.gemspec | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 6af2b3e..e8b8e0d 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,6 @@ source 'https://rubygems.org' gemspec -gem 'faraday-follow_redirects', '~> 0.3' gem 'pry' gem 'rake' gem 'rubocop', '~> 1.43' diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index a3a7b6d..51d1474 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -28,4 +28,6 @@ Gem::Specification.new do |gem| gem.add_dependency('multi_json') gem.add_dependency('oj') gem.add_dependency('spawnling', '2.1.5') + + gem.add_development_dependency('faraday-follow_redirects', '~> 0.3') end From e0284ab948bf6e19b5db3f3e7d26e2c2023901a2 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Fri, 14 Jul 2023 17:55:57 -0700 Subject: [PATCH 15/45] Add require_relative for version --- lib/ontologies_api_client.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ontologies_api_client.rb b/lib/ontologies_api_client.rb index 739639a..4bd0a86 100644 --- a/lib/ontologies_api_client.rb +++ b/lib/ontologies_api_client.rb @@ -9,6 +9,7 @@ require_relative 'ontologies_api_client/collection' require_relative 'ontologies_api_client/read_write' require_relative 'ontologies_api_client/analytics' +require_relative 'ontologies_api_client/version' # Models curr_dir = File.expand_path("../ontologies_api_client", __FILE__) From 6e72275cfdc00ce8d1ec81b697aa1c4f99330e37 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 18 Jul 2023 16:31:08 -0700 Subject: [PATCH 16/45] Bump version from 2.2.2 to 2.2.3 --- Gemfile.lock | 2 +- lib/ontologies_api_client/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1dfabcf..445248f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ontologies_api_client (2.2.2) + ontologies_api_client (2.2.3) activesupport (= 6.1.7.3) addressable (~> 2.8) excon diff --git a/lib/ontologies_api_client/version.rb b/lib/ontologies_api_client/version.rb index 2ad8406..1c410fd 100644 --- a/lib/ontologies_api_client/version.rb +++ b/lib/ontologies_api_client/version.rb @@ -2,6 +2,6 @@ module LinkedData module Client - VERSION = '2.2.2' + VERSION = '2.2.3' end end From d0d53d17bcb49149cb06b3d8ffb38c1030c1fee9 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 18 Jul 2023 18:08:20 -0700 Subject: [PATCH 17/45] Replace test-unit with minitest --- Gemfile | 1 - Gemfile.lock | 5 +---- ontologies_api_client.gemspec | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index e8b8e0d..cd1e8ba 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,3 @@ gemspec gem 'pry' gem 'rake' gem 'rubocop', '~> 1.43' -gem 'test-unit' diff --git a/Gemfile.lock b/Gemfile.lock index 445248f..a9e17b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,7 +51,6 @@ GEM parallel (1.22.1) parser (3.2.0.0) ast (~> 2.4.1) - power_assert (2.0.3) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -75,8 +74,6 @@ GEM ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) spawnling (2.1.5) - test-unit (3.5.7) - power_assert tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) @@ -90,11 +87,11 @@ PLATFORMS DEPENDENCIES faraday-follow_redirects (~> 0.3) + minitest (~> 5.18) ontologies_api_client! pry rake rubocop (~> 1.43) - test-unit BUNDLED WITH 2.3.22 diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 51d1474..46774fa 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -30,4 +30,5 @@ Gem::Specification.new do |gem| gem.add_dependency('spawnling', '2.1.5') gem.add_development_dependency('faraday-follow_redirects', '~> 0.3') + gem.add_development_dependency('minitest', '~> 5.18') end From 6f51466689eb03fe6f8ca9db8d1a5c15da02cdb1 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 19 Jul 2023 17:29:12 -0700 Subject: [PATCH 18/45] Modify unit test code to use Minitest --- test/models/test_class.rb | 2 +- test/test_case.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/models/test_class.rb b/test/models/test_class.rb index 2a38c15..0229ffe 100644 --- a/test/models/test_class.rb +++ b/test/models/test_class.rb @@ -14,7 +14,7 @@ def test_find assert_equal 'http://www.w3.org/2002/07/owl#Class', cls.type assert_equal 'Activity', cls.prefLabel assert_equal ontology, cls.links['ontology'] - assert_true cls.hasChildren + assert cls.hasChildren end # Test PURL generation for a class in an OWL format ontology diff --git a/test/test_case.rb b/test/test_case.rb index cd9fe2e..3e39475 100644 --- a/test/test_case.rb +++ b/test/test_case.rb @@ -1,10 +1,10 @@ -require 'test-unit' +require 'minitest/autorun' require_relative '../lib/ontologies_api_client' require_relative '../config/config' module LinkedData module Client - class TestCase < Test::Unit::TestCase + class TestCase < Minitest::Test end end end From f8930c88647fb62ab96fb5d3b16af8c2429594a6 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 19 Jul 2023 17:35:07 -0700 Subject: [PATCH 19/45] Fix some RuboCop warnings --- test/models/test_collection.rb | 22 ++++++++++++---------- test/test_case.rb | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/test/models/test_collection.rb b/test/models/test_collection.rb index 1de9f8c..d341913 100644 --- a/test/models/test_collection.rb +++ b/test/models/test_collection.rb @@ -1,12 +1,14 @@ -require_relative '../test_case' +# frozen_string_literal: true + require 'pry' +require_relative '../test_case' class TestOntology < LinkedData::Client::Base include LinkedData::Client::Collection include LinkedData::Client::ReadWrite - @media_type = "http://data.bioontology.org/metadata/Ontology" - @include_attrs = "all" + @media_type = 'http://data.bioontology.org/metadata/Ontology' + @include_attrs = 'all' end class CollectionTest < LinkedData::Client::TestCase @@ -16,30 +18,30 @@ def test_all end def test_class_for_type - media_type = "http://data.bioontology.org/metadata/Category" + media_type = 'http://data.bioontology.org/metadata/Category' type_cls = LinkedData::Client::Base.class_for_type(media_type) assert type_cls == LinkedData::Client::Models::Category end def test_find_by - bro = TestOntology.find_by_acronym("BRO") + bro = TestOntology.find_by_acronym('BRO') assert bro.length >= 1 - assert bro.any? {|o| o.acronym.eql?("BRO")} + assert bro.any? { |o| o.acronym.eql?('BRO') } - onts = TestOntology.find_by_hasDomain_and_doNotUpdate("https://data.bioontology.org/categories/Health", true) + onts = TestOntology.find_by_hasDomain_and_doNotUpdate('https://data.bioontology.org/categories/Health', true) assert onts.length >= 1 - onts = TestOntology.find_by_hasDomain_and_hasDomain("https://data.bioontology.org/categories/Phenotype", "https://data.bioontology.org/categories/Human") + onts = TestOntology.find_by_hasDomain_and_hasDomain('https://data.bioontology.org/categories/Phenotype', 'https://data.bioontology.org/categories/Human') assert onts.length >= 1 end def test_where - onts = TestOntology.where {|o| o.name.downcase.start_with?("c")} + onts = TestOntology.where { |o| o.name.downcase.start_with?('c') } assert onts.length >= 1 end def test_find - ont = TestOntology.find("https://data.bioontology.org/ontologies/SNOMEDCT") + ont = TestOntology.find('https://data.bioontology.org/ontologies/SNOMEDCT') assert !ont.nil? end end diff --git a/test/test_case.rb b/test/test_case.rb index 3e39475..5b14532 100644 --- a/test/test_case.rb +++ b/test/test_case.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'minitest/autorun' require_relative '../lib/ontologies_api_client' require_relative '../config/config' From dac52e9fc4a6dba26f8311529bb7bfa2e8bd51fa Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 19 Jul 2023 17:51:33 -0700 Subject: [PATCH 20/45] Use more appropriate assertions --- test/models/test_collection.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/models/test_collection.rb b/test/models/test_collection.rb index d341913..03c5993 100644 --- a/test/models/test_collection.rb +++ b/test/models/test_collection.rb @@ -20,13 +20,13 @@ def test_all def test_class_for_type media_type = 'http://data.bioontology.org/metadata/Category' type_cls = LinkedData::Client::Base.class_for_type(media_type) - assert type_cls == LinkedData::Client::Models::Category + assert_equal LinkedData::Client::Models::Category, type_cls end def test_find_by bro = TestOntology.find_by_acronym('BRO') assert bro.length >= 1 - assert bro.any? { |o| o.acronym.eql?('BRO') } + assert(bro.any? { |o| o.acronym.eql?('BRO') }) onts = TestOntology.find_by_hasDomain_and_doNotUpdate('https://data.bioontology.org/categories/Health', true) assert onts.length >= 1 @@ -42,6 +42,6 @@ def test_where def test_find ont = TestOntology.find('https://data.bioontology.org/ontologies/SNOMEDCT') - assert !ont.nil? + refute_nil ont end end From 7331b8372056ea0cf2a33cc0f86fcf6877712bef Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 20 Jul 2023 14:01:43 -0700 Subject: [PATCH 21/45] Bump version from 2.2.3 to 2.2.4 --- Gemfile.lock | 2 +- lib/ontologies_api_client/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a9e17b9..1e0dfe4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ontologies_api_client (2.2.3) + ontologies_api_client (2.2.4) activesupport (= 6.1.7.3) addressable (~> 2.8) excon diff --git a/lib/ontologies_api_client/version.rb b/lib/ontologies_api_client/version.rb index 1c410fd..4c82465 100644 --- a/lib/ontologies_api_client/version.rb +++ b/lib/ontologies_api_client/version.rb @@ -2,6 +2,6 @@ module LinkedData module Client - VERSION = '2.2.3' + VERSION = '2.2.4' end end From 05bd4d1fc84070d75629c3013f0d7d0c0ea468ec Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 18 Dec 2023 14:59:53 -0800 Subject: [PATCH 22/45] Bump activesupport from 6.1.7.3 to 7.0.8 --- Gemfile.lock | 48 +++++++++++++++++++---------------- ontologies_api_client.gemspec | 2 +- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1e0dfe4..b0752f8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: ontologies_api_client (2.2.4) - activesupport (= 6.1.7.3) + activesupport (= 7.0.8) addressable (~> 2.8) excon faraday @@ -16,19 +16,20 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.1.7.3) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.4) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) + base64 (0.2.0) coderay (1.1.3) concurrent-ruby (1.2.2) - excon (0.100.0) - faraday (2.7.6) + excon (0.105.0) + faraday (2.7.12) + base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) faraday-excon (2.1.0) @@ -42,42 +43,45 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) json (2.6.3) + language_server-protocol (3.17.0.3) lz4-ruby (0.3.3) method_source (1.0.0) - minitest (5.18.1) + minitest (5.20.0) multi_json (1.15.0) multipart-post (2.3.0) - oj (3.15.0) - parallel (1.22.1) - parser (3.2.0.0) + oj (3.16.1) + parallel (1.23.0) + parser (3.2.2.4) ast (~> 2.4.1) + racc pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (5.0.1) + public_suffix (5.0.4) + racc (1.7.3) rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.6.2) - rexml (3.2.5) - rubocop (1.44.1) + rake (13.1.0) + regexp_parser (2.8.2) + rexml (3.2.6) + rubocop (1.57.2) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + parser (>= 3.2.2.4) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.24.1, < 2.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.24.1) - parser (>= 3.1.1.0) - ruby-progressbar (1.11.0) + rubocop-ast (1.30.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) spawnling (2.1.5) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.4.2) - zeitwerk (2.6.8) + unicode-display_width (2.5.0) PLATFORMS ruby diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 46774fa..2320257 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |gem| gem.require_paths = ['lib'] gem.version = LinkedData::Client::VERSION - gem.add_dependency('activesupport', '6.1.7.3') + gem.add_dependency('activesupport', '7.0.8') gem.add_dependency('addressable', '~> 2.8') gem.add_dependency('excon') gem.add_dependency('faraday') From 18cdbe49669d48fbe8155034587a14c789289445 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 8 Jan 2024 10:36:25 -0800 Subject: [PATCH 23/45] Remove Ruby 2.7 and add 3.1 to test matrix --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index e28dcd0..3609178 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['2.7', '3.0'] + ruby-version: ['3.0', '3.1'] steps: - uses: actions/checkout@v3 - name: Set up Ruby From 57eca1e41f1c3e7fa46d112ad61bd889aa38b598 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 8 Jan 2024 10:55:34 -0800 Subject: [PATCH 24/45] Run unit tests in verbose mode --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 3609178..569b9bd 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -34,4 +34,4 @@ jobs: - name: Run tests env: UT_APIKEY: ${{ secrets.UT_APIKEY }} - run: bundle exec rake test + run: bundle exec rake test TESTOPTS="-v" From c45c8a86bed2029698bf872748b6e6e2a35c2bd8 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 8 Jan 2024 11:49:50 -0800 Subject: [PATCH 25/45] Bump minitest from 5.18. to 5.20 --- Gemfile.lock | 2 +- ontologies_api_client.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b0752f8..9af604e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,7 +91,7 @@ PLATFORMS DEPENDENCIES faraday-follow_redirects (~> 0.3) - minitest (~> 5.18) + minitest (~> 5.20) ontologies_api_client! pry rake diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 2320257..ace9568 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -30,5 +30,5 @@ Gem::Specification.new do |gem| gem.add_dependency('spawnling', '2.1.5') gem.add_development_dependency('faraday-follow_redirects', '~> 0.3') - gem.add_development_dependency('minitest', '~> 5.18') + gem.add_development_dependency('minitest', '~> 5.20') end From 4dd08e06752da2933196de22495ac99ea7eb19ed Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 10 Jan 2024 14:55:21 -0800 Subject: [PATCH 26/45] Add minitest-hooks as dev dependency --- Gemfile.lock | 3 +++ ontologies_api_client.gemspec | 1 + 2 files changed, 4 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 9af604e..eb65e3b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -47,6 +47,8 @@ GEM lz4-ruby (0.3.3) method_source (1.0.0) minitest (5.20.0) + minitest-hooks (1.5.1) + minitest (> 5.3) multi_json (1.15.0) multipart-post (2.3.0) oj (3.16.1) @@ -92,6 +94,7 @@ PLATFORMS DEPENDENCIES faraday-follow_redirects (~> 0.3) minitest (~> 5.20) + minitest-hooks (~> 1.5) ontologies_api_client! pry rake diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index ace9568..870978e 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -31,4 +31,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency('faraday-follow_redirects', '~> 0.3') gem.add_development_dependency('minitest', '~> 5.20') + gem.add_development_dependency('minitest-hooks', '~> 1.5') end From 53f330a76dfacd99c88d5be3a122f5f3394b872d Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 10 Jan 2024 14:56:18 -0800 Subject: [PATCH 27/45] Validate API key in before_all --- test/test_case.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_case.rb b/test/test_case.rb index 5b14532..3e5a855 100644 --- a/test/test_case.rb +++ b/test/test_case.rb @@ -1,12 +1,23 @@ # frozen_string_literal: true require 'minitest/autorun' +require 'minitest/hooks/test' require_relative '../lib/ontologies_api_client' require_relative '../config/config' module LinkedData module Client class TestCase < Minitest::Test + include Minitest::Hooks + + def before_all + super + params = { q: 'Conceptual Entity', ontologies: 'STY', require_exact_match: 'true', display_links: 'false' } + response = LinkedData::Client::HTTP.get('/search', params) + if response.respond_to?('status') && response.status.eql?(401) + abort('ABORTED! You must provide a valid API key.') + end + end end end end From 69657d24318472a21edfd2864154d40fdd5cdb30 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 10 Jan 2024 16:45:27 -0800 Subject: [PATCH 28/45] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c8ce8d..fd47065 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ For questions please email [support@bioontology.org](support@bioontology.org.) ## License -Copyright (c) 2021, The Board of Trustees of Leland Stanford Junior University All rights reserved. +Copyright (c) 2024, The Board of Trustees of Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: From 58bf6c77727e360c73057a65ba24b859ebfaad9f Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 16 Jan 2024 11:36:18 -0800 Subject: [PATCH 29/45] Update README.md --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fd47065..9bc1f70 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # ontologies_api_client -Models and serializers for ontologies and related artifacts backed by a [4store](https://github.com/4store/4store) -RDF database. This library can be used for interacting with a 4store instance that stores -[BioPortal](https://bioportal.bioontology.org/) ontology data. Models in the library are based on -[Graph Oriented Objects for Ruby (Goo)](https://github.com/ncbo/goo). Serializers support RDF serialization as -Rack Middleware and automatic generation of hypermedia links. +Models and serializers for ontologies and related artifacts backed by an +[AllegroGraph](https://allegrograph.com/products/allegrograph/) or a [4store](https://github.com/4store/4store) +database. This library can be used for interacting with an AllegroGraph or a 4store instance that +stores [BioPortal](https://bioportal.bioontology.org/) ontology data. Models in the library are based on +[Graph Oriented Objects for Ruby (Goo)](https://github.com/ncbo/goo). Serializers support RDF serialization as Rack Middleware and automatic +generation of hypermedia links. ## Install From fc78bfca587ab8455520c862fb77231e7bd16671 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 16 Jan 2024 11:48:35 -0800 Subject: [PATCH 30/45] Update description to include AllegroGraph --- ontologies_api_client.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 870978e..9c4411b 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -5,10 +5,10 @@ require_relative 'lib/ontologies_api_client/version' Gem::Specification.new do |gem| gem.authors = ['Paul R Alexander'] gem.email = ['support@bioontology.org'] - gem.description = 'Models and serializers for ontologies and related artifacts backed by 4store' - gem.summary = 'This library can be used for interacting with a 4store instance that stores NCBO-based ' \ - 'ontology information. Models in the library are based on Goo. Serializers support RDF ' \ - 'serialization as Rack Middleware and automatic generation of hypermedia links.' + gem.description = 'Models and serializers for ontologies and related artifacts backed by an RDF database' + gem.summary = 'This library can be used for interacting with an AllegroGraph or 4store instance that stores ' \ + 'BioPortal-based ontology information. Models in the library are based on Goo. Serializers ' \ + 'support RDF serialization as Rack Middleware and automatic generation of hypermedia links.' gem.homepage = 'https://github.com/ncbo/ontologies_api_ruby_client' gem.files = `git ls-files`.split($\) From 115cf36f54f73eb10c503147f54bb6f6672d3d99 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 16 Jan 2024 11:49:51 -0800 Subject: [PATCH 31/45] Bump version from 2.2.4 to 2.2.5 --- Gemfile.lock | 10 ++++++---- lib/ontologies_api_client/version.rb | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index eb65e3b..a8b0b7c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ontologies_api_client (2.2.4) + ontologies_api_client (2.2.5) activesupport (= 7.0.8) addressable (~> 2.8) excon @@ -21,13 +21,14 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.5) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) base64 (0.2.0) + bigdecimal (3.1.5) coderay (1.1.3) concurrent-ruby (1.2.2) - excon (0.105.0) + excon (0.109.0) faraday (2.7.12) base64 faraday-net_http (>= 2.0, < 3.1) @@ -51,7 +52,8 @@ GEM minitest (> 5.3) multi_json (1.15.0) multipart-post (2.3.0) - oj (3.16.1) + oj (3.16.3) + bigdecimal (>= 3.0) parallel (1.23.0) parser (3.2.2.4) ast (~> 2.4.1) diff --git a/lib/ontologies_api_client/version.rb b/lib/ontologies_api_client/version.rb index 4c82465..3cd94ff 100644 --- a/lib/ontologies_api_client/version.rb +++ b/lib/ontologies_api_client/version.rb @@ -2,6 +2,6 @@ module LinkedData module Client - VERSION = '2.2.4' + VERSION = '2.2.5' end end From 33d3aba0066252e3295d84c272781949228e549e Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Mon, 22 Jul 2024 12:27:30 -0700 Subject: [PATCH 32/45] Bump version from 2.2.5 to 2.3.0 --- lib/ontologies_api_client/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ontologies_api_client/version.rb b/lib/ontologies_api_client/version.rb index 3cd94ff..c17f0c9 100644 --- a/lib/ontologies_api_client/version.rb +++ b/lib/ontologies_api_client/version.rb @@ -2,6 +2,6 @@ module LinkedData module Client - VERSION = '2.2.5' + VERSION = '2.3.0' end end From 927bbe2880fe38b72b90c2e55475a91d167f1e42 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Mon, 22 Jul 2024 12:35:03 -0700 Subject: [PATCH 33/45] Gemfile.lock update --- Gemfile.lock | 70 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a8b0b7c..74fb749 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ontologies_api_client (2.2.5) + ontologies_api_client (2.3.0) activesupport (= 7.0.8) addressable (~> 2.8) excon @@ -21,18 +21,16 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) - base64 (0.2.0) - bigdecimal (3.1.5) + bigdecimal (3.1.8) coderay (1.1.3) - concurrent-ruby (1.2.2) - excon (0.109.0) - faraday (2.7.12) - base64 - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) + concurrent-ruby (1.3.3) + excon (0.111.0) + faraday (2.10.0) + faraday-net_http (>= 2.0, < 3.2) + logger faraday-excon (2.1.0) excon (>= 0.27.4) faraday (~> 2.0) @@ -40,52 +38,58 @@ GEM faraday (>= 1, < 3) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (3.0.2) - i18n (1.14.1) + faraday-net_http (3.1.0) + net-http + i18n (1.14.5) concurrent-ruby (~> 1.0) - json (2.6.3) + json (2.7.2) language_server-protocol (3.17.0.3) + logger (1.6.0) lz4-ruby (0.3.3) - method_source (1.0.0) - minitest (5.20.0) + method_source (1.1.0) + minitest (5.24.1) minitest-hooks (1.5.1) minitest (> 5.3) multi_json (1.15.0) - multipart-post (2.3.0) - oj (3.16.3) + multipart-post (2.4.1) + net-http (0.4.1) + uri + oj (3.16.4) bigdecimal (>= 3.0) - parallel (1.23.0) - parser (3.2.2.4) + parallel (1.25.1) + parser (3.3.4.0) ast (~> 2.4.1) racc pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (5.0.4) - racc (1.7.3) + public_suffix (6.0.0) + racc (1.8.0) rainbow (3.1.1) - rake (13.1.0) - regexp_parser (2.8.2) - rexml (3.2.6) - rubocop (1.57.2) + rake (13.2.1) + regexp_parser (2.9.2) + rexml (3.3.2) + strscan + rubocop (1.65.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.4) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) + regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) spawnling (2.1.5) + strscan (3.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uri (0.13.0) PLATFORMS ruby @@ -103,4 +107,4 @@ DEPENDENCIES rubocop (~> 1.43) BUNDLED WITH - 2.3.22 + 2.4.18 From 1f9d8ce76775cf9e3fc276c44207c2fcc2011498 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 14 Aug 2024 12:05:15 -0700 Subject: [PATCH 34/45] Add collection paths to IDs if not provided --- lib/ontologies_api_client/collection.rb | 2 ++ test/models/test_collection.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/ontologies_api_client/collection.rb b/lib/ontologies_api_client/collection.rb index 97ccc0f..580cdb7 100644 --- a/lib/ontologies_api_client/collection.rb +++ b/lib/ontologies_api_client/collection.rb @@ -85,6 +85,8 @@ def find(id, params = {}) ## # Get a resource by id (this will retrieve it from the REST service) def get(id, params = {}) + path = collection_path + id = "#{path}/#{id}" unless id.include?(path) HTTP.get(id, params) end diff --git a/test/models/test_collection.rb b/test/models/test_collection.rb index 03c5993..d97cd79 100644 --- a/test/models/test_collection.rb +++ b/test/models/test_collection.rb @@ -44,4 +44,18 @@ def test_find ont = TestOntology.find('https://data.bioontology.org/ontologies/SNOMEDCT') refute_nil ont end + + def test_get + ont = TestOntology.get('https://data.bioontology.org/ontologies/SNOMEDCT') + refute_nil ont + assert_instance_of LinkedData::Client::Models::Ontology, ont + assert_equal 'https://data.bioontology.org/ontologies/SNOMEDCT', ont.id + assert_equal 'SNOMEDCT', ont.acronym + + ont = TestOntology.get('SNOMEDCT') + refute_nil ont + assert_instance_of LinkedData::Client::Models::Ontology, ont + assert_equal 'https://data.bioontology.org/ontologies/SNOMEDCT', ont.id + assert_equal 'SNOMEDCT', ont.acronym + end end From 4a8fcdcf5010434cef316718bb86aac3bacdfbca Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 14 Aug 2024 12:10:03 -0700 Subject: [PATCH 35/45] Cache the result of top_level_links --- lib/ontologies_api_client/collection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ontologies_api_client/collection.rb b/lib/ontologies_api_client/collection.rb index 580cdb7..6f35c21 100644 --- a/lib/ontologies_api_client/collection.rb +++ b/lib/ontologies_api_client/collection.rb @@ -25,7 +25,7 @@ def method_missing(meth, *args, &block) ## # Get all top-level links for the API def top_level_links - HTTP.get(LinkedData::Client.settings.rest_url) + @top_level_links ||= HTTP.get(LinkedData::Client.settings.rest_url) end ## From e6e30ed5edceae78f5051e5862766664fe5fa890 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 14 Aug 2024 13:56:54 -0700 Subject: [PATCH 36/45] Deprecate collection's find method in favor of get --- lib/ontologies_api_client/collection.rb | 8 ++--- lib/ontologies_api_client/models/ontology.rb | 6 +++- test/models/test_ontology.rb | 31 ++++++++++++++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 test/models/test_ontology.rb diff --git a/lib/ontologies_api_client/collection.rb b/lib/ontologies_api_client/collection.rb index 6f35c21..f0bb0f2 100644 --- a/lib/ontologies_api_client/collection.rb +++ b/lib/ontologies_api_client/collection.rb @@ -73,13 +73,11 @@ def where(params = {}, &block) end end - ## # Find a resource by id + # + # @deprecated Use {#get} instead def find(id, params = {}) - found = where do |obj| - obj.id.eql?(id) - end - found.first + get(id, params) end ## diff --git a/lib/ontologies_api_client/models/ontology.rb b/lib/ontologies_api_client/models/ontology.rb index 5db6ed4..3846b69 100644 --- a/lib/ontologies_api_client/models/ontology.rb +++ b/lib/ontologies_api_client/models/ontology.rb @@ -108,11 +108,15 @@ def self.find_by(attrs, *args) # Override to search for views as well by default # Views get hidden on the REST service unless the `include_views` # parameter is set to `true` - def find(id, params = {}) + def self.find(id, params = {}) params[:include_views] = params[:include_views] || true super(id, params) end + def self.find_by_acronym(acronym, params = {}) + [find(acronym, params)] + end + ## # Include parameters commonly used with ontologies def self.include_params diff --git a/test/models/test_ontology.rb b/test/models/test_ontology.rb new file mode 100644 index 0000000..c865d41 --- /dev/null +++ b/test/models/test_ontology.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require_relative '../test_case' + +class OntologyTest < LinkedData::Client::TestCase + def test_find_by_acronym + result = LinkedData::Client::Models::Ontology.find_by_acronym('SNOMEDCT') + refute_empty result + assert_instance_of Array, result + assert_equal 1, result.length + + ont = result.first + assert_instance_of LinkedData::Client::Models::Ontology, ont + assert_equal 'https://data.bioontology.org/ontologies/SNOMEDCT', ont.id + assert_equal 'SNOMEDCT', ont.acronym + end + + def test_find + ont = LinkedData::Client::Models::Ontology.find('SNOMEDCT') + refute_nil ont + assert_instance_of LinkedData::Client::Models::Ontology, ont + assert_equal 'https://data.bioontology.org/ontologies/SNOMEDCT', ont.id + assert_equal 'SNOMEDCT', ont.acronym + + ont = LinkedData::Client::Models::Ontology.find('BiositemapIM') + refute_nil ont + assert_instance_of LinkedData::Client::Models::Ontology, ont + assert_equal 'https://data.bioontology.org/ontologies/BiositemapIM', ont.id + assert_equal 'BiositemapIM', ont.acronym + end +end From e2c86ecf790d1436e6cd5e5bc176406517229426 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 14 Aug 2024 18:32:19 -0700 Subject: [PATCH 37/45] Replace $DEBUG with $DEBUG_API_CLIENT --- lib/ontologies_api_client/http.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ontologies_api_client/http.rb b/lib/ontologies_api_client/http.rb index 8b736eb..ecb809c 100644 --- a/lib/ontologies_api_client/http.rb +++ b/lib/ontologies_api_client/http.rb @@ -61,7 +61,7 @@ def self.get(path, params = {}, options = {}) invalidate_cache = params.delete(:invalidate_cache) || false begin - puts "Getting: #{path} with #{params}" if $DEBUG + puts "Getting: #{path} with #{params}" if $DEBUG_API_CLIENT begin response = conn.get do |req| req.url path @@ -87,7 +87,7 @@ def self.get(path, params = {}, options = {}) obj = recursive_struct(load_json(response.body)) end rescue StandardError => e - puts "Problem getting #{path}" if $DEBUG + puts "Problem getting #{path}" if $DEBUG_API_CLIENT raise e end obj @@ -143,7 +143,7 @@ def self.patch(path, obj) end def self.delete(id) - puts "Deleting #{id}" if $DEBUG + puts "Deleting #{id}" if $DEBUG_API_CLIENT response = conn.delete id raise StandardError, response.body if response.status >= 500 From 938613e2de6507b1bdbf47779d6827dc2d36adf6 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Fri, 16 Aug 2024 17:38:48 -0700 Subject: [PATCH 38/45] Dial back on cache refreshes --- lib/ontologies_api_client/read_write.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ontologies_api_client/read_write.rb b/lib/ontologies_api_client/read_write.rb index 721c669..c74ad02 100644 --- a/lib/ontologies_api_client/read_write.rb +++ b/lib/ontologies_api_client/read_write.rb @@ -90,7 +90,6 @@ def invalidate_cache(cache_refresh_all = true) HTTP.get(self.id, invalidate_cache: true) if self.id session = Thread.current[:session] session[:last_updated] = Time.now.to_f if session - refresh_cache end def refresh_cache From c5cfd9f49993d5f9210e8b82fbed54188ce60c6c Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Fri, 16 Aug 2024 17:39:36 -0700 Subject: [PATCH 39/45] Fix uninitialized global variable warning --- lib/ontologies_api_client/http.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ontologies_api_client/http.rb b/lib/ontologies_api_client/http.rb index ecb809c..b0a4355 100644 --- a/lib/ontologies_api_client/http.rb +++ b/lib/ontologies_api_client/http.rb @@ -38,6 +38,8 @@ def values_at(*selectors) module LinkedData module Client module HTTP + $DEBUG_API_CLIENT ||= false + class Link < String attr_accessor :media_type; end From 5bdb77b40f451cb7356815e03067e1c367829db6 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Fri, 16 Aug 2024 17:49:45 -0700 Subject: [PATCH 40/45] Bump minitest to from 5.24.1 to 5.25.1 --- Gemfile.lock | 4 ++-- ontologies_api_client.gemspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 74fb749..a1949d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -47,7 +47,7 @@ GEM logger (1.6.0) lz4-ruby (0.3.3) method_source (1.1.0) - minitest (5.24.1) + minitest (5.25.1) minitest-hooks (1.5.1) minitest (> 5.3) multi_json (1.15.0) @@ -99,7 +99,7 @@ PLATFORMS DEPENDENCIES faraday-follow_redirects (~> 0.3) - minitest (~> 5.20) + minitest (~> 5.25) minitest-hooks (~> 1.5) ontologies_api_client! pry diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 9c4411b..6caa2a5 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -30,6 +30,6 @@ Gem::Specification.new do |gem| gem.add_dependency('spawnling', '2.1.5') gem.add_development_dependency('faraday-follow_redirects', '~> 0.3') - gem.add_development_dependency('minitest', '~> 5.20') + gem.add_development_dependency('minitest', '~> 5.25') gem.add_development_dependency('minitest-hooks', '~> 1.5') end From 55fdbf09d8c19745db4cccf09a5264b75565f5d8 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Mon, 19 Aug 2024 11:12:07 -0700 Subject: [PATCH 41/45] Fix some RuboCop warnings --- lib/ontologies_api_client/models/ontology.rb | 31 ++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/ontologies_api_client/models/ontology.rb b/lib/ontologies_api_client/models/ontology.rb index 3846b69..eeb2949 100644 --- a/lib/ontologies_api_client/models/ontology.rb +++ b/lib/ontologies_api_client/models/ontology.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'cgi' -require_relative "../base" +require_relative '../base' module LinkedData module Client @@ -8,19 +10,19 @@ class Ontology < LinkedData::Client::Base include LinkedData::Client::Collection include LinkedData::Client::ReadWrite - @media_type = "http://data.bioontology.org/metadata/Ontology" - @include_attrs = "all" + @media_type = 'http://data.bioontology.org/metadata/Ontology' + @include_attrs = 'all' def flat? self.flat end def private? - viewingRestriction && viewingRestriction.downcase.eql?("private") + viewingRestriction && viewingRestriction.downcase.eql?('private') end def licensed? - viewingRestriction && viewingRestriction.downcase.eql?("licensed") + viewingRestriction && viewingRestriction.downcase.eql?('licensed') end def viewing_restricted? @@ -35,7 +37,7 @@ def purl if self.acronym "#{LinkedData::Client.settings.purl_prefix}/#{acronym}" else - "" + '' end end @@ -43,13 +45,13 @@ def access?(user) return true if !viewing_restricted? return false if user.nil? return true if user.admin? - return self.full_acl.any? {|u| u == user.id} + return self.full_acl.any? { |u| u == user.id } end def admin?(user) return false if user.nil? return true if user.admin? - return administeredBy.any? {|u| u == user.id} + return administeredBy.any? { |u| u == user.id } end def invalidate_cache(cache_refresh_all = true) @@ -75,12 +77,12 @@ def acl_select # Method to get the property tree for a given ontology # Gets the properties from the REST API and then returns a tree def property_tree - properties = Hash[self.explore.properties.map {|p| [p.id, p]}] - properties.keys.each do |key| + properties = Hash[self.explore.properties.map { |p| [p.id, p] }] + properties.each_key do |key| prop = properties[key] - prop.parents.each {|par| properties[par].children << prop if properties[par]} + prop.parents.each { |par| properties[par].children << prop if properties[par] } end - roots = properties.values.select {|p| p.parents.empty?} + roots = properties.values.select { |p| p.parents.empty? } root = LinkedData::Client::Models::Property.new root.children = roots root @@ -97,7 +99,7 @@ def self.find_by(attrs, *args) params[:include_views] = params[:include_views] || true else # Stick params back and create a new one - args.push({include_views: true}) + args.push({ include_views: true }) end args.unshift(params) super(attrs, *args) @@ -120,9 +122,8 @@ def self.find_by_acronym(acronym, params = {}) ## # Include parameters commonly used with ontologies def self.include_params - "acronym,administeredBy,group,hasDomain,name,notes,projects,reviews,summaryOnly,viewingRestriction" + 'acronym,administeredBy,group,hasDomain,name,notes,projects,reviews,summaryOnly,viewingRestriction' end - end end end From 9abc05449f9120f9d68f866139a00441a6bd451d Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 20 Aug 2024 13:21:57 -0700 Subject: [PATCH 42/45] Remove invalidate_cache override from ontology --- lib/ontologies_api_client/models/ontology.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/ontologies_api_client/models/ontology.rb b/lib/ontologies_api_client/models/ontology.rb index eeb2949..f595ae2 100644 --- a/lib/ontologies_api_client/models/ontology.rb +++ b/lib/ontologies_api_client/models/ontology.rb @@ -54,11 +54,6 @@ def admin?(user) return administeredBy.any? { |u| u == user.id } end - def invalidate_cache(cache_refresh_all = true) - self.class.all(invalidate_cache: true, include_views: true) - super(cache_refresh_all) - end - # ACL with administrators def full_acl ((self.acl || []) + self.administeredBy).uniq From 67cdaefc1d47da7d106df4cbc86e6ad1c857af2e Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 21 Aug 2024 12:08:00 -0700 Subject: [PATCH 43/45] Remove unused refresh_cache method --- lib/ontologies_api_client/read_write.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/ontologies_api_client/read_write.rb b/lib/ontologies_api_client/read_write.rb index c74ad02..97157fa 100644 --- a/lib/ontologies_api_client/read_write.rb +++ b/lib/ontologies_api_client/read_write.rb @@ -91,16 +91,6 @@ def invalidate_cache(cache_refresh_all = true) session = Thread.current[:session] session[:last_updated] = Time.now.to_f if session end - - def refresh_cache - Spawnling.new do - LinkedData::Client::Models::Ontology.all - LinkedData::Client::Models::OntologySubmission.all - LinkedData::Client::Models::User.all - exit - end - end - end end end From b07de0ae7d99a344d9f44baac12605725d890ea7 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 21 Aug 2024 13:53:36 -0700 Subject: [PATCH 44/45] Remove spawnling dependency --- Gemfile.lock | 2 -- lib/ontologies_api_client.rb | 1 - ontologies_api_client.gemspec | 1 - 3 files changed, 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a1949d6..11ff7da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,6 @@ PATH lz4-ruby multi_json oj - spawnling (= 2.1.5) GEM remote: https://rubygems.org/ @@ -84,7 +83,6 @@ GEM rubocop-ast (1.31.3) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) - spawnling (2.1.5) strscan (3.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) diff --git a/lib/ontologies_api_client.rb b/lib/ontologies_api_client.rb index 4bd0a86..a08dbb1 100644 --- a/lib/ontologies_api_client.rb +++ b/lib/ontologies_api_client.rb @@ -1,6 +1,5 @@ require 'oj' require 'multi_json' -require 'spawnling' require_relative 'ontologies_api_client/config' require_relative 'ontologies_api_client/http' diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 6caa2a5..8e2ec66 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -27,7 +27,6 @@ Gem::Specification.new do |gem| gem.add_dependency('lz4-ruby') gem.add_dependency('multi_json') gem.add_dependency('oj') - gem.add_dependency('spawnling', '2.1.5') gem.add_development_dependency('faraday-follow_redirects', '~> 0.3') gem.add_development_dependency('minitest', '~> 5.25') From 11861cfb2ec7a8c5aa12c386d4692c0586a78213 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 21 Aug 2024 13:58:42 -0700 Subject: [PATCH 45/45] Bump version from 2.3.0 to 2.4.0 --- Gemfile.lock | 2 +- lib/ontologies_api_client/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 11ff7da..4cb70a6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ontologies_api_client (2.3.0) + ontologies_api_client (2.4.0) activesupport (= 7.0.8) addressable (~> 2.8) excon diff --git a/lib/ontologies_api_client/version.rb b/lib/ontologies_api_client/version.rb index c17f0c9..ef2e69e 100644 --- a/lib/ontologies_api_client/version.rb +++ b/lib/ontologies_api_client/version.rb @@ -2,6 +2,6 @@ module LinkedData module Client - VERSION = '2.3.0' + VERSION = '2.4.0' end end