ebsco-eds 0.0.2.pre → 0.0.3.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/ebsco/eds/options.rb +6 -2
- data/lib/ebsco/eds/record.rb +112 -32
- data/lib/ebsco/eds/results.rb +18 -2
- data/lib/ebsco/eds/session.rb +66 -10
- 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: 93c8529d7f55e30b625581f9074b9d27ff617cec
|
4
|
+
data.tar.gz: aa1aadfb6d45692fe10f1078de4be8dbd8869077
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8943fd15a565759b35c94e7fb1e16a98c3738096ab7bfa536513ffa43fb7ddb862010d08b5202466585b920d7c07def39c115f25f7b4431353809d14fc1af11f
|
7
|
+
data.tar.gz: ba2907cf2de2004c6a026f568395144aff62f83b6fe166d76efcd9cb0c680eac0efee8bc84f96b79172c63d517639a1396c53b227361fc31f444fab30ff94bd4
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ A Ruby interface to the EBSCO Discovery Services API.
|
|
5
5
|
[![Build Status](https://travis-ci.org/ebsco/edsapi-ruby.svg)](https://travis-ci.org/ebsco/edsapi-ruby)
|
6
6
|
[![codecov](https://codecov.io/gh/ebsco/edsapi-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/ebsco/edsapi-ruby/branch/master)
|
7
7
|
[![Dependency Status](https://gemnasium.com/badges/github.com/ebsco/edsapi-ruby.svg)](https://gemnasium.com/github.com/ebsco/edsapi-ruby)
|
8
|
-
[![Gem Version](https://
|
8
|
+
[![Gem Version](https://img.shields.io/gem/v/ebsco-eds.svg?style=flat)](http://rubygems.org/gems/ebsco-eds)
|
9
9
|
[![Gitter](https://badges.gitter.im/ebsco/edsapi-ruby.svg)](https://gitter.im/ebsco/edsapi-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
10
10
|
|
11
11
|
## Dependencies
|
data/lib/ebsco/eds/options.rb
CHANGED
@@ -22,6 +22,11 @@ module EBSCO
|
|
22
22
|
when :actions
|
23
23
|
add_actions(options[:actions], info)
|
24
24
|
|
25
|
+
# SOLR: Need to add page actions whenever other actions are present since the other actions
|
26
|
+
# will always reset the page to 1 even though a PageNumber is present in RetrievalCriteria.
|
27
|
+
when 'page'
|
28
|
+
@Actions.push "GoToPage(#{value.to_i})"
|
29
|
+
|
25
30
|
# solr facet translation
|
26
31
|
# "f"=>{"format"=>["eBooks"]}
|
27
32
|
when 'f'
|
@@ -140,7 +145,7 @@ module EBSCO
|
|
140
145
|
include JSONable
|
141
146
|
attr_accessor :Queries, :SearchMode, :IncludeFacets, :FacetFilters, :Limiters, :Sort, :PublicationId,
|
142
147
|
:RelatedContent, :AutoSuggest, :Expanders
|
143
|
-
|
148
|
+
|
144
149
|
def initialize(options = {}, info)
|
145
150
|
|
146
151
|
# defaults
|
@@ -352,7 +357,6 @@ module EBSCO
|
|
352
357
|
# ====================================================================================
|
353
358
|
when :page_number, 'page'
|
354
359
|
@PageNumber = value.to_i
|
355
|
-
# puts 'NEW PAGE: ' + @PageNumber.inspect
|
356
360
|
# solr starts at page 0
|
357
361
|
when 'start'
|
358
362
|
@PageNumber = value.to_i + 1
|
data/lib/ebsco/eds/record.rb
CHANGED
@@ -77,7 +77,11 @@ module EBSCO
|
|
77
77
|
|
78
78
|
# The title.
|
79
79
|
def title
|
80
|
-
get_item_data_by_name('Title') || bib_title
|
80
|
+
_title = get_item_data_by_name('Title') || bib_title
|
81
|
+
if _title.nil?
|
82
|
+
_title = 'This title is unavailable for guests, please login to see more information.'
|
83
|
+
end
|
84
|
+
_title
|
81
85
|
end
|
82
86
|
|
83
87
|
# The source title (e.g., Journal)
|
@@ -553,23 +557,43 @@ module EBSCO
|
|
553
557
|
# ====================================================================================
|
554
558
|
|
555
559
|
def bib_title
|
556
|
-
@bib_entity
|
560
|
+
if @bib_entity
|
561
|
+
@bib_entity.fetch('Titles', {}).find{|item| item['Type'] == 'main'}['TitleFull']
|
562
|
+
else
|
563
|
+
nil
|
564
|
+
end
|
557
565
|
end
|
558
566
|
|
559
567
|
def bib_authors
|
560
|
-
@bib_relationships
|
568
|
+
if @bib_relationships
|
569
|
+
@bib_relationships.deep_find('NameFull').join('; ')
|
570
|
+
else
|
571
|
+
nil
|
572
|
+
end
|
561
573
|
end
|
562
574
|
|
563
575
|
def bib_authors_list
|
564
|
-
@bib_relationships
|
576
|
+
if @bib_relationships
|
577
|
+
@bib_relationships.deep_find('NameFull')
|
578
|
+
else
|
579
|
+
nil
|
580
|
+
end
|
565
581
|
end
|
566
582
|
|
567
583
|
def bib_subjects
|
568
|
-
@bib_entity
|
584
|
+
if @bib_entity
|
585
|
+
@bib_entity.deep_find('SubjectFull')
|
586
|
+
else
|
587
|
+
nil
|
588
|
+
end
|
569
589
|
end
|
570
590
|
|
571
591
|
def bib_languages
|
572
|
-
@bib_entity
|
592
|
+
if @bib_entity
|
593
|
+
@bib_entity.fetch('Languages', {}).map{|lang| lang['Text']}
|
594
|
+
else
|
595
|
+
nil
|
596
|
+
end
|
573
597
|
end
|
574
598
|
|
575
599
|
# def bib_pages
|
@@ -577,15 +601,27 @@ module EBSCO
|
|
577
601
|
# end
|
578
602
|
|
579
603
|
def bib_page_count
|
580
|
-
@bib_entity
|
604
|
+
if @bib_entity
|
605
|
+
@bib_entity.deep_find('PageCount').first
|
606
|
+
else
|
607
|
+
nil
|
608
|
+
end
|
581
609
|
end
|
582
610
|
|
583
611
|
def bib_page_start
|
584
|
-
@bib_entity
|
612
|
+
if @bib_entity
|
613
|
+
@bib_entity.deep_find('StartPage').first
|
614
|
+
else
|
615
|
+
nil
|
616
|
+
end
|
585
617
|
end
|
586
618
|
|
587
619
|
def bib_doi
|
588
|
-
@bib_entity
|
620
|
+
if @bib_entity
|
621
|
+
@bib_entity.fetch('Identifiers',{}).find{|item| item['Type'] == 'doi'}['Value']
|
622
|
+
else
|
623
|
+
nil
|
624
|
+
end
|
589
625
|
end
|
590
626
|
|
591
627
|
# ====================================================================================
|
@@ -593,51 +629,79 @@ module EBSCO
|
|
593
629
|
# ====================================================================================
|
594
630
|
|
595
631
|
def bib_source_title
|
596
|
-
@bib_part
|
632
|
+
if @bib_part
|
633
|
+
@bib_part.fetch('BibEntity',{}).fetch('Titles',{}).find{|item| item['Type'] == 'main'}['TitleFull']
|
634
|
+
else
|
635
|
+
nil
|
636
|
+
end
|
597
637
|
end
|
598
638
|
|
599
639
|
def bib_issn_print
|
600
|
-
@bib_part
|
640
|
+
if @bib_part
|
641
|
+
@bib_part.fetch('BibEntity',{}).fetch('Identifiers',{}).find{|item| item['Type'] == 'issn-print'}['Value']
|
642
|
+
else
|
643
|
+
nil
|
644
|
+
end
|
601
645
|
end
|
602
646
|
|
603
647
|
def bib_issn_electronic
|
604
|
-
@bib_part
|
648
|
+
if @bib_part
|
649
|
+
@bib_part.fetch('BibEntity',{}).fetch('Identifiers',{}).find{|item| item['Type'] == 'issn-electronic'}['Value']
|
650
|
+
else
|
651
|
+
nil
|
652
|
+
end
|
605
653
|
end
|
606
654
|
|
607
655
|
def bib_issns
|
608
656
|
issns = []
|
609
|
-
@bib_part
|
610
|
-
|
611
|
-
|
657
|
+
if @bib_part
|
658
|
+
@bib_part.fetch('BibEntity',{}).fetch('Identifiers',{}).each do |id|
|
659
|
+
if id['Type'].include?('issn') && !id['Type'].include?('locals')
|
660
|
+
issns.push(id['Value'])
|
661
|
+
end
|
612
662
|
end
|
613
663
|
end
|
614
664
|
issns
|
615
665
|
end
|
616
666
|
|
617
667
|
def bib_isbn_print
|
618
|
-
@bib_part
|
668
|
+
if @bib_part
|
669
|
+
@bib_part.fetch('BibEntity',{}).fetch('Identifiers',{}).find{|item| item['Type'] == 'isbn-print'}['Value']
|
670
|
+
else
|
671
|
+
nil
|
672
|
+
end
|
619
673
|
end
|
620
674
|
|
621
675
|
def bib_isbn_electronic
|
622
|
-
@bib_part
|
676
|
+
if @bib_part
|
677
|
+
@bib_part.fetch('BibEntity',{}).fetch('Identifiers',{}).find{|item| item['Type'] == 'isbn-electronic'}['Value']
|
678
|
+
else
|
679
|
+
nil
|
680
|
+
end
|
623
681
|
end
|
624
682
|
|
625
683
|
# todo: make this generic and take an optional parameter for type
|
626
684
|
def bib_isbns
|
627
685
|
isbns = []
|
628
|
-
@bib_part
|
629
|
-
|
630
|
-
|
686
|
+
if @bib_part
|
687
|
+
@bib_part.fetch('BibEntity',{}).fetch('Identifiers',{}).each do |id|
|
688
|
+
if id['Type'].include?('isbn') && !id['Type'].include?('locals')
|
689
|
+
isbns.push(id['Value'])
|
690
|
+
end
|
631
691
|
end
|
632
692
|
end
|
633
693
|
isbns
|
634
694
|
end
|
635
695
|
|
636
696
|
def bib_publication_date
|
637
|
-
|
638
|
-
|
639
|
-
if _date
|
640
|
-
_date
|
697
|
+
if @bib_part
|
698
|
+
_date = @bib_part.fetch('BibEntity',{}).fetch('Dates',{}).find{|item| item['Type'] == 'published'}
|
699
|
+
if _date
|
700
|
+
if _date.has_key?('Y') && _date.has_key?('M') && _date.has_key?('D')
|
701
|
+
_date['Y'] + '-' + _date['M'] + '-' + _date['D']
|
702
|
+
else
|
703
|
+
nil
|
704
|
+
end
|
641
705
|
else
|
642
706
|
nil
|
643
707
|
end
|
@@ -647,29 +711,45 @@ module EBSCO
|
|
647
711
|
end
|
648
712
|
|
649
713
|
def bib_publication_year
|
650
|
-
|
651
|
-
|
652
|
-
|
714
|
+
if @bib_part
|
715
|
+
_date = @bib_part.fetch('BibEntity',{}).fetch('Dates',{}).find{|item| item['Type'] == 'published'}
|
716
|
+
if _date
|
717
|
+
_date.has_key?('Y') ? _date['Y'] : nil
|
718
|
+
else
|
719
|
+
nil
|
720
|
+
end
|
653
721
|
else
|
654
722
|
nil
|
655
723
|
end
|
656
724
|
end
|
657
725
|
|
658
726
|
def bib_publication_month
|
659
|
-
|
660
|
-
|
661
|
-
|
727
|
+
if @bib_part
|
728
|
+
_date = @bib_part.fetch('BibEntity',{}).fetch('Dates',{}).find{|item| item['Type'] == 'published'}
|
729
|
+
if _date
|
730
|
+
_date.has_key?('M') ? _date['M'] : nil
|
731
|
+
else
|
732
|
+
nil
|
733
|
+
end
|
662
734
|
else
|
663
735
|
nil
|
664
736
|
end
|
665
737
|
end
|
666
738
|
|
667
739
|
def bib_volume
|
668
|
-
@bib_part
|
740
|
+
if @bib_part
|
741
|
+
@bib_part.fetch('BibEntity',{}).fetch('Numbering',{}).find{|item| item['Type'] == 'volume'}['Value']
|
742
|
+
else
|
743
|
+
nil
|
744
|
+
end
|
669
745
|
end
|
670
746
|
|
671
747
|
def bib_issue
|
672
|
-
@bib_part
|
748
|
+
if @bib_part
|
749
|
+
@bib_part.fetch('BibEntity',{}).fetch('Numbering',{}).find{|item| item['Type'] == 'issue'}['Value']
|
750
|
+
else
|
751
|
+
nil
|
752
|
+
end
|
673
753
|
end
|
674
754
|
|
675
755
|
# this is used to generate solr fields
|
data/lib/ebsco/eds/results.rb
CHANGED
@@ -22,15 +22,31 @@ module EBSCO
|
|
22
22
|
|
23
23
|
# Creates search results from the \EDS API search response. It includes information about the results and a list
|
24
24
|
# of Record items.
|
25
|
-
def initialize(search_results, additional_limiters = {})
|
25
|
+
def initialize(search_results, additional_limiters = {}, raw_options = {})
|
26
26
|
|
27
27
|
@results = search_results
|
28
28
|
@limiters = additional_limiters
|
29
|
+
@raw_options = raw_options
|
29
30
|
|
30
31
|
# convert all results to a list of records
|
31
32
|
@records = []
|
32
33
|
if stat_total_hits > 0
|
33
|
-
@results['SearchResult']['Data']['Records'].each { |record|
|
34
|
+
@results['SearchResult']['Data']['Records'].each { |record|
|
35
|
+
|
36
|
+
@records.push(EBSCO::EDS::Record.new(record))
|
37
|
+
|
38
|
+
# # records hidden in guest mode
|
39
|
+
# if record['Header']['AccessLevel']
|
40
|
+
# if record['Header']['AccessLevel'].to_i > 1
|
41
|
+
# @records.push(EBSCO::EDS::Record.new(record))
|
42
|
+
# else
|
43
|
+
# @records.push(EBSCO::EDS::Record.new(record))
|
44
|
+
# end
|
45
|
+
# else
|
46
|
+
# @records.push(EBSCO::EDS::Record.new(record))
|
47
|
+
# end
|
48
|
+
|
49
|
+
}
|
34
50
|
end
|
35
51
|
|
36
52
|
# create a special list of research starter records
|
data/lib/ebsco/eds/session.rb
CHANGED
@@ -59,6 +59,7 @@ module EBSCO
|
|
59
59
|
|
60
60
|
@session_token = ''
|
61
61
|
@auth_token = ''
|
62
|
+
@guest = 'y'
|
62
63
|
|
63
64
|
if options.has_key? :user
|
64
65
|
@user = options[:user]
|
@@ -148,15 +149,32 @@ module EBSCO
|
|
148
149
|
# results = session.search({query: 'volcano', results_per_page: 1, publication_id: 'eric', include_facets: false})
|
149
150
|
def search(options = {}, add_actions = false)
|
150
151
|
|
151
|
-
#
|
152
|
-
if
|
153
|
-
@search_options
|
152
|
+
# use existing/updated SearchOptions
|
153
|
+
if options.empty?
|
154
|
+
if @search_options.nil?
|
155
|
+
@search_results = EBSCO::EDS::Results.new(empty_results)
|
156
|
+
else
|
157
|
+
_response = do_request(:post, path: SEARCH_URL, payload: @search_options)
|
158
|
+
@search_results = EBSCO::EDS::Results.new(_response, @info.available_limiters, options)
|
159
|
+
@current_page = @search_results.page_number
|
160
|
+
@search_results
|
161
|
+
end
|
162
|
+
else
|
163
|
+
# Only perform a search when there are query terms since certain EDS profiles will throw errors when
|
164
|
+
# given empty queries
|
165
|
+
if (options.keys & %w[query q]).any? || options.has_key?(:query)
|
166
|
+
# create/recreate the search options if nil or not passing actions
|
167
|
+
if @search_options.nil? || !add_actions
|
168
|
+
@search_options = EBSCO::EDS::Options.new(options, @info)
|
169
|
+
end
|
170
|
+
_response = do_request(:post, path: SEARCH_URL, payload: @search_options)
|
171
|
+
@search_results = EBSCO::EDS::Results.new(_response, @info.available_limiters, options)
|
172
|
+
@current_page = @search_results.page_number
|
173
|
+
@search_results
|
174
|
+
else
|
175
|
+
@search_results = EBSCO::EDS::Results.new(empty_results)
|
176
|
+
end
|
154
177
|
end
|
155
|
-
#puts JSON.pretty_generate(@search_options)
|
156
|
-
_response = do_request(:post, path: SEARCH_URL, payload: @search_options)
|
157
|
-
@search_results = EBSCO::EDS::Results.new(_response, @info.available_limiters)
|
158
|
-
@current_page = @search_results.page_number
|
159
|
-
@search_results
|
160
178
|
end
|
161
179
|
|
162
180
|
# :category: Search & Retrieve Methods
|
@@ -244,8 +262,8 @@ module EBSCO
|
|
244
262
|
# ==== Examples
|
245
263
|
# results = session.add_actions('addfacetfilter(SubjectGeographic:massachusetts)')
|
246
264
|
def add_actions(actions)
|
247
|
-
|
248
|
-
search(
|
265
|
+
@search_options.add_actions(actions, @info)
|
266
|
+
search()
|
249
267
|
end
|
250
268
|
|
251
269
|
# :category: Setter Methods
|
@@ -629,6 +647,44 @@ module EBSCO
|
|
629
647
|
var.nil? || var.respond_to?(:length) && var.length == 0
|
630
648
|
end
|
631
649
|
|
650
|
+
# used to reliably create empty results when there are no search terms provided
|
651
|
+
def empty_results
|
652
|
+
{
|
653
|
+
'SearchRequest'=>
|
654
|
+
{
|
655
|
+
'SearchCriteria'=>
|
656
|
+
{
|
657
|
+
'Queries'=>nil,
|
658
|
+
'SearchMode'=>'',
|
659
|
+
'IncludeFacets'=>'y',
|
660
|
+
'Sort'=>'relevance',
|
661
|
+
'AutoSuggest'=>'n'
|
662
|
+
},
|
663
|
+
'RetrievalCriteria'=>
|
664
|
+
{
|
665
|
+
'View'=>'brief',
|
666
|
+
'ResultsPerPage'=>20,
|
667
|
+
'Highlight'=>'y'
|
668
|
+
},
|
669
|
+
'SearchCriteriaWithActions'=>
|
670
|
+
{
|
671
|
+
'QueriesWithAction'=>nil
|
672
|
+
}
|
673
|
+
},
|
674
|
+
'SearchResult'=>
|
675
|
+
{
|
676
|
+
'Statistics'=>
|
677
|
+
{
|
678
|
+
'TotalHits'=>0,
|
679
|
+
'TotalSearchTime'=>62,
|
680
|
+
'Databases'=>[]
|
681
|
+
},
|
682
|
+
'Data'=> {'RecordFormat'=>'EP Display'},
|
683
|
+
'AvailableCriteria'=>{'DateRange'=>{'MinDate'=>'0001-01', 'MaxDate'=>'0001-01'}}
|
684
|
+
}
|
685
|
+
}
|
686
|
+
end
|
687
|
+
|
632
688
|
end
|
633
689
|
|
634
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.0.
|
4
|
+
version: 0.0.3.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-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|