Skip to content

Commit

Permalink
merge pl/add-mainlang-defaults-refactored into master
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Mar 16, 2022
2 parents 89a8f66 + 7c9aa72 commit 56fc95c
Show file tree
Hide file tree
Showing 12 changed files with 1,447 additions and 994 deletions.
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ gem 'minitest', '< 5.0'
gem 'activesupport'
gem "uuid"
gem 'cube-ruby', require: "cube"
gem 'faraday', '~> 1.9'

# Profiling
group :profiling do
gem 'sinatra'
gem 'rack-accept'
gem 'rack-post-body-to-params'
#gem 'rack-mini-profiler'
gem 'thin'
end

# NCBO Dependencies
gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'master'
35 changes: 20 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,29 @@ GEM
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
eventmachine (1.2.7)
faraday (1.8.0)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
multipart-post (>= 1.2, < 3)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.3)
multipart-post (>= 1.2, < 3)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
http-accept (1.7.0)
http-cookie (1.0.4)
domain_name (~> 0.5)
Expand All @@ -71,7 +75,7 @@ GEM
method_source (1.0.0)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.1115)
mime-types-data (3.2022.0105)
minitest (4.7.5)
multi_json (1.15.0)
multipart-post (2.1.1)
Expand All @@ -87,31 +91,31 @@ GEM
rack (>= 0.4)
rack-post-body-to-params (0.1.8)
activesupport (>= 2.3)
rack-protection (2.1.0)
rack-protection (2.2.0)
rack
rake (13.0.6)
rdf (1.0.8)
addressable (>= 2.2)
redis (4.5.1)
redis (4.6.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rsolr (2.3.0)
rsolr (2.5.0)
builder (>= 2.1.2)
faraday (>= 0.9.0)
faraday (>= 0.9, < 3, != 2.0.0)
ruby2_keywords (0.0.5)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
sinatra (2.1.0)
simplecov_json_formatter (0.1.4)
sinatra (2.2.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
rack-protection (= 2.2.0)
tilt (~> 2.0)
systemu (2.6.5)
thin (1.8.1)
Expand All @@ -123,16 +127,17 @@ GEM
tzinfo (0.3.60)
unf (0.1.4)
unf_ext
unf_ext (0.0.8)
unf_ext (0.0.8.1)
uuid (2.3.9)
macaddr (~> 1.0)

PLATFORMS
ruby
x86_64-darwin-21

DEPENDENCIES
activesupport
cube-ruby
faraday (~> 1.9)
goo!
minitest (< 5.0)
pry
Expand All @@ -146,4 +151,4 @@ DEPENDENCIES
uuid

BUNDLED WITH
2.1.4
2.3.5
22 changes: 19 additions & 3 deletions lib/goo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
require_relative "goo/utils/utils"
require_relative "goo/mixins/sparql_client"


module Goo


@@resource_options = Set.new([:persistent]).freeze

# Define the languages from which the properties values will be taken (be careful if prefLabel with different lang, only one will be taken)
@@main_lang = ["en","eng"]
# Define the languages from which the properties values will be taken
# It choose the first language that match otherwise return all the values
@@main_languages = %w[en]

@@configure_flag = false
@@sparql_backends = {}
Expand All @@ -43,6 +46,19 @@ module Goo

@@slice_loading_size = 500


def self.main_languages
@@main_languages
end
def self.main_languages=(lang)
@@main_languages = lang
end

def self.language_includes(lang)
lang_str = lang.to_s
main_languages.index { |l| lang_str.downcase.eql?(l) || lang_str.upcase.eql?(l)}
end

def self.add_namespace(shortcut, namespace,default=false)
if !(namespace.instance_of? RDF::Vocabulary)
raise ArgumentError, "Namespace must be a RDF::Vocabulary object"
Expand Down Expand Up @@ -238,7 +254,7 @@ def self.search_connection(name=:main)
end

def self.sparql_query_client(name=:main)
return @@sparql_backends[name][:query]
@@sparql_backends[name][:query]
end

def self.sparql_update_client(name=:main)
Expand Down
Loading

0 comments on commit 56fc95c

Please sign in to comment.