ebsco-eds 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/lib/ebsco/eds/configuration.rb +6 -0
- data/lib/ebsco/eds/session.rb +34 -5
- data/lib/ebsco/eds/version.rb +1 -1
- data/lib/faraday/eds_caching_middleware.rb +28 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17ca746dd64cbcc74b2832b6c633b884b2cfc605
|
4
|
+
data.tar.gz: 8bb98ab1b49f849604895798437097e9c27128b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa43d9717b7d22d512d9dfb4de457736d0fa0e68a86eafc4d6de6d748ac51a9a3707699e4568065d387587fc90e2d664d8d6b74bdedcd758bde63788ecf55f0e
|
7
|
+
data.tar.gz: 37e46ab2f6e194e6a5d3e333e63e95a4fb81f8b839dd3ad57327d65e8e8110e8c2a58b3a263378bb52345f25a94b7ad29c358ca0cd24c65cccbc8e51a84a6bc2
|
data/CHANGELOG.md
CHANGED
@@ -4,12 +4,19 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.0.6] - 2018-14-02
|
8
|
+
### Fixed
|
9
|
+
- Fixed a bug where the cached auth key isn't deleted if it expires before its cache expiration. This should only occur in rare cases where the auth token cache expiration exceeds 30 minutes.
|
10
|
+
### Added
|
11
|
+
- Cache expiration is configurable for individual EDS API calls (time unit = seconds).
|
12
|
+
### Changed
|
13
|
+
- Default cache expiration for auth keys is now 25 minutes instead of 30 to make sure they are always refreshed before their 30 minute expiration. If an expiration is configured longer than 25 minutes, it is reset to 25 minutes automatically.
|
14
|
+
|
7
15
|
## [1.0.5] - 2018-11-02
|
8
16
|
### Fixed
|
9
17
|
- Fixed a bug where fulltext html becomes nil after sanitizing. [#85](https://github.com/ebsco/edsapi-ruby/issues/85)
|
10
18
|
- Fixed a bug where the url protocol is missing from fulltext custom links. [#86](https://github.com/ebsco/edsapi-ruby/issues/86)
|
11
19
|
|
12
|
-
|
13
20
|
## [1.0.4] - 2018-10-29
|
14
21
|
### Fixed
|
15
22
|
- List retrieval returns a repeating list of just the first record.
|
@@ -81,6 +88,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
81
88
|
### Added
|
82
89
|
- Adds KW (keywords) and SH (subject heading) to solr search fields
|
83
90
|
|
91
|
+
[1.0.6]: https://github.com/ebsco/edsapi-ruby/compare/1.0.5...1.0.6
|
84
92
|
[1.0.5]: https://github.com/ebsco/edsapi-ruby/compare/1.0.4...1.0.5
|
85
93
|
[1.0.4]: https://github.com/ebsco/edsapi-ruby/compare/1.0.3...1.0.4
|
86
94
|
[1.0.3]: https://github.com/ebsco/edsapi-ruby/compare/1.0.2...1.0.3
|
@@ -38,6 +38,12 @@ module EBSCO
|
|
38
38
|
:ebook_preferred_format => 'ebook-pdf',
|
39
39
|
:use_cache => true,
|
40
40
|
:eds_cache_dir => ENV['TMPDIR'] || '/tmp',
|
41
|
+
:auth_cache_expires_in => 1500,
|
42
|
+
:info_cache_expires_in => 86400,
|
43
|
+
:retrieve_cache_expires_in => 1800,
|
44
|
+
:search_cache_expires_in => 1800,
|
45
|
+
:export_format_cache_expires_in => 86400,
|
46
|
+
:citation_styles_cache_expires_in => 86400,
|
41
47
|
:timeout => 60,
|
42
48
|
:open_timeout => 12,
|
43
49
|
:max_page_jumps => 6,
|
data/lib/ebsco/eds/session.rb
CHANGED
@@ -105,9 +105,17 @@ module EBSCO
|
|
105
105
|
raise EBSCO::EDS::InvalidParameter, 'Session must specify a valid api profile.' if blank?(@profile)
|
106
106
|
|
107
107
|
# these config options can be overridden by environment vars
|
108
|
-
@auth_type
|
109
|
-
@org
|
110
|
-
@cache_dir
|
108
|
+
@auth_type = (ENV.has_key? 'EDS_AUTH') ? ENV['EDS_AUTH'] : @config[:auth]
|
109
|
+
@org = (ENV.has_key? 'EDS_ORG') ? ENV['EDS_ORG'] : @config[:org]
|
110
|
+
@cache_dir = (ENV.has_key? 'EDS_CACHE_DIR') ? ENV['EDS_CACHE_DIR'] : @config[:eds_cache_dir]
|
111
|
+
@auth_expire = (ENV.has_key? 'EDS_AUTH_CACHE_EXPIRES_IN') ? ENV['EDS_AUTH_CACHE_EXPIRES_IN'] : @config[:auth_cache_expires_in]
|
112
|
+
@info_expire = (ENV.has_key? 'EDS_INFO_CACHE_EXPIRES_IN') ? ENV['EDS_INFO_CACHE_EXPIRES_IN'] : @config[:info_cache_expires_in]
|
113
|
+
@retrieve_expire = (ENV.has_key? 'EDS_RETRIEVE_CACHE_EXPIRES_IN') ? ENV['EDS_RETRIEVE_CACHE_EXPIRES_IN'] : @config[:retrieve_cache_expires_in]
|
114
|
+
@search_expire = (ENV.has_key? 'EDS_SEARCH_CACHE_EXPIRES_IN') ? ENV['EDS_SEARCH_CACHE_EXPIRES_IN'] : @config[:search_cache_expires_in]
|
115
|
+
@export_format_expire = (ENV.has_key? 'EDS_EXPORT_FORMAT_CACHE_EXPIRES_IN') ? ENV['EDS_EXPORT_FORMAT_CACHE_EXPIRES_IN'] : @config[:export_format_cache_expires_in]
|
116
|
+
@citation_styles_expire = (ENV.has_key? 'EDS_CITATION_STYLES_CACHE_EXPIRES_IN') ? ENV['EDS_CITATION_STYLES_CACHE_EXPIRES_IN'] : @config[:citation_styles_cache_expires_in]
|
117
|
+
|
118
|
+
|
111
119
|
@log_level = (ENV.has_key? 'EDS_LOG_LEVEL') ? ENV['EDS_LOG_LEVEL'] : @config[:log_level]
|
112
120
|
|
113
121
|
(ENV.has_key? 'EDS_GUEST') ?
|
@@ -847,6 +855,11 @@ module EBSCO
|
|
847
855
|
do_request(method, path: path, payload: payload, attempt: attempt+1)
|
848
856
|
# auth token invalid
|
849
857
|
when '104', '107'
|
858
|
+
# delete the auth cache to make sure we have an unexpired auth token
|
859
|
+
if @use_cache
|
860
|
+
puts 'DELETING AUTH CACHE...' if @debug
|
861
|
+
@cache_store.delete_matched('https://' + @api_hosts_list[@api_host_index] + @config[:uid_auth_url])
|
862
|
+
end
|
850
863
|
@auth_token = nil
|
851
864
|
@auth_token = create_auth_token
|
852
865
|
do_request(method, path: path, payload: payload, attempt: attempt+1)
|
@@ -1069,7 +1082,15 @@ module EBSCO
|
|
1069
1082
|
conn.headers['x-authenticationToken'] = @auth_token ? @auth_token : ''
|
1070
1083
|
conn.headers['User-Agent'] = @config[:user_agent]
|
1071
1084
|
conn.request :url_encoded
|
1072
|
-
conn.use :eds_caching_middleware,
|
1085
|
+
conn.use :eds_caching_middleware,
|
1086
|
+
store: @cache_store,
|
1087
|
+
auth_expire: @auth_expire,
|
1088
|
+
info_expire: @info_expire,
|
1089
|
+
search_expire: @search_expire,
|
1090
|
+
retrieve_expire: @retrieve_expire,
|
1091
|
+
export_format_expire: @export_format_expire,
|
1092
|
+
citation_styles_expire: @citation_styles_expire,
|
1093
|
+
logger: @debug ? logger : nil if @use_cache
|
1073
1094
|
conn.use :eds_exception_middleware
|
1074
1095
|
conn.response :json, content_type: /\bjson$/
|
1075
1096
|
conn.response :detailed_logger, logger if @debug
|
@@ -1109,7 +1130,15 @@ module EBSCO
|
|
1109
1130
|
conn.headers['x-authenticationToken'] = @auth_token ? @auth_token : ''
|
1110
1131
|
conn.headers['User-Agent'] = @config[:user_agent]
|
1111
1132
|
conn.request :url_encoded
|
1112
|
-
conn.use :eds_caching_middleware,
|
1133
|
+
conn.use :eds_caching_middleware,
|
1134
|
+
store: @cache_store,
|
1135
|
+
auth_expire: @auth_expire,
|
1136
|
+
info_expire: @info_expire,
|
1137
|
+
search_expire: @search_expire,
|
1138
|
+
retrieve_expire: @retrieve_expire,
|
1139
|
+
export_format_expire: @export_format_expire,
|
1140
|
+
citation_styles_expire: @citation_styles_expire,
|
1141
|
+
logger: @debug ? logger : nil if @use_cache
|
1113
1142
|
conn.use :eds_exception_middleware
|
1114
1143
|
conn.response :json, content_type: /\bjson$/
|
1115
1144
|
conn.response :detailed_logger, logger if @debug
|
data/lib/ebsco/eds/version.rb
CHANGED
@@ -9,11 +9,16 @@ module Faraday
|
|
9
9
|
def initialize(app, *args)
|
10
10
|
super(app)
|
11
11
|
options = args.first || {}
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
12
|
+
@auth_expire = options.fetch(:auth_expire, 1500)
|
13
|
+
@info_expire = options.fetch(:info_expire, 86400)
|
14
|
+
@retrieve_expire = options.fetch(:retrieve_expire, 1800)
|
15
|
+
@search_expire = options.fetch(:search_expire, 1800)
|
16
|
+
@export_format_expire = options.fetch(:export_format_expire, 86400)
|
17
|
+
@citation_styles_expire = options.fetch(:citation_styles_expire, 86400)
|
18
|
+
@logger = options.fetch(:logger, nil)
|
19
|
+
@namespace = options.fetch(:namespace, 'faraday-eds-cache')
|
20
|
+
@store = options.fetch(:store, :memory_store)
|
21
|
+
@store_options = options.fetch(:store_options, {})
|
17
22
|
|
18
23
|
@store_options[:namespace] ||= @namespace
|
19
24
|
|
@@ -44,40 +49,45 @@ module Faraday
|
|
44
49
|
end
|
45
50
|
|
46
51
|
def cache_response(env)
|
52
|
+
|
47
53
|
return unless cacheable?(env) && !env.request_headers['x-faraday-eds-cache']
|
48
54
|
|
49
55
|
info "Cache WRITE: #{key(env)}"
|
50
|
-
custom_expires_in =
|
56
|
+
custom_expires_in = 1800 # 30 mins
|
51
57
|
uri = env.url
|
52
58
|
|
53
59
|
if uri.request_uri.include?('/authservice/rest/uidauth')
|
54
|
-
custom_expires_in =
|
55
|
-
|
60
|
+
custom_expires_in = @auth_expire
|
61
|
+
# don't allow expiration to exceed 25 minutes since auth tokens always expire in 30 minutes
|
62
|
+
if custom_expires_in > 1500
|
63
|
+
custom_expires_in = 1500
|
64
|
+
end
|
65
|
+
info "#{uri} - Setting expires: #{custom_expires_in}"
|
56
66
|
end
|
57
67
|
|
58
68
|
if uri.request_uri.include?('/edsapi/rest/Info')
|
59
|
-
custom_expires_in =
|
60
|
-
info "#{uri} - Setting
|
69
|
+
custom_expires_in = @info_expire
|
70
|
+
info "#{uri} - Setting /edsapi/rest/Info expires: #{custom_expires_in}"
|
61
71
|
end
|
62
72
|
|
63
73
|
if uri.request_uri.include?('/edsapi/rest/Search?')
|
64
|
-
custom_expires_in =
|
65
|
-
info "#{uri} - Setting
|
74
|
+
custom_expires_in = @search_expire
|
75
|
+
info "#{uri} - Setting /edsapi/rest/Search expires: #{custom_expires_in}"
|
66
76
|
end
|
67
77
|
|
68
78
|
if uri.request_uri.include?('/edsapi/rest/Retrieve?')
|
69
|
-
custom_expires_in =
|
70
|
-
info "#{uri} - Setting
|
79
|
+
custom_expires_in = @retrieve_expire
|
80
|
+
info "#{uri} - Setting /edsapi/rest/Retrieve expires: #{custom_expires_in}"
|
71
81
|
end
|
72
82
|
|
73
83
|
if uri.request_uri.include?('/edsapi/rest/ExportFormat')
|
74
|
-
custom_expires_in =
|
75
|
-
info "#{uri} - Setting
|
84
|
+
custom_expires_in = @export_format_expire
|
85
|
+
info "#{uri} - Setting /edsapi/rest/ExportFormat expires: #{custom_expires_in}"
|
76
86
|
end
|
77
87
|
|
78
88
|
if uri.request_uri.include?('/edsapi/rest/CitationStyles')
|
79
|
-
custom_expires_in =
|
80
|
-
info "#{uri} - Setting
|
89
|
+
custom_expires_in = @citation_styles_expire
|
90
|
+
info "#{uri} - Setting /edsapi/rest/CitationStyles expires: #{custom_expires_in}"
|
81
91
|
end
|
82
92
|
|
83
93
|
@store.write(key(env), env, expires_in: custom_expires_in)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ebsco-eds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill McKinney
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-11-
|
12
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|