Skip to content

Commit

Permalink
Merge a7242a8 into 79fefd8
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-harrison committed Dec 6, 2017
2 parents 79fefd8 + a7242a8 commit 54bfa31
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -3,6 +3,7 @@ rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- 2.2.2
- jruby-19mode # JRuby (1.9)
- rbx-2
install: "bundle install --retry=3"
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -7,6 +7,9 @@ gemspec

gem 'jruby-openssl', "~> 0.9.0", platform: :jruby

# TODO: Remove once PR: https://github.com/savonrb/savon/pull/848 has been merged
gem 'savon', git: 'https://github.com/michael-harrison/savon.git', branch: 'hotfix/nokogiri_vulnerbility_USN-3424-1'

group :test do
gem "coveralls", "~> 0.7.0", :require => false
end
Expand Down
5 changes: 3 additions & 2 deletions exlibris-primo.gemspec
Expand Up @@ -20,13 +20,14 @@ Gem::Specification.new do |s|
s.add_dependency "require_all", "~> 1.3.1"
# Leverage ActiveSupport core extensions.
s.add_dependency "activesupport", ">= 3.2.14"
s.add_dependency "nokogiri", "~> 1.6.0"
s.add_dependency "nokogiri", "~> 1.8.1"
s.add_dependency "json", "~> 1.8.0"
s.add_dependency "savon", "~> 2.8.0"
s.add_dependency "savon", "~> 2.12.0"
s.add_dependency "iso-639", "~> 0.2.0"
s.add_development_dependency "rake", "~> 10.1"
s.add_development_dependency "vcr", "~> 2.9.0"
s.add_development_dependency "webmock", "~> 1.20.0"
s.add_development_dependency "pry", "~> 0.9.12.2"
s.add_development_dependency 'minitest', '~> 4.7.5'
s.add_development_dependency 'test-unit'
end
6 changes: 5 additions & 1 deletion lib/exlibris/primo/config.rb
Expand Up @@ -7,7 +7,7 @@ module Primo
module Config
class << self
include WriteAttributes
attr_accessor :base_url, :institution, :institutions, :libraries, :availability_statuses, :sources,
attr_accessor :base_url, :proxy_url, :institution, :institutions, :libraries, :availability_statuses, :sources,
:facet_labels, :facet_top_level, :facet_collections, :facet_resource_types, :load_time

def load_yaml file
Expand All @@ -29,6 +29,10 @@ def base_url
@base_url ||= String.new config.base_url.to_s
end

def proxy_url
@proxy_url ||= config.proxy_url
end

def institution
@institution ||= String.new config.institution.to_s
end
Expand Down
5 changes: 3 additions & 2 deletions lib/exlibris/primo/holding.rb
Expand Up @@ -100,13 +100,14 @@ def to_source

# Return the attribute accessible instance variables as a hash.
def to_h
{ :availlibrary => availlibrary, :record_id => record_id, :original_id => original_id,
{
:availlibrary => availlibrary, :record_id => record_id, :original_id => original_id,
:title => title, :author => author, :display_type => display_type, :source_id => source_id,
:original_source_id => original_source_id, :source_record_id => source_record_id,
:ils_api_id => ils_api_id, :institution_code => institution_code, :library_code => library_code,
:availability_status_code => availability_status_code, :collection => collection,
:call_number => call_number, :coverage => coverage, :notes => notes, :subfields => subfields,
:source_id => source_id, :source_class => source_class, :source_data => source_data }
:source_class => source_class, :source_data => source_data }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/exlibris/primo/version.rb
@@ -1,5 +1,5 @@
module Exlibris
module Primo
VERSION = '1.1.9'
VERSION = '1.1.10'
end
end
13 changes: 12 additions & 1 deletion lib/exlibris/primo/web_service/client/base/savon_client.rb
Expand Up @@ -11,9 +11,20 @@ def client
# we don't want to make an extra HTTP call.
#
# @client ||= Savon.client(wsdl: wsdl)
@client ||= Savon.client(endpoint: endpoint, namespace: endpoint, log: false, log_level: :warn)
@client ||= Savon.client(client_options)
end
protected :client

def client_options
{
proxy: proxy_url,
endpoint: endpoint,
namespace: endpoint,
log: false,
log_level: :warn
}.delete_if { |k, v| v.blank? }
end
private :client_options
end
end
end
Expand Down
7 changes: 5 additions & 2 deletions test/config_test.rb
Expand Up @@ -17,9 +17,10 @@ def test_config

def test_config_from_yaml
reset_primo_configuration
yaml_primo_configuration
yaml_primo_configuration(false)
assert_equal "yaml_url", Exlibris::Primo::Config.base_url
assert_equal "YAML_INSTITUTION", Exlibris::Primo::Config.institution
assert_equal "yaml_proxy_url", Exlibris::Primo::Config.proxy_url
assert_nil(Exlibris::Primo::Config.institutions)
assert_equal({ "LIB_CODE1" => "Library Decoded 1", "LIB_CODE2" => "Library Decoded 2",
"LIB_CODE3" => "Library Decoded 3" }, Exlibris::Primo::Config.libraries)
Expand All @@ -44,10 +45,12 @@ def test_config_from_yaml

def test_config_attributes
reset_primo_configuration
yaml_primo_configuration
yaml_primo_configuration(false)
search = Exlibris::Primo::Search.new
assert_equal "yaml_url", search.base_url
assert_equal "YAML_INSTITUTION", search.institution
assert_equal "yaml_proxy_url", search
.proxy_url
assert_equal({}, search.institutions)
assert_equal({ "LIB_CODE1" => "Library Decoded 1", "LIB_CODE2" => "Library Decoded 2",
"LIB_CODE3" => "Library Decoded 3" }, search.libraries)
Expand Down
1 change: 1 addition & 0 deletions test/support/config.yml
@@ -1,5 +1,6 @@
base_url: "yaml_url"
institution: "YAML_INSTITUTION"
proxy_url: "yaml_proxy_url"
libraries:
"LIB_CODE1": "Library Decoded 1"
"LIB_CODE2": "Library Decoded 2"
Expand Down
4 changes: 3 additions & 1 deletion test/test_helper.rb
Expand Up @@ -66,15 +66,17 @@ def assert_request(request, expected_root, *expected_args)
end
protected :assert_request

def yaml_primo_configuration
def yaml_primo_configuration(overide_proxy_url = true)
Exlibris::Primo.configure do |config|
config.load_yaml File.expand_path("../support/config.yml", __FILE__)
config.proxy_url = nil if overide_proxy_url
end
end

def reset_primo_configuration
Exlibris::Primo.configure do |config|
config.base_url = nil
config.proxy_url = nil
config.institution = nil
config.institutions = nil
config.libraries = nil
Expand Down

0 comments on commit 54bfa31

Please sign in to comment.