ebsco-eds 0.0.1.pre → 0.0.2.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62e553aee7daa0edd9d2d8090dc1e26140970f10
4
- data.tar.gz: a52fcb3d33dfc8e7bb41a5046c49fb031fb9d92c
3
+ metadata.gz: 7caadfc342d7546949d09b98622721f2cf462a6c
4
+ data.tar.gz: 2f14eb30a58b209d49baeff48b8a73ec1b79f6c7
5
5
  SHA512:
6
- metadata.gz: def2d87b7779bf26805eca8978d464997ede09095140cc83b16e179282d4dd49c396ef45c752d5e93edfb44f79d5137c34e36e3760c2dfbcf6d2d239564dde71
7
- data.tar.gz: 76e6cbc75bffbca076c435725c5e5fab389b1712c5e4504fb621bf4f4707bc49db2ba12cb0ac6676c812bf1034974170e6ee05378a7bf9932dd1aaa02347389a
6
+ metadata.gz: 2b49a04e893451ff0fd50864507060e12057cd68d3912757a1242b8daa49310ebe37b68aa5e955e861991cdf8dd9b741dec56ba34a4bba8e5112ecd4189bf532
7
+ data.tar.gz: 35abec0b5ba811a3542857626f4e639ee17f22726d4e5bef935b6941e24bb03d200750e5f84b2c1f91644473100fd1adf86749230cf6a096865f9cdd86eb7e47
data/.env.test CHANGED
@@ -1,12 +1,6 @@
1
- EDS_PROFILE=eds-api
2
- EDS_USER=billmckinn
3
- EDS_PASS=4n~r1me86y
1
+ EDS_PROFILE=edsapi
2
+ EDS_USER=user
3
+ EDS_PASS=secret
4
4
  EDS_AUTH=user
5
5
  EDS_GUEST=n
6
- EDS_ORG=none
7
-
8
- # bmckinney repo
9
- # CODECOV_TOKEN=cfc86a29-02eb-43f3-9903-7fd46f9a510d
10
-
11
- # ebsco repo
12
- CODECOV_TOKEN=d72eb958-f826-40eb-8112-e77a965dc94e
6
+ EDS_ORG=none
data/README.md CHANGED
@@ -5,6 +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://badge.fury.io/rb/ebsco-eds.svg)](https://badge.fury.io/rb/ebsco-eds)
8
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)
9
10
 
10
11
  ## Dependencies
@@ -31,6 +32,7 @@ Or install it yourself as:
31
32
 
