median 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- median (0.0.2)
4
+ median (0.0.3)
5
5
  activesupport (~> 3.2.3)
6
6
  nokogiri (~> 1.5.2)
7
7
  savon (~> 0.9.9)
@@ -34,82 +34,15 @@ class Median::Primo::Record
34
34
  @links = Links.new(xml)
35
35
  end
36
36
 
37
- def dedub?
38
- self.id.present? ? self.id.downcase.start_with?('dedupmrg') : false
39
- end
40
-
41
- def local_resource?
42
- !online_resource?
43
- end
44
-
45
- def online_resource?
46
- online_resource_categories = ['online_resource', 'online resource', 'remote search resource', 'sfx resource']
47
- online_resource_categories.include?(self.delivery_category)
48
- end
49
-
50
- def versions?
51
- versions > 1
52
- end
53
-
54
- def series?
55
- type.try(:downcase) == 'serie' or delivery_category == 'structural metadata'
56
- end
57
-
58
- private
37
+ protected
59
38
 
60
39
  class Links
61
40
  include Median::XmlSupport
62
41
 
63
- field :openurl, xpath: './LINKS/openurl', process: :force_sfx_menu_language
42
+ field :openurl, xpath: './LINKS/openurl'
64
43
  field :backlink, xpath: './LINKS/backlink'
65
44
  field :thumbnail, xpath: './LINKS/thumbnail'
66
- field :resource_links, xpath: './LINKS/linktorsrc', multiple: true
67
-
68
- def filtered_resource_links
69
- filter_ezb_links(self.resource_links)
70
- end
71
-
72
- def default_resource_link
73
- filtered_resource_links.first
74
- end
75
-
76
- def resource_link?
77
- self.resource_links.present?
78
- end
79
-
80
-
81
- private
82
-
83
- def filter_ezb_links(links)
84
- ezb_link = get_ezb_link(links)
85
- ezb_link.present? ? [ezb_link] : links
86
- end
87
-
88
- def get_ezb_link(links)
89
- links.each do |link|
90
- return link if link.include? 'uni-regensburg.de/ezeit'
91
- end
92
- nil
93
- end
94
-
95
- def force_sfx_menu_language(openurl)
96
- openurl.gsub(/req\.language=.+&/, '') # remove the language setting to force thedefault
97
- end
45
+ field :resource_links, xpath: './/record/links/linktorsrc', multiple: true
98
46
  end
99
47
 
100
- #
101
- # GetIt links are broken in the SOAP API. The links always point to the first result.
102
- #
103
- #class GetItLinks < Array
104
- # def initialize(xml)
105
- # super()
106
- # nodes = xml.xpath('./GETIT')
107
- # nodes.each do |node|
108
- # #puts node.inspect
109
- # #self << {getit1: node.attribute('GetIt1').try(:value), getit2: node.attribute('GetIt2').try(:value)}
110
- # #puts self
111
- # end
112
- # end
113
- #end
114
-
115
48
  end
@@ -2,23 +2,22 @@ class Median::Primo::SearchRequest
2
2
 
3
3
  PRECISION_OPTIONS = {contains: 'contains', exact: 'exact', begins_with: 'begins_with'}
4
4
 
5
- def initialize(request_params)
5
+ def initialize(options)
6
6
  # set search term
7
- self.search_term = request_params[:q]
7
+ self.search_term = options[:search_term]
8
8
  # set the index field
9
- self.index_field = request_params[:if]
9
+ self.index_field = options[:index_field]
10
10
  # set the precision
11
- self.precision = request_params[:po]
11
+ self.precision = options[:precision]
12
12
  # page and page size
13
- self.page = request_params[:p]
14
- self.page_size = request_params[:ps]
13
+ self.page = options[:page]
14
+ self.page_size = options[:page_size]
15
15
  # set facets
16
- self.facets = request_params[:f]
17
- # doc id in case we do a fullview search
18
- # for a single record
19
- self.doc_id = request_params[:id]
20
- # search scope
21
- self.scope = request_params[:scope]
16
+ self.facets = options[:facets]
17
+ # doc id in case we do a fullview search for a single record
18
+ self.doc_id = options[:doc_id]
19
+ # search locations
20
+ self.locations = options[:locations]
22
21
  end
23
22
 
24
23
  # search term
@@ -74,10 +73,10 @@ class Median::Primo::SearchRequest
74
73
  @doc_id
75
74
  end
76
75
 
77
- # search scope
78
- attr_writer :scope
79
- def scope
80
- @scope || 'default'
76
+ # search locations
77
+ attr_writer :locations
78
+ def locations
79
+ @locations || []
81
80
  end
82
81
 
83
82
  # Facets
@@ -174,7 +173,7 @@ class Median::Primo::SearchRequest
174
173
  <SortByList>
175
174
  <SortField>rank</SortField>
176
175
  </SortByList>
177
- #{scopes_xml}
176
+ #{locations_xml}
178
177
  </PrimoSearchRequest>
179
178
  <institution>PAD</institution>
180
179
  <group>GUEST</group>
@@ -199,20 +198,15 @@ class Median::Primo::SearchRequest
199
198
  end.join('')
200
199
  end
201
200
 
202
- def scopes_xml
203
- if self.scope == 'catalog'
204
- return <<-xml
205
- <Locations>
206
- <uic:Location type="local" value="scope:(PAD_ALEPH_MM)"/>
207
- </Locations>
208
- xml
209
- else
210
- return <<-xml
211
- <Locations>
212
- <uic:Location type="local" value="scope:(PAD_ALEPH_MM)"/>
213
- <uic:Location type="adaptor" value="primo_central_multiple_fe" />
214
- </Locations>
215
- xml
216
- end
201
+ def locations_xml
202
+ locations = self.locations.map do |l|
203
+ "<uic:Location type=\"#{l[:type]}\" value=\"#{l[:value]}\"/>"
204
+ end.join
205
+
206
+ return <<-xml
207
+ <Locations>
208
+ #{locations}
209
+ </Locations>
210
+ xml
217
211
  end
218
212
  end
@@ -45,20 +45,4 @@ class Median::Primo::SearchResult
45
45
  has_previous_page? ? search_request.page - 1 : 1
46
46
  end
47
47
 
48
- protected
49
-
50
- # show only configured facets in the configured order
51
- #def filter_facets(facets)
52
- # configured_facets_names = Primo.config.facets
53
- # return facets if configured_facets_names.blank?
54
- #
55
- # new_facets = []
56
- # configured_facets_names.each do |facet_name|
57
- # facets.each do |facet|
58
- # new_facets << facet if facet.name == facet_name
59
- # end
60
- # end
61
- # new_facets
62
- #end
63
-
64
48
  end
@@ -1,3 +1,3 @@
1
1
  module Median
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: median
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-21 00:00:00.000000000 Z
12
+ date: 2012-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: -1093772393699786230
150
+ hash: -3480515468127621782
151
151
  requirements: []
152
152
  rubyforge_project:
153
153
  rubygems_version: 1.8.24