From 101c2bb8080ade06d12a724abfbb6f310aea223e Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Sun, 22 May 2022 21:05:54 +0200 Subject: [PATCH 01/23] inverse the invalidate_cache all condition and extract it in a function --- lib/ontologies_api_client/read_write.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/ontologies_api_client/read_write.rb b/lib/ontologies_api_client/read_write.rb index ff2461e..721c669 100644 --- a/lib/ontologies_api_client/read_write.rb +++ b/lib/ontologies_api_client/read_write.rb @@ -7,8 +7,7 @@ module ReadWrite def save(options = {}) resp = HTTP.post(self.class.collection_path, self.to_hash) - # cache_refresh_all allow to avoid to refresh everything, to make it faster when saving new submission - invalidate_cache(options[:cache_refresh_all] == false) + cache_refresh(options) resp end @@ -16,9 +15,7 @@ def update(options = {}) values = options[:values] || changed_values() return if values.empty? resp = HTTP.patch(self.id, values) - # When updating submission we avoid refreshing all cache to avoid calling /submissions?display=all that takes a lot of time - invalidate_cache(options[:cache_refresh_all] == false) - + cache_refresh(options) resp end @@ -39,7 +36,7 @@ def update_from_params(params) end def changed_values - existing = HTTP.get(self.id, include: "all") + existing = HTTP.get(self.id, include: 'all') changed_attrs = {} self.instance_variables.each do |var| var_sym = var[1..-1].to_sym @@ -53,12 +50,17 @@ def changed_values def delete resp = HTTP.delete(self.id) - invalidate_cache() + cache_refresh resp end private + def cache_refresh(options = {}) + # cache_refresh_all allow to avoid to refresh everything, to make it faster when saving/updating a submission + invalidate_cache(options[:cache_refresh_all] || options[:cache_refresh_all].nil?) + end + def equivalent?(current_value, new_value) # If we're comparing an existing embedded object # then use the id for comparison From e6d6587943ac316527c13fc367a3da7567b2d65b Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 6 Sep 2022 01:48:50 +0200 Subject: [PATCH 02/23] return the response for path, batch and delete methods --- lib/ontologies_api_client/http.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ontologies_api_client/http.rb b/lib/ontologies_api_client/http.rb index ef57f9d..102d536 100644 --- a/lib/ontologies_api_client/http.rb +++ b/lib/ontologies_api_client/http.rb @@ -99,7 +99,7 @@ def self.get_batch(paths, params = {}) else responses = threaded_request(paths, params) end - return responses + responses end def self.post(path, obj, options = {}) @@ -133,12 +133,14 @@ def self.patch(path, obj) custom_req(obj, file, file_attribute, req) end raise Exception, response.body if response.status >= 500 + response end def self.delete(id) puts "Deleting #{id}" if $DEBUG response = conn.delete id raise Exception, response.body if response.status >= 500 + response end def self.object_from_json(json) From d468ce092edabd89a9ec93fb229748e02f9cfa39 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 6 Sep 2022 01:50:09 +0200 Subject: [PATCH 03/23] replace Exception with StandardError --- lib/ontologies_api_client/http.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ontologies_api_client/http.rb b/lib/ontologies_api_client/http.rb index 102d536..c4999ea 100644 --- a/lib/ontologies_api_client/http.rb +++ b/lib/ontologies_api_client/http.rb @@ -83,7 +83,7 @@ def self.get(path, params = {}, options = {}) else obj = recursive_struct(load_json(response.body)) end - rescue Exception => e + rescue StandardError => e puts "Problem getting #{path}" if $DEBUG raise e end @@ -108,7 +108,8 @@ def self.post(path, obj, options = {}) req.url path custom_req(obj, file, file_attribute, req) end - raise Exception, response.body if response.status >= 500 + raise StandardError, response.body if response.status >= 500 + if options[:raw] || false # return the unparsed body of the request return response.body else @@ -122,7 +123,8 @@ def self.put(path, obj) req.url path custom_req(obj, file, file_attribute, req) end - raise Exception, response.body if response.status >= 500 + raise StandardError, response.body if response.status >= 500 + recursive_struct(load_json(response.body)) end @@ -132,14 +134,16 @@ def self.patch(path, obj) req.url path custom_req(obj, file, file_attribute, req) end - raise Exception, response.body if response.status >= 500 + raise StandardError, response.body if response.status >= 500 + response end def self.delete(id) puts "Deleting #{id}" if $DEBUG response = conn.delete id - raise Exception, response.body if response.status >= 500 + raise StandardError, response.body if response.status >= 500 + response end From 94463b643547f85dc66cf737cb0b03f4e3ea6738 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 6 Sep 2022 01:50:37 +0200 Subject: [PATCH 04/23] remove useless return keyword --- lib/ontologies_api_client/http.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ontologies_api_client/http.rb b/lib/ontologies_api_client/http.rb index c4999ea..0378bde 100644 --- a/lib/ontologies_api_client/http.rb +++ b/lib/ontologies_api_client/http.rb @@ -111,9 +111,9 @@ def self.post(path, obj, options = {}) raise StandardError, response.body if response.status >= 500 if options[:raw] || false # return the unparsed body of the request - return response.body + response.body else - return recursive_struct(load_json(response.body)) + recursive_struct(load_json(response.body)) end end From d98fb9467af30ce3fb2c42ddccd9f4383e16b68a Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 6 Sep 2022 01:53:04 +0200 Subject: [PATCH 05/23] RuboCop auto lint --- lib/ontologies_api_client/http.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/ontologies_api_client/http.rb b/lib/ontologies_api_client/http.rb index 0378bde..8b736eb 100644 --- a/lib/ontologies_api_client/http.rb +++ b/lib/ontologies_api_client/http.rb @@ -19,6 +19,7 @@ def members def length @table.keys.length end + alias :size :length def to_a @@ -37,7 +38,9 @@ def values_at(*selectors) module LinkedData module Client module HTTP - class Link < String; attr_accessor :media_type; end + class Link < String + attr_accessor :media_type; + end def self.conn unless LinkedData::Client.connection_configured? @@ -53,7 +56,7 @@ def self.conn def self.get(path, params = {}, options = {}) headers = options[:headers] || {} raw = options[:raw] || false # return the unparsed body of the request - params = params.delete_if {|k,v| v == nil || v.to_s.empty?} + params = params.delete_if { |k, v| v == nil || v.to_s.empty? } params[:ncbo_cache_buster] = Time.now.to_f if raw # raw requests don't get cached to ensure body is available invalidate_cache = params.delete(:invalidate_cache) || false @@ -94,7 +97,7 @@ def self.get_batch(paths, params = {}) responses = [] if conn.in_parallel? conn.in_parallel do - paths.each {|p| responses << conn.get(p, params) } + paths.each { |p| responses << conn.get(p, params) } end else responses = threaded_request(paths, params) @@ -176,9 +179,11 @@ def self.custom_req(obj, file, file_attribute, req) def self.params_file_handler(params) return if params.nil? + file, return_attribute = nil, nil params.dup.each do |attribute, value| next unless value.is_a?(File) || value.is_a?(Tempfile) || value.is_a?(ActionDispatch::Http::UploadedFile) + filename = value.original_filename file = Faraday::UploadIO.new(value.path, "text/plain", filename) return_attribute = attribute @@ -209,7 +214,7 @@ def self.recursive_struct(json_obj) context = json_obj.delete("@context") # strip context # Create a struct with the left-over attributes to store data - attributes = json_obj.keys.map {|k| k.to_sym} + attributes = json_obj.keys.map { |k| k.to_sym } attributes_always_present = value_cls.attrs_always_present || [] rescue [] attributes = (attributes + attributes_always_present).uniq @@ -239,7 +244,7 @@ def self.recursive_struct(json_obj) end else # Get the struct class - recursive_obj_hash = {links: nil, context: nil} + recursive_obj_hash = { links: nil, context: nil } json_obj.each do |key, value| recursive_obj_hash[key] = recursive_struct(value) end @@ -266,6 +271,7 @@ def self.prep_links(obj) context = links.delete("@context") return if context.nil? + links.keys.each do |link_type| link = Link.new(links[link_type]) link.media_type = context[link_type] @@ -276,6 +282,7 @@ def self.prep_links(obj) def self.load_json(json) return if json.nil? || json.empty? + begin MultiJson.load(json) rescue Exception => e From a7d447fa539f3500401a15454d0eff3579409742 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 6 Sep 2022 02:11:55 +0200 Subject: [PATCH 06/23] add bundle linux platform --- Gemfile.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile.lock b/Gemfile.lock index e5d51e8..38ba97b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -59,6 +59,7 @@ PLATFORMS ruby x86_64-darwin-16 x86_64-darwin-17 + x86_64-linux DEPENDENCIES ontologies_api_client! From 5a0d380beb5d25d535adaf8f961b0b8647215192 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 16 Nov 2022 11:11:38 -0800 Subject: [PATCH 07/23] set fail-fast to false in order to run all jobs regardless if one fails --- .github/workflows/ruby.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 8eaf0e4..e8f9b86 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -16,6 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: ruby-version: ['2.7', '3.0'] steps: From a52f30b8ab20d35569e404092dfd3831e57c415d Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 16 Nov 2022 15:37:13 -0800 Subject: [PATCH 08/23] Add extra check to detect empty value of UI_APIKEY env var --- config/config.test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/config.test.rb b/config/config.test.rb index ad77b13..af6837b 100644 --- a/config/config.test.rb +++ b/config/config.test.rb @@ -1,7 +1,8 @@ # 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 -abort('env variable UT_APIKEY is not set. Canceling tests...') unless ENV.include?('UT_APIKEY') +abort('UT_APIKEY env variable is not set. Canceling tests') unless ENV.include?('UT_APIKEY') +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' From f6231acb5a73b1692ce5762b728aed66e28695d3 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 16 Nov 2022 17:07:52 -0800 Subject: [PATCH 09/23] use pull_request_target instead of pull_request addresses #14 workflow fails because secrets are not passed to the runner when a workflow is triggered from a forked repository --- .github/workflows/ruby.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index e8f9b86..1ac8f53 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -9,7 +9,8 @@ name: Ruby on: push: - pull_request: + pull_request_target: + types: [opened, reopened] jobs: test: From 21cdfe2d9edc9fd08692ed0d1351f40ad6cbf44d Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 23 Nov 2022 10:08:39 -0800 Subject: [PATCH 10/23] update actions/checkout version --- .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 1ac8f53..e28dcd0 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -21,7 +21,7 @@ jobs: matrix: ruby-version: ['2.7', '3.0'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Ruby # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): From ac80768ea6956c9df6dd84faff7ff9897d92dfec Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 14 Dec 2022 11:22:36 -0800 Subject: [PATCH 11/23] Bump activesupport from 6.0.4.1 to 6.1.5.1 --- Gemfile.lock | 37 +++++++++++++++++------------------ ontologies_api_client.gemspec | 2 +- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d2cc57d..184cfbf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: ontologies_api_client (2.0.3) - activesupport (= 6.0.4.1) + activesupport (= 6.1.5.1) excon faraday faraday-excon (~> 2.0.0) @@ -15,32 +15,32 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.0.4.1) + activesupport (6.1.5.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) coderay (1.1.3) - concurrent-ruby (1.1.9) - excon (0.91.0) + concurrent-ruby (1.1.10) + excon (0.95.0) faraday (2.0.1) faraday-net_http (~> 2.0) ruby2_keywords (>= 0.0.4) faraday-excon (2.0.0) excon (>= 0.27.4) faraday (~> 2.0.0.alpha.pre.2) - faraday-multipart (1.0.3) - multipart-post (>= 1.2, < 3) - faraday-net_http (2.0.1) - i18n (1.10.0) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (2.1.0) + i18n (1.12.0) concurrent-ruby (~> 1.0) lz4-ruby (0.3.3) method_source (1.0.0) - minitest (5.15.0) + minitest (5.16.3) multi_json (1.15.0) - multipart-post (2.1.1) - oj (3.13.11) + multipart-post (2.2.3) + oj (3.13.23) power_assert (2.0.1) pry (0.14.1) coderay (~> 1.1) @@ -50,10 +50,9 @@ GEM spawnling (2.1.5) test-unit (3.5.3) power_assert - thread_safe (0.3.6) - tzinfo (1.2.10) - thread_safe (~> 0.1) - zeitwerk (2.5.4) + tzinfo (2.0.5) + concurrent-ruby (~> 1.0) + zeitwerk (2.6.6) PLATFORMS ruby diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index b0d7966..1f39597 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |gem| gem.require_paths = ["lib"] gem.version = "2.0.3" - gem.add_dependency('activesupport', '6.0.4.1') + gem.add_dependency('activesupport', '6.1.5.1') gem.add_dependency('excon') gem.add_dependency('faraday') gem.add_dependency('faraday-excon', '~> 2.0.0') From ca18863efae65813db46adfce632cc73e325a9a8 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 14 Dec 2022 11:37:21 -0800 Subject: [PATCH 12/23] Update gem.version --- Gemfile.lock | 4 ++-- ontologies_api_client.gemspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 184cfbf..c9c4f48 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ontologies_api_client (2.0.3) + ontologies_api_client (2.2.0) activesupport (= 6.1.5.1) excon faraday @@ -67,4 +67,4 @@ DEPENDENCIES test-unit BUNDLED WITH - 2.1.4 + 2.3.22 diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 1f39597..b305586 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -10,7 +10,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.0.3" + gem.version = "2.2.0" gem.add_dependency('activesupport', '6.1.5.1') gem.add_dependency('excon') From b33b09e2c95c57287a3ff6a60cc335b6f6e2581a Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 10 Jan 2023 09:59:26 -0800 Subject: [PATCH 13/23] Add addressable gem --- Gemfile.lock | 4 ++++ ontologies_api_client.gemspec | 1 + 2 files changed, 5 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index c9c4f48..ac442cd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,7 @@ PATH specs: ontologies_api_client (2.2.0) activesupport (= 6.1.5.1) + addressable (~> 2.8) excon faraday faraday-excon (~> 2.0.0) @@ -21,6 +22,8 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) coderay (1.1.3) concurrent-ruby (1.1.10) excon (0.95.0) @@ -45,6 +48,7 @@ GEM pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) + public_suffix (5.0.1) rake (13.0.6) ruby2_keywords (0.0.5) spawnling (2.1.5) diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index b305586..39d1400 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -13,6 +13,7 @@ Gem::Specification.new do |gem| gem.version = "2.2.0" gem.add_dependency('activesupport', '6.1.5.1') + gem.add_dependency('addressable', '~> 2.8') gem.add_dependency('excon') gem.add_dependency('faraday') gem.add_dependency('faraday-excon', '~> 2.0.0') From 50213694806a7ea60aa7652f51bfc9162c0cb6f6 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 10 Jan 2023 11:55:51 -0800 Subject: [PATCH 14/23] Fix URI.escape is obsolete warnings Resolves #18 --- lib/ontologies_api_client/link_explorer.rb | 5 +++-- lib/ontologies_api_client/models/class.rb | 5 ++++- lib/ontologies_api_client/models/mapping.rb | 10 ++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/ontologies_api_client/link_explorer.rb b/lib/ontologies_api_client/link_explorer.rb index ce77780..421a5f5 100644 --- a/lib/ontologies_api_client/link_explorer.rb +++ b/lib/ontologies_api_client/link_explorer.rb @@ -1,4 +1,4 @@ -require 'uri' +require 'addressable/uri' require_relative 'http' module LinkedData @@ -58,10 +58,11 @@ def combined_links def replace_template_elements(url, values = []) return url if values.nil? || values.empty? + values = values.dup values = [values] unless values.is_a?(Array) return url.gsub(/(\{.*?\})/) do - URI.escape(values.shift, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) + Addressable::URI.encode_component(values.shift, Addressable::URI::CharacterClasses::UNRESERVED) end end diff --git a/lib/ontologies_api_client/models/class.rb b/lib/ontologies_api_client/models/class.rb index e26c9c1..4e620ab 100644 --- a/lib/ontologies_api_client/models/class.rb +++ b/lib/ontologies_api_client/models/class.rb @@ -1,3 +1,4 @@ +require 'addressable/uri' require "uri" require_relative "../base" @@ -47,8 +48,10 @@ def to_jsonld def purl return "" if self.links.nil? return self.id if self.id.include?("purl.") + ont = self.explore.ontology - "#{LinkedData::Client.settings.purl_prefix}/#{ont.acronym}?conceptid=#{URI.escape(self.id, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}" + encoded_id = Addressable::URI.encode_component(self.id, Addressable::URI::CharacterClasses::UNRESERVED) + "#{LinkedData::Client.settings.purl_prefix}/#{ont.acronym}?conceptid=#{encoded_id}" end def ontology diff --git a/lib/ontologies_api_client/models/mapping.rb b/lib/ontologies_api_client/models/mapping.rb index 9e8cf1d..73667b5 100644 --- a/lib/ontologies_api_client/models/mapping.rb +++ b/lib/ontologies_api_client/models/mapping.rb @@ -1,4 +1,4 @@ -require "uri" +require 'addressable/template' require_relative "../base" module LinkedData @@ -11,11 +11,13 @@ class Mapping < LinkedData::Client::Base @media_type = "http://data.bioontology.org/metadata/Mapping" def self.find(id, params = {}) - HTTP.get(mappings_url_prefix + URI.escape(id, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")), params) + template = Addressable::Template.new("#{mappings_url_prefix}/{mapping}") + HTTP.get(template.expand({mapping: id}), params) end def delete - HTTP.delete(mappings_url_prefix + URI.escape(self.id, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))) + template = Addressable::Template.new("#{mappings_url_prefix}/{mapping}") + HTTP.delete(template.expand({mapping: self.id})) end private @@ -24,7 +26,7 @@ def delete # This is in a method because the settings are configured after # the VM initialization, so the rest_url could be null or wrong def self.mappings_url_prefix - LinkedData::Client.settings.rest_url + "/mappings/" + LinkedData::Client.settings.rest_url + "/mappings" end def mappings_url_prefix From c643e53915f3e3398c7432fb4bea0dbce29a4834 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 12 Jan 2023 12:44:06 -0800 Subject: [PATCH 15/23] Add rubocop gem to enable inspections in RubyMine --- Gemfile | 1 + Gemfile.lock | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Gemfile b/Gemfile index acdf917..1d035b1 100644 --- a/Gemfile +++ b/Gemfile @@ -3,5 +3,6 @@ source 'https://rubygems.org' gemspec gem 'rake' +gem 'rubocop', '~> 1.43' gem 'pry' gem 'test-unit' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index ac442cd..85aefcc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,6 +24,7 @@ GEM zeitwerk (~> 2.3) addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) coderay (1.1.3) concurrent-ruby (1.1.10) excon (0.95.0) @@ -38,24 +39,45 @@ GEM faraday-net_http (2.1.0) i18n (1.12.0) concurrent-ruby (~> 1.0) + json (2.6.3) lz4-ruby (0.3.3) method_source (1.0.0) minitest (5.16.3) multi_json (1.15.0) multipart-post (2.2.3) oj (3.13.23) + parallel (1.22.1) + parser (3.2.0.0) + ast (~> 2.4.1) power_assert (2.0.1) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) public_suffix (5.0.1) + rainbow (3.1.1) rake (13.0.6) + regexp_parser (2.6.1) + rexml (3.2.5) + rubocop (1.43.0) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.0.0) + 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) + 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) ruby2_keywords (0.0.5) spawnling (2.1.5) test-unit (3.5.3) power_assert tzinfo (2.0.5) concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) zeitwerk (2.6.6) PLATFORMS @@ -68,6 +90,7 @@ DEPENDENCIES ontologies_api_client! pry rake + rubocop (~> 1.43) test-unit BUNDLED WITH From cb653b0b3ddc516786ec61e68fbf95ce7d369fe3 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 12 Jan 2023 14:36:53 -0800 Subject: [PATCH 16/23] Fix wrong number of arguments error Resolves #21 --- 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 4e620ab..20d1b78 100644 --- a/lib/ontologies_api_client/models/class.rb +++ b/lib/ontologies_api_client/models/class.rb @@ -60,7 +60,7 @@ def ontology def self.find(id, ontology, params = {}) ontology = HTTP.get(ontology, params) - ontology.explore.class(URI.escape(id, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))) + ontology.explore.single_class(id) end def self.search(*args) From bf3e9b3825ae40d6fc06f1e3c71325a778627ed6 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 12 Jan 2023 14:37:14 -0800 Subject: [PATCH 17/23] Add unit test for the find method --- test/models/test_class.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/models/test_class.rb diff --git a/test/models/test_class.rb b/test/models/test_class.rb new file mode 100644 index 0000000..e5abe44 --- /dev/null +++ b/test/models/test_class.rb @@ -0,0 +1,16 @@ +require_relative '../test_case' + +class ClassTest < LinkedData::Client::TestCase + def test_find + id = 'http://bioontology.org/ontologies/Activity.owl#Activity' + ontology = 'https://data.bioontology.org/ontologies/BRO' + cls = LinkedData::Client::Models::Class.find(id, ontology) + refute_nil cls + assert_instance_of LinkedData::Client::Models::Class, cls + assert_equal id, cls.id + 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 + end +end From f80a1b5ca84f77a916b3fb6e92325483a4ddcd54 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 12 Jan 2023 16:27:33 -0800 Subject: [PATCH 18/23] Fix some RuboCop warnings --- ontologies_api_client.gemspec | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 39d1400..41380b7 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -1,16 +1,20 @@ +# frozen_string_literal: true + Gem::Specification.new do |gem| - gem.authors = ["Paul R Alexander"] - gem.email = ["support@bioontology.org"] - gem.description = %q{Models and serializers for ontologies and related artifacts backed by 4store} - gem.summary = %q{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.homepage = "https://github.com/ncbo/ontologies_api_ruby_client" + 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.homepage = 'https://github.com/ncbo/ontologies_api_ruby_client' gem.files = `git ls-files`.split($\) - gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } + gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) - gem.name = "ontologies_api_client" - gem.require_paths = ["lib"] - gem.version = "2.2.0" + gem.name = 'ontologies_api_client' + gem.require_paths = ['lib'] + gem.version = '2.2.0' gem.add_dependency('activesupport', '6.1.5.1') gem.add_dependency('addressable', '~> 2.8') From 20e49180fb49b2c52e3694f920aa98f753f1942e Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 12 Jan 2023 16:29:08 -0800 Subject: [PATCH 19/23] Bump version from 2.2.0 to 2.2.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 85aefcc..d4e6e5b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ontologies_api_client (2.2.0) + ontologies_api_client (2.2.1) activesupport (= 6.1.5.1) addressable (~> 2.8) excon @@ -42,7 +42,7 @@ GEM json (2.6.3) lz4-ruby (0.3.3) method_source (1.0.0) - minitest (5.16.3) + minitest (5.17.0) multi_json (1.15.0) multipart-post (2.2.3) oj (3.13.23) diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 41380b7..9ef6805 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -14,7 +14,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.0' + gem.version = '2.2.1' gem.add_dependency('activesupport', '6.1.5.1') gem.add_dependency('addressable', '~> 2.8') From 15b2c8767177d928a18a691a9a9f555d7ba18249 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Thu, 26 Jan 2023 17:12:17 -0800 Subject: [PATCH 20/23] Unpin version of faraday-excon --- Gemfile.lock | 28 ++++++++++++++-------------- ontologies_api_client.gemspec | 3 ++- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d4e6e5b..dfcd224 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,7 @@ PATH addressable (~> 2.8) excon faraday - faraday-excon (~> 2.0.0) + faraday-excon faraday-multipart lz4-ruby multi_json @@ -26,17 +26,17 @@ GEM public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) coderay (1.1.3) - concurrent-ruby (1.1.10) - excon (0.95.0) - faraday (2.0.1) - faraday-net_http (~> 2.0) + concurrent-ruby (1.2.0) + excon (0.97.2) + faraday (2.7.4) + faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) - faraday-excon (2.0.0) + faraday-excon (2.1.0) excon (>= 0.27.4) - faraday (~> 2.0.0.alpha.pre.2) + faraday (~> 2.0) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (2.1.0) + faraday-net_http (3.0.2) i18n (1.12.0) concurrent-ruby (~> 1.0) json (2.6.3) @@ -44,21 +44,21 @@ GEM method_source (1.0.0) minitest (5.17.0) multi_json (1.15.0) - multipart-post (2.2.3) + multipart-post (2.3.0) oj (3.13.23) parallel (1.22.1) parser (3.2.0.0) ast (~> 2.4.1) - power_assert (2.0.1) - pry (0.14.1) + power_assert (2.0.3) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) public_suffix (5.0.1) rainbow (3.1.1) rake (13.0.6) - regexp_parser (2.6.1) + regexp_parser (2.6.2) rexml (3.2.5) - rubocop (1.43.0) + rubocop (1.44.1) json (~> 2.3) parallel (~> 1.10) parser (>= 3.2.0.0) @@ -73,7 +73,7 @@ GEM ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) spawnling (2.1.5) - test-unit (3.5.3) + test-unit (3.5.7) power_assert tzinfo (2.0.5) concurrent-ruby (~> 1.0) diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 9ef6805..0eb8b05 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -20,7 +20,8 @@ Gem::Specification.new do |gem| gem.add_dependency('addressable', '~> 2.8') gem.add_dependency('excon') gem.add_dependency('faraday') - gem.add_dependency('faraday-excon', '~> 2.0.0') + #gem.add_dependency('faraday-excon', '~> 2.1.0') + gem.add_dependency('faraday-excon') gem.add_dependency('faraday-multipart') gem.add_dependency('lz4-ruby') gem.add_dependency('multi_json') From ea8918b7d63654bcc62fda6840f0a3facaa04a81 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 20 Jun 2023 13:40:46 -0700 Subject: [PATCH 21/23] Bump activesupport from 6.1.5.1 to 6.1.7.3 --- Gemfile.lock | 4 ++-- ontologies_api_client.gemspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index dfcd224..efae580 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: ontologies_api_client (2.2.1) - activesupport (= 6.1.5.1) + activesupport (= 6.1.7.3) addressable (~> 2.8) excon faraday @@ -16,7 +16,7 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.1.5.1) + activesupport (6.1.7.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 0eb8b05..862cba6 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |gem| gem.require_paths = ['lib'] gem.version = '2.2.1' - gem.add_dependency('activesupport', '6.1.5.1') + gem.add_dependency('activesupport', '6.1.7.3') gem.add_dependency('addressable', '~> 2.8') gem.add_dependency('excon') gem.add_dependency('faraday') From 1dfb207c2e7342fa32de10fcebff4af811dea471 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 20 Jun 2023 13:41:37 -0700 Subject: [PATCH 22/23] Remove commented out dependency --- ontologies_api_client.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 862cba6..1fcdf5a 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -20,7 +20,6 @@ Gem::Specification.new do |gem| gem.add_dependency('addressable', '~> 2.8') gem.add_dependency('excon') gem.add_dependency('faraday') - #gem.add_dependency('faraday-excon', '~> 2.1.0') gem.add_dependency('faraday-excon') gem.add_dependency('faraday-multipart') gem.add_dependency('lz4-ruby') From 2f27e471995765c366241493e0d949b3d731ff82 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Tue, 20 Jun 2023 13:48:09 -0700 Subject: [PATCH 23/23] Bump version from 2.2.1 to 2.2.2 --- Gemfile.lock | 20 ++++++++++---------- ontologies_api_client.gemspec | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index efae580..9cf0f9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ontologies_api_client (2.2.1) + ontologies_api_client (2.2.2) activesupport (= 6.1.7.3) addressable (~> 2.8) excon @@ -22,13 +22,13 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.1) + addressable (2.8.4) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) coderay (1.1.3) - concurrent-ruby (1.2.0) - excon (0.97.2) - faraday (2.7.4) + concurrent-ruby (1.2.2) + excon (0.100.0) + faraday (2.7.6) faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) faraday-excon (2.1.0) @@ -37,15 +37,15 @@ GEM faraday-multipart (1.0.4) multipart-post (~> 2) faraday-net_http (3.0.2) - i18n (1.12.0) + i18n (1.14.1) concurrent-ruby (~> 1.0) json (2.6.3) lz4-ruby (0.3.3) method_source (1.0.0) - minitest (5.17.0) + minitest (5.18.1) multi_json (1.15.0) multipart-post (2.3.0) - oj (3.13.23) + oj (3.15.0) parallel (1.22.1) parser (3.2.0.0) ast (~> 2.4.1) @@ -75,10 +75,10 @@ GEM spawnling (2.1.5) test-unit (3.5.7) power_assert - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) - zeitwerk (2.6.6) + zeitwerk (2.6.8) PLATFORMS ruby diff --git a/ontologies_api_client.gemspec b/ontologies_api_client.gemspec index 1fcdf5a..4190b07 100644 --- a/ontologies_api_client.gemspec +++ b/ontologies_api_client.gemspec @@ -14,7 +14,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.1' + gem.version = '2.2.2' gem.add_dependency('activesupport', '6.1.7.3') gem.add_dependency('addressable', '~> 2.8')