ebsco-eds 1.0.2 → 1.0.3
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 +4 -4
- data/lib/ebsco/eds/citations.rb +211 -10
- data/lib/ebsco/eds/configuration.rb +8 -1
- data/lib/ebsco/eds/version.rb +1 -1
- 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: e1cbd8a8c3ea7b3b415848518583ce29fa09e753
|
4
|
+
data.tar.gz: aa61e535cf82ff605822219b5db2ca5ac6d4f48b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0464b610e8bbff86f206d9ed80fffb1b58583840fef7408ee4f3546caf04219af157472408ec1c5928e56ea117196f72af053b3da3c6134e26d5f97ae72046bf
|
7
|
+
data.tar.gz: eaad8cbb7bc87b1dc103ea264536d2f70aa3f1dc14a04e16b994fb7da9ef03daffc237c95ce325276c2fa26d6e93da64d999116da9de179399ef8c787b329e39
|
data/lib/ebsco/eds/citations.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ebsco/eds/jsonable'
|
2
|
+
require 'erb'
|
2
3
|
|
3
4
|
module EBSCO
|
4
5
|
module EDS
|
@@ -9,14 +10,83 @@ module EBSCO
|
|
9
10
|
|
10
11
|
def initialize(dbid:, an:, citation_result:, eds_config: nil)
|
11
12
|
|
12
|
-
|
13
|
-
(ENV.has_key? '
|
14
|
-
if %w(y Y yes Yes true True).include?(ENV['
|
15
|
-
@
|
13
|
+
|
14
|
+
(ENV.has_key? 'EDS_DEBUG') ?
|
15
|
+
if %w(y Y yes Yes true True).include?(ENV['EDS_DEBUG'])
|
16
|
+
@debug = true
|
17
|
+
else
|
18
|
+
@debug = false
|
19
|
+
end :
|
20
|
+
@debug = eds_config[:debug]
|
21
|
+
|
22
|
+
# citation link find and replace?
|
23
|
+
(ENV.has_key? 'EDS_CITATION_LINK_FIND') ?
|
24
|
+
if !ENV['EDS_CITATION_LINK_FIND'].empty?
|
25
|
+
@citation_link_find = ENV['EDS_CITATION_LINK_FIND']
|
16
26
|
else
|
17
|
-
@
|
27
|
+
@citation_link_find = ""
|
18
28
|
end :
|
19
|
-
@
|
29
|
+
@citation_link_find = eds_config[:citation_link_find]
|
30
|
+
|
31
|
+
(ENV.has_key? 'EDS_CITATION_LINK_REPLACE') ?
|
32
|
+
if !ENV['EDS_CITATION_LINK_REPLACE'].empty?
|
33
|
+
@citation_link_replace = ENV['EDS_CITATION_LINK_REPLACE']
|
34
|
+
else
|
35
|
+
@citation_link_replace = ""
|
36
|
+
end :
|
37
|
+
@citation_link_replace = eds_config[:citation_link_replace]
|
38
|
+
|
39
|
+
# citation db find and replace?
|
40
|
+
(ENV.has_key? 'EDS_CITATION_DB_FIND') ?
|
41
|
+
if !ENV['EDS_CITATION_DB_FIND'].empty?
|
42
|
+
@citation_db_find = ENV['EDS_CITATION_DB_FIND']
|
43
|
+
else
|
44
|
+
@citation_db_find = ""
|
45
|
+
end :
|
46
|
+
@citation_db_find = eds_config[:citation_db_find]
|
47
|
+
|
48
|
+
(ENV.has_key? 'EDS_CITATION_DB_REPLACE') ?
|
49
|
+
if !ENV['EDS_CITATION_DB_REPLACE'].empty?
|
50
|
+
@citation_db_replace = ENV['EDS_CITATION_DB_REPLACE']
|
51
|
+
else
|
52
|
+
@citation_db_replace = ""
|
53
|
+
end :
|
54
|
+
@citation_db_replace = eds_config[:citation_db_replace]
|
55
|
+
|
56
|
+
|
57
|
+
# citation link find and replace?
|
58
|
+
(ENV.has_key? 'EDS_RIS_LINK_FIND') ?
|
59
|
+
if !ENV['EDS_RIS_LINK_FIND'].empty?
|
60
|
+
@ris_link_find = ENV['EDS_RIS_LINK_FIND']
|
61
|
+
else
|
62
|
+
@ris_link_find = ""
|
63
|
+
end :
|
64
|
+
@ris_link_find = eds_config[:ris_link_find]
|
65
|
+
|
66
|
+
(ENV.has_key? 'EDS_RIS_LINK_REPLACE') ?
|
67
|
+
if !ENV['EDS_RIS_LINK_REPLACE'].empty?
|
68
|
+
@ris_link_replace = ENV['EDS_RIS_LINK_REPLACE']
|
69
|
+
else
|
70
|
+
@ris_link_replace = ""
|
71
|
+
end :
|
72
|
+
@ris_link_replace = eds_config[:ris_link_replace]
|
73
|
+
|
74
|
+
# citation db find and replace?
|
75
|
+
(ENV.has_key? 'EDS_RIS_DB_FIND') ?
|
76
|
+
if !ENV['EDS_RIS_DB_FIND'].empty?
|
77
|
+
@ris_db_find = ENV['EDS_RIS_DB_FIND']
|
78
|
+
else
|
79
|
+
@ris_db_find = ""
|
80
|
+
end :
|
81
|
+
@ris_db_find = eds_config[:ris_db_find]
|
82
|
+
|
83
|
+
(ENV.has_key? 'EDS_RIS_DB_REPLACE') ?
|
84
|
+
if !ENV['EDS_RIS_DB_REPLACE'].empty?
|
85
|
+
@ris_db_replace = ENV['EDS_RIS_DB_REPLACE']
|
86
|
+
else
|
87
|
+
@ris_db_replace = ""
|
88
|
+
end :
|
89
|
+
@ris_db_replace = eds_config[:ris_db_replace]
|
20
90
|
|
21
91
|
@eds_database_id = dbid
|
22
92
|
@eds_accession_number = an
|
@@ -35,14 +105,41 @@ module EBSCO
|
|
35
105
|
end
|
36
106
|
|
37
107
|
if style.key? 'Label'
|
108
|
+
puts if @debug
|
109
|
+
puts style['Label'].inspect if @debug
|
38
110
|
item['label'] = JSON.parse(style['Label'].to_json)
|
39
111
|
end
|
40
112
|
|
41
113
|
if style.key? 'Data'
|
42
114
|
data = JSON.parse(style['Data'].to_json)
|
43
|
-
|
44
|
-
|
115
|
+
|
116
|
+
|
117
|
+
if data
|
118
|
+
puts 'BEFORE: ' + data.inspect if @debug
|
119
|
+
|
120
|
+
# apply citation link find & replace
|
121
|
+
unless @citation_link_find.empty?
|
122
|
+
replace_template = ERB.new(@citation_link_replace)
|
123
|
+
find_template = ERB.new(@citation_link_find)
|
124
|
+
replace_link = replace_template.result(binding)
|
125
|
+
find_link_regex = find_template.result(binding)
|
126
|
+
link_regex = Regexp.new find_link_regex
|
127
|
+
data = data.gsub!(link_regex, replace_link) || data
|
128
|
+
end
|
129
|
+
|
130
|
+
# apply citation db find & replace
|
131
|
+
unless @citation_db_find.empty?
|
132
|
+
replace_template = ERB.new(@citation_db_replace)
|
133
|
+
find_template = ERB.new(@citation_db_find)
|
134
|
+
replace_db = replace_template.result(binding)
|
135
|
+
find_db_regex = find_template.result(binding)
|
136
|
+
link_regex = Regexp.new find_db_regex
|
137
|
+
data = data.gsub!(link_regex, replace_db) || data
|
138
|
+
end
|
139
|
+
|
140
|
+
puts 'AFTER: ' + data.inspect if @debug
|
45
141
|
end
|
142
|
+
|
46
143
|
item['data'] = data
|
47
144
|
end
|
48
145
|
|
@@ -76,9 +173,34 @@ module EBSCO
|
|
76
173
|
|
77
174
|
if citation_result.key? 'Data'
|
78
175
|
data = JSON.parse(citation_result['Data'].to_json)
|
79
|
-
|
80
|
-
|
176
|
+
|
177
|
+
if data
|
178
|
+
puts "BEFORE: \n" if @debug
|
179
|
+
puts data if @debug
|
180
|
+
# apply ris link find & replace
|
181
|
+
unless @citation_link_find.empty?
|
182
|
+
replace_template = ERB.new(@ris_link_replace)
|
183
|
+
find_template = ERB.new(@ris_link_find)
|
184
|
+
replace_link = replace_template.result(binding)
|
185
|
+
find_link_regex = find_template.result(binding)
|
186
|
+
link_regex = Regexp.new find_link_regex
|
187
|
+
data = data.gsub!(link_regex, replace_link) || data
|
188
|
+
end
|
189
|
+
|
190
|
+
# apply ris db find & replace
|
191
|
+
unless @ris_db_find.empty?
|
192
|
+
replace_template = ERB.new(@ris_db_replace)
|
193
|
+
find_template = ERB.new(@ris_db_find)
|
194
|
+
replace_db = replace_template.result(binding)
|
195
|
+
find_db_regex = find_template.result(binding)
|
196
|
+
link_regex = Regexp.new find_db_regex
|
197
|
+
data = data.gsub!(link_regex, replace_db) || data
|
198
|
+
end
|
199
|
+
puts if @debug
|
200
|
+
puts "AFTER: \n" if @debug
|
201
|
+
puts data if @debug
|
81
202
|
end
|
203
|
+
|
82
204
|
item['data'] = data
|
83
205
|
end
|
84
206
|
|
@@ -144,7 +266,86 @@ module EBSCO
|
|
144
266
|
citation.gsub!(/DP\s+-\s+EBSCOhost\s+/, '')
|
145
267
|
end
|
146
268
|
citation
|
269
|
+
end
|
270
|
+
|
271
|
+
def applyLinksTemplateToExports(data, dbid, an)
|
272
|
+
if data
|
273
|
+
renderer = ERB.new(@links_template)
|
274
|
+
new_link = renderer.result(binding)
|
275
|
+
unless new_link.empty?
|
276
|
+
if @debug
|
277
|
+
puts 'doing links template...'
|
278
|
+
puts 'BEFORE:'
|
279
|
+
puts data.inspect
|
280
|
+
end
|
281
|
+
data.gsub!(/UR\s+--\s+http:\/\/search\.ebscohost\.com\/login\.aspx\?direct=true&site=eds-live&db=#{dbid}&AN=#{an}/, 'UR - ' + new_link)
|
282
|
+
if @debug
|
283
|
+
puts 'AFTER:'
|
284
|
+
puts data.inspect
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
data
|
289
|
+
end
|
290
|
+
|
291
|
+
def applyDbTemplateToExports(data)
|
292
|
+
if data
|
293
|
+
renderer = ERB.new(@db_template)
|
294
|
+
new_db = renderer.result(binding)
|
295
|
+
unless new_db.empty?
|
296
|
+
if @debug
|
297
|
+
puts 'doing db template...'
|
298
|
+
puts 'BEFORE:'
|
299
|
+
puts data.inspect
|
300
|
+
end
|
301
|
+
data.gsub!(/DP\s+-\s+EBSCOhost/, 'DP - ' + new_db)
|
302
|
+
if @debug
|
303
|
+
puts 'AFTER:'
|
304
|
+
puts data.inspect
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
data
|
309
|
+
end
|
310
|
+
|
311
|
+
def applyLinksTemplateToStyles(data, dbid, an)
|
312
|
+
if data
|
313
|
+
renderer = ERB.new(@links_template)
|
314
|
+
new_link = renderer.result(binding)
|
315
|
+
unless new_link.empty?
|
316
|
+
if @debug
|
317
|
+
puts 'doing links template...'
|
318
|
+
puts 'BEFORE:'
|
319
|
+
puts data.inspect
|
320
|
+
end
|
321
|
+
data.gsub!(/(http:\/\/)?search\.ebscohost\.com\/login\.aspx\?direct=true&site=eds-live&db=#{dbid}&AN=#{an}/, new_link)
|
322
|
+
if @debug
|
323
|
+
puts 'AFTER:'
|
324
|
+
puts data.inspect
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
data
|
329
|
+
end
|
147
330
|
|
331
|
+
def applyDbTemplateToStyles(data)
|
332
|
+
if data
|
333
|
+
renderer = ERB.new(@db_template)
|
334
|
+
new_db = renderer.result(binding)
|
335
|
+
unless new_db.empty?
|
336
|
+
if @debug
|
337
|
+
puts 'doing db template...'
|
338
|
+
puts 'BEFORE:'
|
339
|
+
puts data.inspect
|
340
|
+
end
|
341
|
+
data.gsub!(/<i>EBSCOhost<\/i>/, '<i>' + new_db + '</i>')
|
342
|
+
if @debug
|
343
|
+
puts 'AFTER:'
|
344
|
+
puts data.inspect
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
data
|
148
349
|
end
|
149
350
|
|
150
351
|
end
|
@@ -46,7 +46,14 @@ module EBSCO
|
|
46
46
|
:all_subjects_search_links => false,
|
47
47
|
:decode_sanitize_html => false,
|
48
48
|
:titleize_facets => false,
|
49
|
-
:
|
49
|
+
:citation_link_find => '[.,]\s+(<i>EBSCOhost|viewed|Available|Retrieved from|http:\/\/search.ebscohost.com|Disponível em).+$',
|
50
|
+
:citation_link_replace => '.',
|
51
|
+
:citation_db_find => '',
|
52
|
+
:citation_db_replace => '',
|
53
|
+
:ris_link_find => '',
|
54
|
+
:ris_link_replace => '',
|
55
|
+
:ris_db_find => '',
|
56
|
+
:ris_db_replace => ''
|
50
57
|
}
|
51
58
|
@valid_config_keys = @config.keys
|
52
59
|
end
|
data/lib/ebsco/eds/version.rb
CHANGED
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.3
|
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-10-
|
12
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|