ebsco-eds 0.0.5.pre → 0.0.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ebsco/eds/options.rb +39 -2
- data/lib/ebsco/eds/record.rb +5 -2
- data/lib/ebsco/eds/results.rb +20 -0
- data/lib/ebsco/eds/session.rb +16 -6
- 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: 52a371da7111d83a7616bdd5de68deabd1c6983a
|
4
|
+
data.tar.gz: 00fae54472789a602ad4cd50cab93f88d4778308
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b195bf1718c6715555487dc15f3d2eaccd62e5a2ec7152fb606a7a07a069b95a66d7758c83b5a04fd7d321b05889965e7e9c75e8eedf7d0933b6244f0ede8207
|
7
|
+
data.tar.gz: a4b22c20bcc5c092dd55414e4cfd4a427049e277e10c2cd4ce76ac8f27184daa9fa69334cd28e4ab2f5afa2885407bb00c0ddabfe55ae319b242b169c9b28daa
|
data/lib/ebsco/eds/options.rb
CHANGED
@@ -36,57 +36,66 @@ module EBSCO
|
|
36
36
|
@Actions.push "addfacetfilter(SourceType:#{item})"
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
39
40
|
if value.has_key?('language_facet')
|
40
41
|
lang_list = value['language_facet']
|
41
42
|
lang_list.each do |item|
|
42
43
|
@Actions.push "addfacetfilter(Language:#{item})"
|
43
44
|
end
|
44
45
|
end
|
46
|
+
|
45
47
|
if value.has_key?('subject_topic_facet')
|
46
48
|
subj_list = value['subject_topic_facet']
|
47
49
|
subj_list.each do |item|
|
48
50
|
@Actions.push "addfacetfilter(SubjectEDS:#{item})"
|
49
51
|
end
|
50
52
|
end
|
53
|
+
|
51
54
|
if value.has_key?('geographic_facet')
|
52
55
|
subj_list = value['geographic_facet']
|
53
56
|
subj_list.each do |item|
|
54
57
|
@Actions.push "addfacetfilter(SubjectGeographic:#{item})"
|
55
58
|
end
|
56
59
|
end
|
60
|
+
|
57
61
|
if value.has_key?('publisher_facet')
|
58
62
|
subj_list = value['publisher_facet']
|
59
63
|
subj_list.each do |item|
|
60
64
|
@Actions.push "addfacetfilter(Publisher:#{item})"
|
61
65
|
end
|
62
66
|
end
|
67
|
+
|
63
68
|
if value.has_key?('journal_facet')
|
64
69
|
subj_list = value['journal_facet']
|
65
70
|
subj_list.each do |item|
|
66
71
|
@Actions.push "addfacetfilter(Journal:#{item})"
|
67
72
|
end
|
68
73
|
end
|
74
|
+
|
69
75
|
if value.has_key?('category_facet')
|
70
76
|
subj_list = value['category_facet']
|
71
77
|
subj_list.each do |item|
|
72
78
|
@Actions.push "addfacetfilter(Category:#{item})"
|
73
79
|
end
|
74
80
|
end
|
81
|
+
|
75
82
|
if value.has_key?('content_provider_facet')
|
76
83
|
subj_list = value['content_provider_facet']
|
77
84
|
subj_list.each do |item|
|
78
85
|
@Actions.push "addfacetfilter(ContentProvider:#{item})"
|
79
86
|
end
|
80
87
|
end
|
88
|
+
|
81
89
|
if value.has_key?('library_location_facet')
|
82
90
|
subj_list = value['library_location_facet']
|
83
91
|
subj_list.each do |item|
|
84
92
|
@Actions.push "addfacetfilter(LocationLibrary:#{item})"
|
85
93
|
end
|
86
94
|
end
|
95
|
+
|
87
96
|
if value.has_key?('search_limiters')
|
88
|
-
|
89
|
-
|
97
|
+
_list = value['search_limiters']
|
98
|
+
_list.each do |item|
|
90
99
|
if item == 'Full Text'
|
91
100
|
@Actions.push "addlimiter(FT:y)"
|
92
101
|
end
|
@@ -99,6 +108,34 @@ module EBSCO
|
|
99
108
|
end
|
100
109
|
end
|
101
110
|
|
111
|
+
if value.has_key?('pub_date_facet')
|
112
|
+
_list = value['pub_date_facet']
|
113
|
+
_this_year = Date.today.year
|
114
|
+
_this_month = Date.today.month
|
115
|
+
_list.each do |item|
|
116
|
+
if item == 'This year'
|
117
|
+
_range = _this_year.to_s + '-01/' + _this_year.to_s + '-' + _this_month.to_s
|
118
|
+
@Actions.push "addlimiter(DT1:#{_range})"
|
119
|
+
end
|
120
|
+
if item == 'Last 3 years'
|
121
|
+
_range = (_this_year-3).to_s + '-' + _this_month.to_s + '/' + _this_year.to_s + '-' + _this_month.to_s
|
122
|
+
@Actions.push "addlimiter(DT1:#{_range})"
|
123
|
+
end
|
124
|
+
if item == 'Last 10 years'
|
125
|
+
_range = (_this_year-10).to_s + '-' + _this_month.to_s + '/' + _this_year.to_s + '-' + _this_month.to_s
|
126
|
+
@Actions.push "addlimiter(DT1:#{_range})"
|
127
|
+
end
|
128
|
+
if item == 'Last 50 years'
|
129
|
+
_range = (_this_year-50).to_s + '-' + _this_month.to_s + '/' + _this_year.to_s + '-' + _this_month.to_s
|
130
|
+
@Actions.push "addlimiter(DT1:#{_range})"
|
131
|
+
end
|
132
|
+
if item == 'More than 50 years ago'
|
133
|
+
_range = '0000-01/' + (_this_year-50).to_s + '-12'
|
134
|
+
@Actions.push "addlimiter(DT1:#{_range})"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
102
139
|
else
|
103
140
|
|
104
141
|
end
|
data/lib/ebsco/eds/record.rb
CHANGED
@@ -22,7 +22,7 @@ module EBSCO
|
|
22
22
|
if results_record.key? 'Record'
|
23
23
|
@record = results_record['Record'] # single record returned by retrieve api
|
24
24
|
else
|
25
|
-
@record = results_record
|
25
|
+
@record = results_record # set of records returned by search api
|
26
26
|
end
|
27
27
|
|
28
28
|
@items = @record.fetch('Items', {})
|
@@ -79,7 +79,7 @@ module EBSCO
|
|
79
79
|
# The title.
|
80
80
|
def title
|
81
81
|
_retval = get_item_data_by_name('Title') || bib_title
|
82
|
-
#
|
82
|
+
# TODO: make this configurable
|
83
83
|
if _retval.nil?
|
84
84
|
_retval = 'This title is unavailable for guests, please login to see more information.'
|
85
85
|
end
|
@@ -812,6 +812,9 @@ module EBSCO
|
|
812
812
|
if cover_medium_url
|
813
813
|
hash['cover_medium_url'] = cover_medium_url
|
814
814
|
end
|
815
|
+
if all_links
|
816
|
+
hash['links'] = all_links
|
817
|
+
end
|
815
818
|
hash
|
816
819
|
end
|
817
820
|
|
data/lib/ebsco/eds/results.rb
CHANGED
@@ -121,6 +121,7 @@ module EBSCO
|
|
121
121
|
category_facet = solr_facets('Category')
|
122
122
|
content_provider_facet = solr_facets('ContentProvider')
|
123
123
|
library_location_facet = solr_facets('LocationLibrary')
|
124
|
+
pub_date_facet = solr_pub_date_facets
|
124
125
|
facet = true
|
125
126
|
|
126
127
|
# solr response
|
@@ -149,6 +150,7 @@ module EBSCO
|
|
149
150
|
'format' => format,
|
150
151
|
'language_facet' => language_facet,
|
151
152
|
'subject_topic_facet' => subject_topic_facet,
|
153
|
+
'pub_date_facet' => pub_date_facet,
|
152
154
|
'publisher_facet' => publisher_facet,
|
153
155
|
'journal_facet' => journal_facet,
|
154
156
|
'geographic_facet' => geographic_facet,
|
@@ -161,6 +163,24 @@ module EBSCO
|
|
161
163
|
|
162
164
|
end
|
163
165
|
|
166
|
+
# Publication date facets:
|
167
|
+
# - This year
|
168
|
+
# - Last 3 years
|
169
|
+
# - Last 10 years
|
170
|
+
# - Last 50 years
|
171
|
+
# - More than 50 years ago
|
172
|
+
def solr_pub_date_facets
|
173
|
+
pub_date_facets = []
|
174
|
+
if stat_total_hits.to_i > 0
|
175
|
+
pub_date_facets.push('This year').push('')
|
176
|
+
pub_date_facets.push('Last 3 years').push('')
|
177
|
+
pub_date_facets.push('Last 10 years').push('')
|
178
|
+
pub_date_facets.push('Last 50 years').push('')
|
179
|
+
pub_date_facets.push('More than 50 years ago').push('')
|
180
|
+
end
|
181
|
+
pub_date_facets
|
182
|
+
end
|
183
|
+
|
164
184
|
# Translate limiters found in calls to Info endpoint into solr facet fields if they are turned on
|
165
185
|
def solr_search_limiters
|
166
186
|
search_limiters = []
|
data/lib/ebsco/eds/session.rb
CHANGED
@@ -108,16 +108,24 @@ module EBSCO
|
|
108
108
|
@auth_token = create_auth_token
|
109
109
|
end
|
110
110
|
|
111
|
-
if options.
|
111
|
+
if options.key? :session_token
|
112
112
|
@session_token = options[:session_token]
|
113
113
|
else
|
114
114
|
@session_token = create_session_token
|
115
115
|
end
|
116
116
|
|
117
|
-
@info
|
117
|
+
@info ||= EBSCO::EDS::Info.new(do_request(:get, path: INFO_URL))
|
118
118
|
@current_page = 0
|
119
119
|
@search_options = nil
|
120
120
|
|
121
|
+
# DEBUG
|
122
|
+
# if options.key? :caller
|
123
|
+
# puts 'CREATE SESSION CALLER: ' + options[:caller].inspect
|
124
|
+
# puts 'CALLER OPTIONS: ' + options.inspect
|
125
|
+
# end
|
126
|
+
# puts 'AUTH TOKEN: ' + @auth_token.inspect
|
127
|
+
# puts 'SESSION TOKEN: ' + @session_token.inspect
|
128
|
+
|
121
129
|
end
|
122
130
|
|
123
131
|
# :category: Search & Retrieve Methods
|
@@ -208,9 +216,11 @@ module EBSCO
|
|
208
216
|
# record = session.retrieve({dbid: 'asn', an: '108974507'})
|
209
217
|
#
|
210
218
|
def retrieve(dbid:, an:, highlight: nil, ebook: 'ebook-pdf')
|
211
|
-
payload = {:
|
219
|
+
payload = { DbId: dbid, An: an, HighlightTerms: highlight, EbookPreferredFormat: ebook }
|
212
220
|
retrieve_response = do_request(:post, path: RETRIEVE_URL, payload: payload)
|
213
|
-
EBSCO::EDS::Record.new(retrieve_response)
|
221
|
+
record = EBSCO::EDS::Record.new(retrieve_response)
|
222
|
+
# puts 'RECORD: ' + record.pretty_inspect
|
223
|
+
record
|
214
224
|
end
|
215
225
|
|
216
226
|
def solr_retrieve_list(list: [], highlight: nil, ebook: 'ebook-pdf')
|
@@ -558,10 +568,10 @@ module EBSCO
|
|
558
568
|
end
|
559
569
|
end
|
560
570
|
resp.body
|
561
|
-
rescue
|
571
|
+
rescue StandardError => e
|
562
572
|
if e.respond_to? 'fault'
|
563
573
|
error_code = e.fault[:error_body]['ErrorNumber'] || e.fault[:error_body]['ErrorCode']
|
564
|
-
|
574
|
+
unless error_code.nil?
|
565
575
|
case error_code
|
566
576
|
# session token missing
|
567
577
|
when '108', '109'
|
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.0.
|
4
|
+
version: 0.0.6.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-03-
|
12
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|