umlaut 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/app/controllers/resource_controller.rb +2 -2
- data/app/controllers/umlaut/error_handling.rb +2 -2
- data/app/models/collection.rb +1 -1
- data/app/models/referent.rb +8 -0
- data/app/models/service_wave.rb +1 -7
- data/app/service_adaptors/amazon.rb +3 -2
- data/app/service_adaptors/isbn_link.rb +4 -1
- data/app/service_adaptors/sfx.rb +13 -10
- data/lib/umlaut.rb +2 -0
- data/lib/umlaut/util.rb +24 -0
- data/lib/umlaut/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2JkNmQyMDRkYTIxNGE2YjZlOWNjYWM5MDY2NDk1MmNlYjBiMzg2Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTEzMzAzNjM1OWZiMWY5YzAyZjFiYTBhZDYxYzE1MjdlMmVmMGU5ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmFmZjIzMDUyN2RmNDIxMTI4MDJmNTI2ZjNhMDRkYmFlYjg0MzkwMTIzYWM4
|
10
|
+
YmEyMDA2MTNhZDJlNzk3NTc4YzczNzAyN2ZjODliY2E5MWMwYjI4NWRhZjY5
|
11
|
+
ZWMzNDEwODBjNmE0OTgwNTc2NmZjNDQxMjY5NDc0MWE2Y2Q3ZWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjY0OWQ0YTdjNDE5ZTI5ZDMwOWVmMTE1YmQ3ZTI2YmNhYjk5NTExMWM1NDNj
|
14
|
+
Mjg2YjIwOWYxNDQ1YTFlODcyNjEwOWUzMGQ0MjViNjJiZDU5N2MzZWFmNDNh
|
15
|
+
YjkxOGQ3NDI1ZWZjMTMzZWVlMjY0NmUyY2Q2NWYyMzdkMDNjMTM=
|
@@ -49,9 +49,9 @@ class ResourceController < UmlautController
|
|
49
49
|
render(:text => remote_response.read)
|
50
50
|
rescue Timeout::Error, Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
|
51
51
|
msg = "#{e.inspect}: waiting for image proxy from `#{url_str}`; timeout is currently set to #{HttpTimeout}s; returning broken image"
|
52
|
-
|
52
|
+
backtrace = Umlaut::Util.clean_backtrace(e)
|
53
53
|
|
54
|
-
logger.warn("#{msg}\n #{
|
54
|
+
logger.warn("#{msg}\n #{backtrace.join("\n ")}")
|
55
55
|
|
56
56
|
response.headers['X-Original-Url'] = url_str
|
57
57
|
render :text => msg, :status => 504
|
@@ -36,8 +36,8 @@ module Umlaut::ErrorHandling
|
|
36
36
|
|
37
37
|
def log_error_with_context(exception, severity = :fatal)
|
38
38
|
message = "\n#{exception.class} (#{exception.message}):\n"
|
39
|
-
message << " uri: #{request.fullpath}\n
|
40
|
-
message << " params: #{params.inspect}\n
|
39
|
+
message << " uri: #{request.fullpath}\n"
|
40
|
+
message << " params: #{params.inspect}\n"
|
41
41
|
message << " Referer: #{request.referer}\n" if request.referer
|
42
42
|
message << " User-Agent: #{request.user_agent}\n"
|
43
43
|
message << " Client IP: #{request.remote_addr}\n\n"
|
data/app/models/collection.rb
CHANGED
@@ -142,7 +142,7 @@ class Collection
|
|
142
142
|
# and logged to db as well as logfile if possible, only bugs in ServiceWave
|
143
143
|
# itself should wind up caught here.
|
144
144
|
Thread.current[:exception] = e
|
145
|
-
logger.error("Background Service execution exception: #{e}\n
|
145
|
+
logger.error("Background Service execution exception: #{e.inspect}\n " + Umlaut::Util.clean_backtrace(e).join("\n "))
|
146
146
|
|
147
147
|
# One exception is in test environment, when we may be intentionally
|
148
148
|
# trying to get exceptions to propagate up from ServiceWave to here,
|
data/app/models/referent.rb
CHANGED
@@ -244,6 +244,10 @@ class Referent < ActiveRecord::Base
|
|
244
244
|
def oclcnum
|
245
245
|
return get_oclcnum(self)
|
246
246
|
end
|
247
|
+
|
248
|
+
def doi
|
249
|
+
return get_doi(self)
|
250
|
+
end
|
247
251
|
|
248
252
|
# Creates an OpenURL::ContextObject assembling all the data in this
|
249
253
|
# referrent.
|
@@ -351,6 +355,10 @@ class Referent < ActiveRecord::Base
|
|
351
355
|
if key == "journal" && metadata['atitle'].present?
|
352
356
|
key = 'article'
|
353
357
|
end
|
358
|
+
|
359
|
+
if key == "book" && metadata['atitle'].present?
|
360
|
+
key = "bookitem"
|
361
|
+
end
|
354
362
|
|
355
363
|
label = I18n.t(key, :scope => "umlaut.citation.genre", :default => "")
|
356
364
|
label = nil if label.blank?
|
data/app/models/service_wave.rb
CHANGED
@@ -163,13 +163,7 @@ class ServiceWave
|
|
163
163
|
|
164
164
|
protected
|
165
165
|
def clean_backtrace(exception)
|
166
|
-
|
167
|
-
trace = Rails.backtrace_cleaner.clean(exception.backtrace)
|
168
|
-
trace = Rails.backtrace_cleaner.clean(exception.backtrace, :all) if trace.empty?
|
169
|
-
return trace
|
170
|
-
else
|
171
|
-
return exception.backtrace
|
172
|
-
end
|
166
|
+
Umlaut::Util.clean_backtrace(exception)
|
173
167
|
end
|
174
168
|
|
175
169
|
|
@@ -277,8 +277,9 @@ class Amazon < Service
|
|
277
277
|
end
|
278
278
|
|
279
279
|
end
|
280
|
-
|
281
|
-
|
280
|
+
|
281
|
+
# Don't overwrite aulast with our full au
|
282
|
+
unless (metadata['au'] || metadata['aulast'])
|
282
283
|
if author = (item_attributes.at("Author"))
|
283
284
|
request.referent.enhance_referent('au', author.inner_text)
|
284
285
|
end
|
@@ -28,7 +28,10 @@ class IsbnLink < Service
|
|
28
28
|
def handle(umlaut_request)
|
29
29
|
|
30
30
|
isbn = get_isbn(umlaut_request.referent)
|
31
|
-
|
31
|
+
|
32
|
+
# remove hyphens, some services don't like them.
|
33
|
+
isbn = isbn.gsub('-', '') if isbn.present?
|
34
|
+
|
32
35
|
# No isbn, nothing we can do.
|
33
36
|
return umlaut_request.dispatched(self, true) if isbn.blank?
|
34
37
|
|
data/app/service_adaptors/sfx.rb
CHANGED
@@ -100,7 +100,7 @@ class Sfx < Service
|
|
100
100
|
return @base_url
|
101
101
|
end
|
102
102
|
|
103
|
-
def handle(request)
|
103
|
+
def handle(request)
|
104
104
|
client = self.initialize_client(request)
|
105
105
|
begin
|
106
106
|
response = self.do_request(client)
|
@@ -256,13 +256,11 @@ class Sfx < Service
|
|
256
256
|
|
257
257
|
|
258
258
|
# Okay, keep track of best fit ctx for metadata enhancement
|
259
|
-
if
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
best_nofulltext_ctx = perl_data
|
265
|
-
end
|
259
|
+
if ( umlaut_service == 'fulltext')
|
260
|
+
best_fulltext_ctx = perl_data
|
261
|
+
best_nofulltext_ctx = nil
|
262
|
+
elsif best_nofulltext_ctx == nil
|
263
|
+
best_nofulltext_ctx = perl_data
|
266
264
|
end
|
267
265
|
|
268
266
|
if ( umlaut_service ) # Okay, it's in services or targets of interest
|
@@ -399,7 +397,9 @@ class Sfx < Service
|
|
399
397
|
:service_type_value => "highlighted_link")
|
400
398
|
end
|
401
399
|
|
400
|
+
|
402
401
|
# Did we find a ctx best fit for enhancement?
|
402
|
+
|
403
403
|
if best_fulltext_ctx
|
404
404
|
enhance_referent(request, best_fulltext_ctx)
|
405
405
|
elsif best_nofulltext_ctx
|
@@ -673,15 +673,18 @@ class Sfx < Service
|
|
673
673
|
# Second argument is a Nokogiri element representing the <perldata>
|
674
674
|
# tag and children.
|
675
675
|
def enhance_referent(request, perl_data)
|
676
|
+
|
677
|
+
|
676
678
|
ActiveRecord::Base.connection_pool.with_connection do
|
677
679
|
metadata = request.referent.metadata
|
678
680
|
|
679
681
|
sfx_co = Sfx.parse_perl_data(perl_data)
|
680
682
|
|
681
683
|
sfx_metadata = sfx_co.referent.metadata
|
684
|
+
|
682
685
|
# Do NOT enhance for metadata type 'BOOK', unreliable matching from
|
683
|
-
# SFX!
|
684
|
-
return if sfx_metadata["object_type"] == "BOOK" || sfx_metadata["genre"] == "book"
|
686
|
+
# SFX! UNLESS we requested based on a DOI or ISBN, that's reliable.
|
687
|
+
return if request.referent.isbn.blank? && request.referent.doi.blank? && (sfx_metadata["object_type"] == "BOOK" || sfx_metadata["genre"] == "book")
|
685
688
|
|
686
689
|
# If we already had metadata for journal title and the SFX one
|
687
690
|
# differs, we want to over-write it. This is good for ambiguous
|
data/lib/umlaut.rb
CHANGED
data/lib/umlaut/util.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Umlaut
|
2
|
+
module Util
|
3
|
+
|
4
|
+
module_function
|
5
|
+
|
6
|
+
# Provide a prettified and cleaned exception backtrace array from an exception,
|
7
|
+
# using the Rails backtrace cleaner, as configured in the app. Umlaut configures
|
8
|
+
# it, in an initializer declared in umlaut.rb, to prettify and include Umlaut trace lines.
|
9
|
+
#
|
10
|
+
# This will produce a stack trace similar to what Rails logs by default for uncaught
|
11
|
+
# exceptions. We use it for exception logging in several places.
|
12
|
+
#
|
13
|
+
# Pass in the exception itself, not `exception.backtrace`.
|
14
|
+
def clean_backtrace(exception)
|
15
|
+
if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner)
|
16
|
+
trace = Rails.backtrace_cleaner.clean(exception.backtrace)
|
17
|
+
trace = Rails.backtrace_cleaner.clean(exception.backtrace, :all) if trace.empty?
|
18
|
+
return trace
|
19
|
+
else
|
20
|
+
return exception.backtrace
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/umlaut/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umlaut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind, et al
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -509,6 +509,7 @@ files:
|
|
509
509
|
- lib/truncate_to_db_limit.rb
|
510
510
|
- lib/umlaut.rb
|
511
511
|
- lib/umlaut/routes.rb
|
512
|
+
- lib/umlaut/util.rb
|
512
513
|
- lib/umlaut/version.rb
|
513
514
|
homepage: https://github.com/team-umlaut/umlaut
|
514
515
|
licenses: []
|