Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: .
specs:
ontologies_api_client (2.5.0)
activesupport (= 7.0.8)
ontologies_api_client (2.5.3)
activesupport (= 7.2.2.1)
addressable (~> 2.8)
excon
faraday
Expand All @@ -15,17 +15,28 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
activesupport (7.2.2.1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
coderay (1.1.3)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
drb (2.2.1)
excon (1.2.3)
faraday (2.12.2)
faraday-net_http (>= 2.0, < 3.5)
Expand Down Expand Up @@ -83,6 +94,7 @@ GEM
rubocop-ast (1.38.0)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
securerandom (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.1.4)
Expand Down
26 changes: 13 additions & 13 deletions lib/ontologies_api_client/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Link < String

def self.conn
unless LinkedData::Client.connection_configured?
if Kernel.const_defined?("Rails")
rails = Kernel.const_get("Rails")
if Kernel.const_defined?('Rails')
rails = Kernel.const_get('Rails')
store = rails.cache if rails.cache
end
LinkedData::Client.config_connection(cache_store: store)
Expand All @@ -58,7 +58,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

Expand All @@ -72,9 +72,9 @@ def self.get(path, params = {}, options = {})
req.headers.merge(headers)
req.headers[:invalidate_cache] = invalidate_cache
end
rescue Exception => e
rescue StandardError => e
params = Faraday::Utils.build_query(params)
path << "?" unless params.empty? || path.include?("?")
path += '?' unless params.empty? || path.include?('?')
raise e, "Problem retrieving:\n#{path}#{params}\n\nError: #{e.message}\n#{e.backtrace.join("\n\t")}"
end

Expand Down Expand Up @@ -163,14 +163,14 @@ def self.custom_req(obj, file, file_attribute, req)

if file
# multipart
boundary = "OntologiesAPIMultipartPost"
boundary = 'OntologiesAPIMultipartPost'
req.headers['Content-Type'] = "multipart/mixed; boundary=#{boundary}; type=application/json; start=json"
parts = []
parts << Faraday::Parts::Part.new(boundary, "json\"\r\nContent-Type: \"application/json; charset=UTF-8", MultiJson.dump(obj))
parts << Faraday::Parts::Part.new(boundary, file_attribute, file)
parts << Faraday::Parts::EpiloguePart.new(boundary)
req.body = Faraday::CompositeReadIO.new(parts)
req.headers["Content-Length"] = req.body.length.to_s
req.headers['Content-Length'] = req.body.length.to_s
else
# normal
req.body = MultiJson.dump(obj)
Expand All @@ -187,7 +187,7 @@ def self.params_file_handler(params)
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)
file = Faraday::UploadIO.new(value.path, 'text/plain', filename)
return_attribute = attribute
params.delete(attribute)
end
Expand All @@ -211,9 +211,9 @@ def self.recursive_struct(json_obj)
if json_obj.is_a?(Hash)
return if json_obj.empty?

value_cls = LinkedData::Client::Base.class_for_type(json_obj["@type"])
value_cls = LinkedData::Client::Base.class_for_type(json_obj['@type'])
links = prep_links(json_obj) # strip links
context = json_obj.delete("@context") # strip context
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 }
Expand All @@ -224,7 +224,7 @@ def self.recursive_struct(json_obj)
if value_cls
instance = value_cls.new
attributes.each do |attr|
attr = attr[1..-1] if attr[0].eql?("@")
attr = attr[1..-1] if attr[0].eql?('@')
instance.class.class_eval do
unless method_defined?(attr.to_sym)
define_method attr.to_sym do
Expand All @@ -241,7 +241,7 @@ def self.recursive_struct(json_obj)

# Create objects for each key/value pair, recursively
json_obj.each do |attr, value|
attr = attr[1..-1] if attr[0].eql?("@")
attr = attr[1..-1] if attr[0].eql?('@')
instance.instance_variable_set("@#{attr}", recursive_struct(value))
end
else
Expand Down Expand Up @@ -271,7 +271,7 @@ def self.prep_links(obj)
links = obj.delete(LinkedData::Client.settings.links_attr)
return if links.nil?

context = links.delete("@context")
context = links.delete('@context')
return if context.nil?

links.keys.each do |link_type|
Expand Down
2 changes: 1 addition & 1 deletion lib/ontologies_api_client/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module LinkedData
module Client
VERSION = '2.5.0'
VERSION = '2.5.3'
end
end
2 changes: 1 addition & 1 deletion ontologies_api_client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
gem.require_paths = ['lib']
gem.version = LinkedData::Client::VERSION

gem.add_dependency('activesupport', '7.0.8')
gem.add_dependency('activesupport', '7.2.2.1')
gem.add_dependency('addressable', '~> 2.8')
gem.add_dependency('excon')
gem.add_dependency('faraday')
Expand Down
Loading