32
33
  - [Configuration](https://github.com/ebsco/edsapi-ruby/wiki/Configuration)
33
34
  - [Quick Start](https://github.com/ebsco/edsapi-ruby/wiki/Quick-Start)
35
+ - [Blacklight Support](https://github.com/ebsco/edsapi-ruby/wiki/Solr-and-Blacklight-Support)
34
36
 
35
37
  ### Models
36
38
 
@@ -43,8 +43,56 @@ module EBSCO
43
43
  @Actions.push "addfacetfilter(SubjectEDS:#{item})"
44
44
  end
45
45
  end
46
-
47
- puts 'ACTIONS: ' + @Actions.inspect
46
+ if value.has_key?('geographic_facet')
47
+ subj_list = value['geographic_facet']
48
+ subj_list.each do |item|
49
+ @Actions.push "addfacetfilter(SubjectGeographic:#{item})"
50
+ end
51
+ end
52
+ if value.has_key?('publisher_facet')
53
+ subj_list = value['publisher_facet']
54
+ subj_list.each do |item|
55
+ @Actions.push "addfacetfilter(Publisher:#{item})"
56
+ end
57
+ end
58
+ if value.has_key?('journal_facet')
59
+ subj_list = value['journal_facet']
60
+ subj_list.each do |item|
61
+ @Actions.push "addfacetfilter(Journal:#{item})"
62
+ end
63
+ end
64
+ if value.has_key?('category_facet')
65
+ subj_list = value['category_facet']
66
+ subj_list.each do |item|
67
+ @Actions.push "addfacetfilter(Category:#{item})"
68
+ end
69
+ end
70
+ if value.has_key?('content_provider_facet')
71
+ subj_list = value['content_provider_facet']
72
+ subj_list.each do |item|
73
+ @Actions.push "addfacetfilter(ContentProvider:#{item})"
74
+ end
75
+ end
76
+ if value.has_key?('library_location_facet')
77
+ subj_list = value['library_location_facet']
78
+ subj_list.each do |item|
79
+ @Actions.push "addfacetfilter(LocationLibrary:#{item})"
80
+ end
81
+ end
82
+ if value.has_key?('search_limiters')
83
+ subj_list = value['search_limiters']
84
+ subj_list.each do |item|
85
+ if item == 'Full Text'
86
+ @Actions.push "addlimiter(FT:y)"
87
+ end
88
+ if item == 'Peer Reviewed'
89
+ @Actions.push "addlimiter(RV:y)"
90
+ end
91
+ if item == 'Available in Library Collection'
92
+ @Actions.push "addlimiter(FT1:y)"
93
+ end
94
+ end
95
+ end
48
96
 
49
97
  else
50
98
 
@@ -260,7 +308,6 @@ module EBSCO
260
308
 
261
309
  end
262
310
 
263
-
264
311
  end
265
312
 
266
313
  end
@@ -323,14 +370,12 @@ module EBSCO
323
370
  @Highlight = 'n'
324
371
  end
325
372
 
326
-
327
373
  else
328
374
 
329
375
  end
330
376
 
331
377
  end
332
378
 
333
-
334
379
  end
335
380
 
336
381
  end
@@ -672,14 +672,55 @@ module EBSCO
672
672
  @bib_part.fetch('BibEntity',{}).fetch('Numbering',{}).find{|item| item['Type'] == 'issue'}['Value']
673
673
  end
674
674
 
675
+ # this is used to generate solr fields
675
676
  def to_hash
676
677
  hash = {}
677
- hash['id'] = database_id + '-' + accession_number
678
- hash['title_display'] = title.gsub('<highlight>', '').gsub('</highlight>', '')
679
- hash['pub_date'] = publication_year
678
+ if database_id && accession_number
679
+ safe_an = accession_number.gsub(/\./,'_')
680
+ hash['id'] = database_id + '__' + safe_an
681
+ end
682
+ if !title.nil?
683
+ hash['title_display'] = title.gsub('<highlight>', '').gsub('</highlight>', '')
684
+ end
685
+ if publication_year
686
+ hash['pub_date'] = publication_year
687
+ end
688
+ if authors
689
+ hash['author_display'] = authors.to_s
690
+ end
691
+ if publication_type
692
+ hash['format'] = publication_type.to_s
693
+ end
694
+ if languages
695
+ if languages.kind_of?(Array)
696
+ hash['language_facet'] = languages.join(', ')
697
+ else
698
+ hash['language_facet'] = languages.to_s
699
+ end
700
+ end
701
+ if publisher_info
702
+ hash['pub_info'] = publisher_info
703
+ end
704
+ if abstract
705
+ hash['abstract'] = abstract
706
+ end
680
707
  hash
681
708
  end
682
709
 
710
+ def to_solr
711
+ # solr response
712
+ {
713
+ 'responseHeader' => {
714
+ 'status' => 0
715
+ },
716
+ 'response' => {
717
+ 'numFound' => 1,
718
+ 'start' => 0,
719
+ 'docs' => [to_hash]
720
+ }
721
+ }
722
+ end
723
+
683
724
  end # Class Record
684
725
  end # Module EDS
685
726
  end # Module EBSCO
@@ -22,9 +22,10 @@ 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)
25
+ def initialize(search_results, additional_limiters = {})
26
26
 
27
27
  @results = search_results
28
+ @limiters = additional_limiters
28
29
 
29
30
  # convert all results to a list of records
30
31
  @records = []
@@ -79,7 +80,7 @@ module EBSCO
79
80
  # todo: add solr hl.tag.pre and hl.tag.post to retrieval criteria
80
81
  if retrieval_criteria.fetch('Highlight',{}) == 'y'
81
82
  hl_title = record.title.gsub('&lt;highlight&gt;', '<em>').gsub('&lt;/highlight&gt;', '</em>')
82
- hl_hash.update({ record.database_id + '-' + record.accession_number => { 'title_display' => [hl_title]} })
83
+ hl_hash.update({ record.database_id + '__' + record.accession_number => { 'title_display' => [hl_title]} })
83
84
  #hl_hash.merge title_hl
84
85
  end
85
86
 
@@ -112,15 +113,42 @@ module EBSCO
112
113
  'facet_counts' =>
113
114
  {
114
115
  'facet_fields' => {
116
+ 'search_limiters' => solr_search_limiters,
115
117
  'format' => solr_facets('SourceType'),
116
118
  'language_facet' => solr_facets('Language'),
117
- 'subject_topic_facet' => solr_facets('SubjectEDS')
119
+ 'subject_topic_facet' => solr_facets('SubjectEDS'),
120
+ 'publisher_facet' => solr_facets('Publisher'),
121
+ 'journal_facet' => solr_facets('Journal'),
122
+ 'geographic_facet' => solr_facets('SubjectGeographic'),
123
+ 'category_facet' => solr_facets('Category'),
124
+ 'content_provider_facet' => solr_facets('ContentProvider'),
125
+ 'library_location_facet' => solr_facets('LocationLibrary')
118
126
  }
119
127
  }
120
128
  }
121
129
 
122
130
  end
123
131
 
132
+ # Translate limiters found in calls to Info endpoint into solr facet fields if they are turned on
133
+ def solr_search_limiters
134
+ search_limiters = []
135
+ if stat_total_hits.to_i > 0
136
+ _ft_limiter = @limiters.find{|item| item['Id'] == 'FT'}
137
+ if _ft_limiter['DefaultOn'] == 'y'
138
+ search_limiters.push('Full Text').push('')
139
+ end
140
+ _rv_limiter = @limiters.find{|item| item['Id'] == 'RV'}
141
+ if _rv_limiter['DefaultOn'] == 'y'
142
+ search_limiters.push('Peer Reviewed').push('')
143
+ end
144
+ _ft1_limiter = @limiters.find{|item| item['Id'] == 'FT1'}
145
+ if _ft1_limiter['DefaultOn'] == 'y'
146
+ search_limiters.push('Available in Library Collection').push('')
147
+ end
148
+ end
149
+ search_limiters
150
+ end
151
+
124
152
  # Total number of results found.
125
153
  def stat_total_hits
126
154
  _hits = @results.fetch('SearchResult',{}).fetch('Statistics',{}).fetch('TotalHits',{})
@@ -57,8 +57,8 @@ module EBSCO
57
57
  # }
58
58
  def initialize(options = {})
59
59
 
60
- @auth_token = ''
61
60
  @session_token = ''
61
+ @auth_token = ''
62
62
 
63
63
  if options.has_key? :user
64
64
  @user = options[:user]
@@ -100,8 +100,19 @@ module EBSCO
100
100
  end
101
101
 
102
102
  @max_retries = MAX_ATTEMPTS
103
- @auth_token = create_auth_token
104
- @session_token = create_session_token
103
+
104
+ if options.has_key? :auth_token
105
+ @auth_token = options[:auth_token]
106
+ else
107
+ @auth_token = create_auth_token
108
+ end
109
+
110
+ if options.has_key? :session_token
111
+ @session_token = options[:session_token]
112
+ else
113
+ @session_token = create_session_token
114
+ end
115
+
105
116
  @info = EBSCO::EDS::Info.new(do_request(:get, path: INFO_URL))
106
117
  @current_page = 0
107
118
  @search_options = nil
@@ -143,7 +154,7 @@ module EBSCO
143
154
  end
144
155
  #puts JSON.pretty_generate(@search_options)
145
156
  _response = do_request(:post, path: SEARCH_URL, payload: @search_options)
146
- @search_results = EBSCO::EDS::Results.new(_response)
157
+ @search_results = EBSCO::EDS::Results.new(_response, @info.available_limiters)
147
158
  @current_page = @search_results.page_number
148
159
  @search_results
149
160
  end
@@ -1,5 +1,5 @@
1
1
  module EBSCO
2
2
  module EDS
3
- VERSION = '0.0.1.pre'
3
+ VERSION = '0.0.2.pre'
4
4
  end
5
5
  end
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.1.pre
4
+ version: 0.0.2.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-03 00:00:00.000000000 Z
12
+ date: 2017-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday