forked from ontoportal/ontologies_api_ruby_client
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fff5453
commit cf68ad1
Showing
13 changed files
with
276 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,33 @@ | ||
# 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('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 | ||
$API_CLIENT_INVALIDATE_CACHE = false | ||
$DEBUG_API_CLIENT = false | ||
|
||
LinkedData::Client.config do |config| | ||
config.rest_url = 'https://data.bioontology.org' | ||
config.apikey = ENV['UT_APIKEY'] | ||
# config.apikey = 'xxxxx-xxxxx-xxxxxxxxxx' | ||
config.rest_url = 'https://data.bioontology.org/' | ||
config.apikey = '8b5b7825-538d-40e0-9e9e-5ab9274a9aeb' | ||
config.links_attr = 'links' | ||
config.cache = false | ||
config.cache = true | ||
config.debug_client = false | ||
config.debug_client_keys = [] | ||
config.federated_portals = { | ||
bioportal: { | ||
api: 'https://data.agroportal.lirmm.fr/', | ||
apikey: '1de0a270-29c5-4dda-b043-7c3580628cd5', | ||
color: '#234979', | ||
}, | ||
ecoportal: { | ||
api: 'https://data.ecoportal.lifewatch.eu/', | ||
apikey: "43a437ba-a437-4bf0-affd-ab520e584719", | ||
color: '#0f4e8a', | ||
}, | ||
# earthportal: { | ||
# api: 'https://earthportal.eu:8443/', | ||
# apikey: "c9147279-954f-41bd-b068-da9b0c441288", | ||
# color: '#1e2251', | ||
# }, | ||
biodivportal: { | ||
api: 'https://data.biodivportal.gfbio.org/', | ||
apikey: "47a57aa3-7b54-4f34-b695-dbb5f5b7363e", | ||
color: '#1e2251', | ||
} | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'active_support/core_ext/hash' | ||
|
||
module LinkedData | ||
module Client | ||
module RequestFederation | ||
|
||
def self.included(base) | ||
base.extend(ClassMethods) | ||
end | ||
|
||
module ClassMethods | ||
def federated_get(params = {}, &link) | ||
federate = params.delete(:federate) || ::RequestStore.store[:federated_portals] | ||
|
||
portals = [LinkedData::Client::HTTP.conn] | ||
|
||
if federate.is_a?(Array) | ||
portals += LinkedData::Client::HTTP.federated_conn | ||
.select{|portal_name, _| federate.include?(portal_name) || federate.include?(portal_name.to_s)} | ||
.values | ||
elsif !federate.blank? # all | ||
portals += LinkedData::Client::HTTP.federated_conn.values | ||
end | ||
|
||
connections = Parallel.map(portals, in_threads: portals.size) do |conn| | ||
begin | ||
HTTP.get(link.call(conn.url_prefix.to_s.chomp('/')), params, connection: conn) | ||
rescue StandardError => e | ||
[OpenStruct.new(errors: "Problem retrieving #{link.call(conn.url_prefix.to_s.chomp('/'))}")] | ||
end | ||
end | ||
|
||
connections.flatten | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
Oops, something went wrong.