ebsco-eds 0.1.9.pre → 0.2.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.test +3 -3
- data/lib/ebsco/eds/configuration.rb +3 -1
- data/lib/ebsco/eds/record.rb +105 -133
- data/lib/ebsco/eds/session.rb +9 -9
- 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: 0ec5b5c854dfdf57d04d9488a7ef07de40711f46
|
4
|
+
data.tar.gz: f05a30ba9788834a16d85924188fd012f402ad45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9991eae7323bacd2151f17ed9ad4ea57a89c6898553ca0e47ae16599c25b8d1e03503e0cd4a8445eddd668bfa9c0412434f94f411d2db84bdf17e491624b3cac
|
7
|
+
data.tar.gz: 657d974a39dc5d75ca716f1691e134f0c251fee8284d6c0a881564cfa86974721ab700b5b7914fdf9cd88c1d4c909a3cf099bfba0fb60823ba24ae3fec1ef31d
|
data/.env.test
CHANGED
@@ -32,7 +32,9 @@ module EBSCO
|
|
32
32
|
:max_results_per_page => 100,
|
33
33
|
:ebook_preferred_format => 'ebook-pdf',
|
34
34
|
:use_cache => true,
|
35
|
-
:eds_cache_dir => ENV['TMPDIR'] || '/tmp'
|
35
|
+
:eds_cache_dir => ENV['TMPDIR'] || '/tmp',
|
36
|
+
:timeout => 60,
|
37
|
+
:open_timeout => 2
|
36
38
|
}
|
37
39
|
@valid_config_keys = @config.keys
|
38
40
|
end
|
data/lib/ebsco/eds/record.rb
CHANGED
@@ -27,6 +27,9 @@ module EBSCO
|
|
27
27
|
:eds_subjects,
|
28
28
|
:eds_subjects_geographic,
|
29
29
|
:eds_subjects_person,
|
30
|
+
:eds_subjects_company,
|
31
|
+
:eds_subjects_mesh,
|
32
|
+
:eds_subjects_bisac,
|
30
33
|
:eds_subjects_genre,
|
31
34
|
:eds_author_supplied_keywords,
|
32
35
|
:eds_descriptors,
|
@@ -41,6 +44,7 @@ module EBSCO
|
|
41
44
|
:eds_publication_date,
|
42
45
|
:eds_publication_year,
|
43
46
|
:eds_publication_info,
|
47
|
+
:eds_publisher,
|
44
48
|
:eds_document_type,
|
45
49
|
:eds_document_doi,
|
46
50
|
:eds_document_oclc,
|
@@ -70,9 +74,48 @@ module EBSCO
|
|
70
74
|
:eds_publication_id,
|
71
75
|
:eds_publication_is_searchable,
|
72
76
|
:eds_publication_scope_note
|
77
|
+
]
|
73
78
|
|
79
|
+
KNOWN_ITEM_NAMES = %w(
|
80
|
+
URL
|
81
|
+
Title
|
82
|
+
TitleSource
|
83
|
+
TitleAlt
|
84
|
+
Abstract
|
85
|
+
Note
|
86
|
+
Author
|
87
|
+
AffiliationAuthor
|
88
|
+
Subject
|
89
|
+
SubjectGeographic
|
90
|
+
SubjectPerson
|
91
|
+
SubjectCompany
|
92
|
+
SubjectMESH
|
93
|
+
SubjectBISAC
|
94
|
+
SubjectGenre
|
95
|
+
Subset
|
96
|
+
Language
|
97
|
+
PhysDesc
|
98
|
+
TypePub
|
99
|
+
DatePub
|
100
|
+
TypeDocument
|
101
|
+
DOI
|
102
|
+
ISSN
|
103
|
+
SeriesInfo
|
104
|
+
FullTextWordCount
|
105
|
+
AbstractSuppliedCopyright
|
106
|
+
CodeNAICS
|
107
|
+
NoteScope
|
108
|
+
Publisher
|
109
|
+
)
|
110
|
+
|
111
|
+
KNOWN_ITEM_LABELS = [
|
112
|
+
'OCLC',
|
113
|
+
'Descriptors',
|
114
|
+
'Publication Information',
|
115
|
+
'Related ISBNs'
|
74
116
|
]
|
75
117
|
|
118
|
+
|
76
119
|
# Raw record as returned by the \EDS API via search or retrieve
|
77
120
|
attr_accessor(*ATTRIBUTES)
|
78
121
|
|
@@ -111,18 +154,21 @@ module EBSCO
|
|
111
154
|
@id = @eds_database_id + '__' + @eds_accession_number.gsub(/\./,'_')
|
112
155
|
@eds_title = title
|
113
156
|
@eds_source_title = source_title
|
114
|
-
@eds_composed_title =
|
115
|
-
@eds_other_titles =
|
116
|
-
@eds_abstract =
|
157
|
+
@eds_composed_title = get_item_data_by_name('TitleSource')
|
158
|
+
@eds_other_titles = get_item_data_by_name('TitleAlt')
|
159
|
+
@eds_abstract = get_item_data_by_name('Abstract')
|
117
160
|
@eds_authors = bib_authors_list
|
118
161
|
@eds_authors_composed = get_item_data_by_name('Author')
|
119
162
|
@eds_author_affiliations = get_item_data_by_name('AffiliationAuthor')
|
120
163
|
@eds_subjects = bib_subjects || get_item_data_by_name('Subject')
|
121
164
|
@eds_subjects_geographic = get_item_data_by_name('SubjectGeographic')
|
122
165
|
@eds_subjects_person = get_item_data_by_name('SubjectPerson')
|
166
|
+
@eds_subjects_company = get_item_data_by_name('SubjectCompany')
|
167
|
+
@eds_subjects_bisac = get_item_data_by_name('SubjectBISAC')
|
168
|
+
@eds_subjects_mesh = get_item_data_by_name('SubjectMESH')
|
123
169
|
@eds_subjects_genre = get_item_data_by_name('SubjectGenre')
|
124
170
|
@eds_author_supplied_keywords = get_item_data_by_name('Keyword')
|
125
|
-
@eds_notes =
|
171
|
+
@eds_notes = get_item_data_by_name('Note')
|
126
172
|
@eds_subset = get_item_data_by_name('Subset')
|
127
173
|
@eds_languages = get_item_data_by_name('Language') || bib_languages
|
128
174
|
@eds_page_count = bib_page_count
|
@@ -133,6 +179,7 @@ module EBSCO
|
|
133
179
|
@eds_publication_date = bib_publication_date || get_item_data_by_name('DatePub')
|
134
180
|
@eds_publication_year = bib_publication_year || get_item_data_by_name('DatePub')
|
135
181
|
@eds_publication_info = get_item_data_by_label('Publication Information')
|
182
|
+
@eds_publisher = get_item_data_by_name('Publisher')
|
136
183
|
@eds_document_type = get_item_data_by_name('TypeDocument')
|
137
184
|
@eds_document_doi = get_item_data_by_name('DOI') || bib_doi
|
138
185
|
@eds_document_oclc = get_item_data_by_label('OCLC')
|
@@ -157,11 +204,17 @@ module EBSCO
|
|
157
204
|
@eds_code_naics = get_item_data_by_name('CodeNAICS')
|
158
205
|
@eds_abstract_supplied_copyright = get_item_data_by_name('AbstractSuppliedCopyright')
|
159
206
|
@eds_descriptors = get_item_data_by_label('Descriptors')
|
160
|
-
|
161
207
|
@eds_publication_id = @record['Header']['PublicationId']
|
162
208
|
@eds_publication_is_searchable = @record['Header']['IsSearchable']
|
163
209
|
@eds_publication_scope_note = get_item_data_by_name('NoteScope')
|
164
210
|
|
211
|
+
# add item metadata
|
212
|
+
@items.each do |item|
|
213
|
+
unless KNOWN_ITEM_NAMES.include?(item['Name']) || KNOWN_ITEM_LABELS.include?(item['Label'])
|
214
|
+
add_extra_item_accessors(item)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
165
218
|
end
|
166
219
|
|
167
220
|
# --
|
@@ -186,38 +239,14 @@ module EBSCO
|
|
186
239
|
if _retval.nil?
|
187
240
|
_retval = 'This title is unavailable for guests, please login to see more information.'
|
188
241
|
end
|
189
|
-
|
242
|
+
_retval
|
190
243
|
end
|
191
244
|
|
192
245
|
# The source title (example: 'Salem Press Encyclopedia')
|
193
246
|
def source_title
|
194
247
|
_retval = bib_source_title || get_item_data_by_name('TitleSource')
|
195
248
|
_reval = nil? if _retval == title # suppress if it's identical to title
|
196
|
-
_retval.nil?? nil :
|
197
|
-
end
|
198
|
-
|
199
|
-
# composed title (example: 'Salem Press Encyclopedia, January, 2017. 2p.')
|
200
|
-
def source_title_composed
|
201
|
-
_retval = get_item_data_by_name('TitleSource')
|
202
|
-
_retval.nil?? nil : CGI.unescapeHTML(_retval)
|
203
|
-
end
|
204
|
-
|
205
|
-
# Other alternative titles.
|
206
|
-
def other_titles
|
207
|
-
_retval = get_item_data_by_name('TitleAlt')
|
208
|
-
_retval.nil?? nil : CGI.unescapeHTML(_retval)
|
209
|
-
end
|
210
|
-
|
211
|
-
# The abstract
|
212
|
-
def abstract
|
213
|
-
_retval = get_item_data_by_name('Abstract')
|
214
|
-
_retval.nil?? nil : CGI.unescapeHTML(_retval)
|
215
|
-
end
|
216
|
-
|
217
|
-
# Notes
|
218
|
-
def notes
|
219
|
-
_retval = get_item_data_by_name('Note')
|
220
|
-
_retval.nil?? nil : CGI.unescapeHTML(_retval)
|
249
|
+
_retval.nil?? nil : _retval
|
221
250
|
end
|
222
251
|
|
223
252
|
# Cover image - thumbnail size link
|
@@ -406,38 +435,6 @@ module EBSCO
|
|
406
435
|
links
|
407
436
|
end
|
408
437
|
|
409
|
-
# ====================================================================================
|
410
|
-
# ITEM DATA HELPERS
|
411
|
-
# ====================================================================================
|
412
|
-
|
413
|
-
# look up by 'Name' and return 'Data'
|
414
|
-
def get_item_data_by_name(name)
|
415
|
-
if @items.empty?
|
416
|
-
nil
|
417
|
-
else
|
418
|
-
_item_property = @items.find{|item| item['Name'] == name}
|
419
|
-
if _item_property.nil?
|
420
|
-
nil
|
421
|
-
else
|
422
|
-
_item_property['Data']
|
423
|
-
end
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
# look up by 'Label' and return 'Data'
|
428
|
-
def get_item_data_by_label(label)
|
429
|
-
if @items.empty?
|
430
|
-
nil
|
431
|
-
else
|
432
|
-
_item_property = @items.find{|item| item['Label'] == label}
|
433
|
-
if _item_property.nil?
|
434
|
-
nil
|
435
|
-
else
|
436
|
-
_item_property['Data']
|
437
|
-
end
|
438
|
-
end
|
439
|
-
end
|
440
|
-
|
441
438
|
# ====================================================================================
|
442
439
|
# BIB ENTITY
|
443
440
|
# ====================================================================================
|
@@ -702,74 +699,7 @@ module EBSCO
|
|
702
699
|
hash
|
703
700
|
end
|
704
701
|
|
705
|
-
# this is used to generate solr fields
|
706
|
-
# def to_hash(type = 'compact')
|
707
|
-
# hash = {}
|
708
|
-
#
|
709
|
-
# # information typically required by all views
|
710
|
-
# if database_id && accession_number
|
711
|
-
# safe_an = accession_number.gsub(/\./,'_')
|
712
|
-
# hash['eds_id'] = database_id + '__' + safe_an
|
713
|
-
# end
|
714
|
-
# unless title.nil?
|
715
|
-
# hash['eds_title'] = title.gsub('<highlight>', '').gsub('</highlight>', '')
|
716
|
-
# end
|
717
|
-
# if source_title
|
718
|
-
# hash['eds_source_title'] = source_title
|
719
|
-
# end
|
720
|
-
# if publication_year
|
721
|
-
# hash['eds_publication_year'] = publication_year
|
722
|
-
# end
|
723
|
-
# if authors
|
724
|
-
# hash['eds_authors'] = authors.to_s
|
725
|
-
# end
|
726
|
-
# if publication_type
|
727
|
-
# hash['eds_publication_type'] = publication_type.to_s
|
728
|
-
# end
|
729
|
-
# if languages
|
730
|
-
# if languages.kind_of?(Array)
|
731
|
-
# hash['eds_language'] = languages.join(', ')
|
732
|
-
# else
|
733
|
-
# hash['eds_language'] = languages.to_s
|
734
|
-
# end
|
735
|
-
# end
|
736
|
-
# if publisher_info
|
737
|
-
# hash['eds_publisher_info'] = publisher_info
|
738
|
-
# end
|
739
|
-
# if abstract
|
740
|
-
# hash['eds_abstract'] = abstract
|
741
|
-
# end
|
742
|
-
# if cover_thumb_url
|
743
|
-
# hash['eds_cover_thumb_url'] = cover_thumb_url
|
744
|
-
# end
|
745
|
-
# if cover_medium_url
|
746
|
-
# hash['eds_cover_medium_url'] = cover_medium_url
|
747
|
-
# end
|
748
|
-
# if all_links
|
749
|
-
# hash['eds_fulltext_link'] = { 'id' => database_id + '__' + safe_an, 'links' => all_links}
|
750
|
-
# end
|
751
|
-
#
|
752
|
-
# # extra information typically required by detailed item views
|
753
|
-
# if type == 'verbose'
|
754
|
-
# if all_links
|
755
|
-
# hash['eds_links'] = all_links
|
756
|
-
# end
|
757
|
-
# if doi
|
758
|
-
# hash['eds_doi'] = doi
|
759
|
-
# end
|
760
|
-
# if html_fulltext
|
761
|
-
# hash['eds_html_fulltext'] = html_fulltext
|
762
|
-
# end
|
763
|
-
# end
|
764
|
-
#
|
765
|
-
# hash
|
766
|
-
# end
|
767
|
-
|
768
702
|
def to_solr
|
769
|
-
# solr response
|
770
|
-
# item_hash = to_hash 'verbose'
|
771
|
-
item_hash = to_attr_hash
|
772
|
-
solr_response =
|
773
703
|
{
|
774
704
|
'responseHeader' => {
|
775
705
|
'status' => 0
|
@@ -777,13 +707,55 @@ module EBSCO
|
|
777
707
|
'response' => {
|
778
708
|
'numFound' => 1,
|
779
709
|
'start' => 0,
|
780
|
-
'docs' =>
|
710
|
+
'docs' => to_attr_hash
|
781
711
|
}
|
782
712
|
}
|
783
|
-
# puts 'SOLR RESPONSE: ' + solr_response.inspect
|
784
|
-
solr_response
|
785
713
|
end
|
786
714
|
|
715
|
+
# ====================================================================================
|
716
|
+
# ITEM DATA HELPERS
|
717
|
+
# ====================================================================================
|
718
|
+
|
719
|
+
# look up by 'Name' and return 'Data'
|
720
|
+
def get_item_data_by_name(name)
|
721
|
+
if @items.empty?
|
722
|
+
nil
|
723
|
+
else
|
724
|
+
_item_property = @items.find{|item| item['Name'] == name}
|
725
|
+
if _item_property.nil?
|
726
|
+
nil
|
727
|
+
else
|
728
|
+
CGI.unescapeHTML(_item_property['Data'])
|
729
|
+
end
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
# look up by 'Label' and return 'Data'
|
734
|
+
def get_item_data_by_label(label)
|
735
|
+
if @items.empty?
|
736
|
+
nil
|
737
|
+
else
|
738
|
+
_item_property = @items.find{|item| item['Label'] == label}
|
739
|
+
if _item_property.nil?
|
740
|
+
nil
|
741
|
+
else
|
742
|
+
CGI.unescapeHTML(_item_property['Data'])
|
743
|
+
end
|
744
|
+
end
|
745
|
+
end
|
746
|
+
|
747
|
+
# dynamically add item metadata as 'eds_extra_ItemNameOrLabel'
|
748
|
+
def add_extra_item_accessors(item)
|
749
|
+
key = item['Name'] ? item['Name'] : item['Label'].gsub(/\s+/, '_')
|
750
|
+
value = item['Data']
|
751
|
+
unless key.nil?
|
752
|
+
key = "eds_extras_#{key}"
|
753
|
+
unless value.nil?
|
754
|
+
class_eval { attr_accessor key }
|
755
|
+
instance_variable_set "@#{key}", CGI.unescapeHTML(value)
|
756
|
+
end
|
757
|
+
end
|
758
|
+
end
|
787
759
|
|
788
760
|
end # Class Record
|
789
761
|
end # Module EDS
|
data/lib/ebsco/eds/session.rb
CHANGED
@@ -104,15 +104,13 @@ module EBSCO
|
|
104
104
|
@use_cache = (ENV.has_key? 'EDS_USE_CACHE') ? ENV['EDS_USE_CACHE'] : @config[:use_cache]
|
105
105
|
@cache_dir = (ENV.has_key? 'EDS_CACHE_DIR') ? ENV['EDS_CACHE_DIR'] : @config[:eds_cache_dir]
|
106
106
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
@guest = @config[:guest]
|
115
|
-
end
|
107
|
+
(ENV.has_key? 'EDS_GUEST') ?
|
108
|
+
if %w(n N no No).include?(ENV['EDS_GUEST'])
|
109
|
+
@guest = false
|
110
|
+
else
|
111
|
+
@guest = true
|
112
|
+
end :
|
113
|
+
@guest = @config[:guest]
|
116
114
|
|
117
115
|
# use cache for auth token and info calls?
|
118
116
|
if @use_cache
|
@@ -685,6 +683,8 @@ module EBSCO
|
|
685
683
|
conn.use :eds_exception_middleware
|
686
684
|
conn.response :json, content_type: /\bjson$/
|
687
685
|
conn.response :detailed_logger, logger if @debug
|
686
|
+
conn.options[:open_timeout] = @config[:open_timeout]
|
687
|
+
conn.options[:timeout] = @config[:timeout]
|
688
688
|
conn.adapter Faraday.default_adapter
|
689
689
|
end
|
690
690
|
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: 0.
|
4
|
+
version: 0.2.0.pre
|
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: 2017-07-
|
12
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|