summon 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Changelog.md +4 -0
- data/lib/summon/schema/document.rb +18 -17
- data/lib/summon/schema/facet.rb +9 -6
- data/lib/summon/schema/search.rb +1 -0
- data/lib/summon/version.rb +1 -1
- data/spec/summon/schema/document_spec.rb +48 -54
- data/spec/summon/schema/facet_spec.rb +30 -64
- metadata +4 -4
data/.gitignore
CHANGED
data/Changelog.md
CHANGED
@@ -19,16 +19,17 @@ class Summon::Document < Summon::Schema
|
|
19
19
|
attr :publication_date, :json_name => "PublicationDate_xml", :transform => :Date
|
20
20
|
attr :publication_place
|
21
21
|
attr :meeting_name, :single => false
|
22
|
-
|
22
|
+
|
23
23
|
attr :isi_cited_references_count, :json_name => "ISICitedReferencesCount"
|
24
24
|
attr :isi_cited_references_uri, :json_name => "ISICitedReferencesURI"
|
25
|
-
|
25
|
+
|
26
26
|
attr :dissertation_advisors, :json_name => "DissertationAdvisor"
|
27
27
|
attr :dissertation_categories, :json_name => "DissertationCategory"
|
28
28
|
attr :dissertation_degrees, :json_name => "DissertationDegree"
|
29
29
|
attr :dissertation_degrees_dates, :json_name => "DissertationDegreeDate"
|
30
30
|
attr :dissertation_schools, :json_name => "DissertationSchool"
|
31
|
-
|
31
|
+
|
32
|
+
attr :in_holdings, :json_name => "inHoldings", :boolean => true
|
32
33
|
attr :library
|
33
34
|
attr :call_numbers, :json_name => "LCCallNum"
|
34
35
|
attr :deweys, :json_name => "DEWEY"
|
@@ -39,13 +40,13 @@ class Summon::Document < Summon::Schema
|
|
39
40
|
attr :eissns, :json_name => "EISSN"
|
40
41
|
attr :patent_number
|
41
42
|
attr :gov_doc_class_nums, :json_name => "GovDocClassNum"
|
42
|
-
|
43
|
+
|
43
44
|
attr :copyright, :single => false
|
44
|
-
|
45
|
+
|
45
46
|
attr :subject_terms
|
46
47
|
attr :genres, :json_name => "Genre"
|
47
48
|
attr :languages, :json_name => "Language"
|
48
|
-
|
49
|
+
|
49
50
|
attr :snippet #highlight
|
50
51
|
attr :abstract
|
51
52
|
attr :fulltext, :boolean => true, :json_name => "hasFullText"
|
@@ -62,9 +63,9 @@ class Summon::Document < Summon::Schema
|
|
62
63
|
attr :availability_id
|
63
64
|
attr :eric, :json_name => "ERIC"
|
64
65
|
attr :dbid, :json_name => "DBID", :single => false
|
65
|
-
|
66
|
+
|
66
67
|
attr :lib_guide_tab, :json_name => "LibGuideTab_xml", :single => false
|
67
|
-
|
68
|
+
|
68
69
|
attr :spotlight_children, :single => false, :transform => :Document
|
69
70
|
attr :fulltext_hit, :json_name => "isFullTextHit"
|
70
71
|
attr :peer_documents, :single => false, :json_name => "peerDocuments", :transform => :Document
|
@@ -76,11 +77,11 @@ class Summon::Document < Summon::Schema
|
|
76
77
|
def isbn
|
77
78
|
@isbns.first
|
78
79
|
end
|
79
|
-
|
80
|
+
|
80
81
|
def call_number
|
81
82
|
@call_numbers.first
|
82
83
|
end
|
83
|
-
|
84
|
+
|
84
85
|
def gov_doc_class_num
|
85
86
|
@gov_doc_class_nums.first
|
86
87
|
end
|
@@ -88,7 +89,7 @@ class Summon::Document < Summon::Schema
|
|
88
89
|
def pages?
|
89
90
|
@start_page || @page_count
|
90
91
|
end
|
91
|
-
|
92
|
+
|
92
93
|
def publication_date
|
93
94
|
@publication_date || Summon::Date.new({})
|
94
95
|
end
|
@@ -96,15 +97,15 @@ class Summon::Document < Summon::Schema
|
|
96
97
|
def publisher
|
97
98
|
@publishers.first
|
98
99
|
end
|
99
|
-
|
100
|
+
|
100
101
|
def authors
|
101
102
|
@authors.map {|n| Summon::Author.new(n["fullname"], n["surname"], n["givenname"], n["middlename"])}
|
102
103
|
end
|
103
|
-
|
104
|
+
|
104
105
|
def corporate_authors
|
105
106
|
@corporate_authors.map {|n| Summon::Author.new(n)}
|
106
107
|
end
|
107
|
-
|
108
|
+
|
108
109
|
def to_s(options = {})
|
109
110
|
"Title: #{title}"
|
110
111
|
end
|
@@ -116,7 +117,7 @@ class Summon::Document < Summon::Schema
|
|
116
117
|
def from_library?
|
117
118
|
@availability_id != nil
|
118
119
|
end
|
119
|
-
|
120
|
+
|
120
121
|
end
|
121
122
|
|
122
123
|
class Summon::Author < Struct.new(:fullname, :surname, :givenname, :middlename)
|
@@ -136,7 +137,7 @@ class Summon::Author < Struct.new(:fullname, :surname, :givenname, :middlename)
|
|
136
137
|
def middlename(*args)
|
137
138
|
super()
|
138
139
|
end
|
139
|
-
|
140
|
+
|
140
141
|
alias_method :name, :fullname
|
141
142
|
end
|
142
143
|
|
@@ -144,7 +145,7 @@ class Summon::LibGuideTab < Struct.new(:name, :uri)
|
|
144
145
|
def name(*args)
|
145
146
|
super()
|
146
147
|
end
|
147
|
-
|
148
|
+
|
148
149
|
def uri(*args)
|
149
150
|
super()
|
150
151
|
end
|
data/lib/summon/schema/facet.rb
CHANGED
@@ -7,7 +7,10 @@ class Summon::Facet < Summon::Schema
|
|
7
7
|
attr :page_number
|
8
8
|
attr :counts, :transform => :FacetCount
|
9
9
|
attr :remove_command
|
10
|
-
attr :
|
10
|
+
attr :has_applied_value?, :json_name => :hasAppliedValue, :boolean => true
|
11
|
+
attr :has_limiting_value?, :json_name => :hasLimitingValue, :boolean => true
|
12
|
+
attr :list_values_command
|
13
|
+
attr :remove_value_filters_command
|
11
14
|
|
12
15
|
|
13
16
|
def to_s
|
@@ -17,11 +20,11 @@ class Summon::Facet < Summon::Schema
|
|
17
20
|
def range?
|
18
21
|
false
|
19
22
|
end
|
20
|
-
|
23
|
+
|
21
24
|
def empty?
|
22
25
|
@counts.empty?
|
23
26
|
end
|
24
|
-
|
27
|
+
|
25
28
|
end
|
26
29
|
|
27
30
|
class Summon::FacetCount < Summon::Schema
|
@@ -37,15 +40,15 @@ class Summon::FacetCount < Summon::Schema
|
|
37
40
|
def escaped_value
|
38
41
|
Summon.escape(@value)
|
39
42
|
end
|
40
|
-
|
43
|
+
|
41
44
|
def excluded?
|
42
45
|
negated?
|
43
46
|
end
|
44
|
-
|
47
|
+
|
45
48
|
def included?
|
46
49
|
applied? && !excluded?
|
47
50
|
end
|
48
|
-
|
51
|
+
|
49
52
|
def abs_value
|
50
53
|
value.sub /^-/, ''
|
51
54
|
end
|
data/lib/summon/schema/search.rb
CHANGED
@@ -7,6 +7,7 @@ class Summon::Search < Summon::Schema
|
|
7
7
|
attr :query_time
|
8
8
|
attr :total_request_time
|
9
9
|
|
10
|
+
attr :availability_path
|
10
11
|
attr :query, :transform => :Query
|
11
12
|
attr :recommendations, :transform => :RecommendationList, :json_name => "recommendationLists"
|
12
13
|
attr :suggestions, :transform => :Suggestion, :json_name => :didYouMeanSuggestions
|
data/lib/summon/version.rb
CHANGED
@@ -1,43 +1,37 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Summon::Document do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
before {@document = Summon::Document.new(@service, JSON.parse(EXAMPLE_DOCUMENT_JSON))}
|
5
|
+
subject {@document}
|
6
|
+
it {should be_from_library}
|
7
|
+
its(:abstract) {should eql "This is the most awesome document ever"}
|
8
|
+
its(:subject_terms) {should eql ["Women's music", "Popular music", "Rock music"]}
|
9
|
+
its(:issns) {should eql ["1063-7125", "0000-1111"]}
|
10
|
+
its(:isbns) {should eql [ "0849343763 (v. 1)","0849343771 (v. 2)"]}
|
11
|
+
its(:publication_title) {should eql "Batman Books"}
|
12
|
+
it {should be_in_holdings}
|
12
13
|
|
13
|
-
describe "
|
14
|
-
it "
|
15
|
-
|
16
|
-
|
14
|
+
describe "authors" do
|
15
|
+
it "combines givenname, middlename, surname if fullname is missing" do
|
16
|
+
@document.authors[2].name.should == "Shi Wang"
|
17
|
+
@document.authors[3].name.should == "Hai C Chu"
|
17
18
|
end
|
18
|
-
|
19
|
-
|
20
|
-
document_data = JSON.parse(EXAMPLE_DOCUMENT_JSON)
|
21
|
-
document_data.delete('availabilityId')
|
22
|
-
doc = Summon::Document.new(@service, document_data)
|
23
|
-
doc.from_library?.should be(false)
|
19
|
+
it "preserves order" do
|
20
|
+
@document.authors.map(&:name).should == ["Liang, Yong X", "Gu, Miao N", "Shi Wang", "Hai C Chu"]
|
24
21
|
end
|
25
22
|
end
|
26
|
-
|
27
|
-
describe "
|
23
|
+
|
24
|
+
describe "without any availability ids" do
|
28
25
|
before do
|
29
26
|
document_data = JSON.parse(EXAMPLE_DOCUMENT_JSON)
|
30
|
-
|
31
|
-
|
32
|
-
it "should combine givenname, middlename, surname if fullname is missing" do
|
33
|
-
@doc.authors[2].name.should == "Shi Wang"
|
34
|
-
@doc.authors[3].name.should == "Hai C Chu"
|
35
|
-
end
|
36
|
-
it "should preserve order" do
|
37
|
-
@doc.authors.map(&:name).should == ["Liang, Yong X", "Gu, Miao N", "Shi Wang", "Hai C Chu"]
|
27
|
+
document_data.delete('availabilityId')
|
28
|
+
@document = Summon::Document.new(@service, document_data)
|
38
29
|
end
|
30
|
+
subject{@document}
|
31
|
+
it {should_not be_from_library}
|
39
32
|
end
|
40
|
-
|
33
|
+
|
34
|
+
|
41
35
|
EXAMPLE_DOCUMENT_JSON = <<-JSON
|
42
36
|
{
|
43
37
|
"Publisher_xml": [
|
@@ -66,7 +60,7 @@ describe Summon::Document do
|
|
66
60
|
"XQueryRevision": [
|
67
61
|
"Rev: 6229"
|
68
62
|
],
|
69
|
-
"inHoldings":
|
63
|
+
"inHoldings": true,
|
70
64
|
"DBID": [
|
71
65
|
"GXQ"
|
72
66
|
],
|
@@ -106,7 +100,7 @@ describe Summon::Document do
|
|
106
100
|
"surname": "Chu",
|
107
101
|
"middlename": "C",
|
108
102
|
"givenname": "Hai"
|
109
|
-
}
|
103
|
+
}
|
110
104
|
],
|
111
105
|
"CorporateAuthor": [
|
112
106
|
"Hunter, Rick",
|
@@ -246,21 +240,21 @@ describe Summon::Document do
|
|
246
240
|
]
|
247
241
|
}
|
248
242
|
JSON
|
249
|
-
|
243
|
+
|
250
244
|
EXPECTED_DOCUMENT_YAML = <<-YAML
|
251
|
-
--- !ruby/object:Summon::Document
|
245
|
+
--- !ruby/object:Summon::Document
|
252
246
|
abstract: This is the most awesome document ever
|
253
|
-
authors:
|
247
|
+
authors:
|
254
248
|
- Hunter, Lisa
|
255
249
|
availability_id: b16644323
|
256
|
-
call_numbers:
|
250
|
+
call_numbers:
|
257
251
|
- M1630.18 .H95 2000
|
258
252
|
- M1630.20 .H95 2000
|
259
253
|
content_type: Audio Recording
|
260
|
-
corporate_authors:
|
254
|
+
corporate_authors:
|
261
255
|
- Hunter, Rick
|
262
256
|
- Crusher, Beverly
|
263
|
-
dbid:
|
257
|
+
dbid:
|
264
258
|
- GXQ
|
265
259
|
dissertation_advisor: Claudio Friedmann
|
266
260
|
dissertation_category: Education
|
@@ -271,51 +265,51 @@ dissertation_degree_date_decade: "2000"
|
|
271
265
|
dissertation_degree_date_year: "2001"
|
272
266
|
dissertation_school: West Virginia University
|
273
267
|
doi: 10.1109\/CBMS.2008.1
|
274
|
-
edition:
|
268
|
+
edition:
|
275
269
|
end_page: i
|
276
270
|
fulltext: false
|
277
|
-
genres:
|
271
|
+
genres:
|
278
272
|
- Biography
|
279
273
|
- Congress
|
280
|
-
gov_doc_class_nums:
|
274
|
+
gov_doc_class_nums:
|
281
275
|
- A 57.38/42:M 45
|
282
276
|
- A 57.38/42:M 45
|
283
277
|
id: gvsu_catalog_b16644323
|
284
|
-
isbns:
|
278
|
+
isbns:
|
285
279
|
- 0849343763 (v. 1)
|
286
280
|
- 0849343771 (v. 2)
|
287
281
|
isi_cited_references_count: 5
|
288
282
|
isi_cited_references_uri: http://happy.com
|
289
|
-
issns:
|
283
|
+
issns:
|
290
284
|
- 1063-7125
|
291
285
|
- 0000-1111
|
292
286
|
issue: "7"
|
293
|
-
languages:
|
287
|
+
languages:
|
294
288
|
- English
|
295
289
|
lib_guide_tab: []
|
296
290
|
|
297
291
|
library: Women's Center Library
|
298
292
|
open_url: ctx_ver=Z39.88-2004&rfr_id=info:sid/summon.serialssolutions.com&rft_val_fmt=info:ofi/fmt:kev:mtx:dc&rft.title=Lisa+Hunter+--+alive&rft.creator=Hunter%2C+Lisa&rft.date=c200-0.&rft.pub=Spirulina+Records&rft.externalDBID=n%2Fa&rft.externalDocID=b16644323
|
299
293
|
page_count: xxviii, 140 p.
|
300
|
-
patent_number:
|
301
|
-
publication_date: !ruby/object:Summon::Date
|
294
|
+
patent_number:
|
295
|
+
publication_date: !ruby/object:Summon::Date
|
302
296
|
day: "02"
|
303
297
|
month: "01"
|
304
|
-
service:
|
305
|
-
src:
|
298
|
+
service:
|
299
|
+
src:
|
306
300
|
text: c2000.
|
307
301
|
year: "2000"
|
308
302
|
publication_place: Indiana
|
309
303
|
publication_series_title: A Bantam book
|
310
304
|
publication_title: Batman Books
|
311
|
-
publishers:
|
305
|
+
publishers:
|
312
306
|
- Spirulina Records
|
313
307
|
- Swingsistersound
|
314
|
-
service:
|
308
|
+
service:
|
315
309
|
snippet: This is the snippet
|
316
|
-
src:
|
310
|
+
src:
|
317
311
|
start_page: pp23
|
318
|
-
subject_terms:
|
312
|
+
subject_terms:
|
319
313
|
- Women's music
|
320
314
|
- Popular music
|
321
315
|
- Rock music
|
@@ -325,7 +319,7 @@ thumbnail_medium: http://api.test.summon.serialssolutions.com:8093/image/isbn/YX
|
|
325
319
|
thumbnail_small: http://api.test.summon.serialssolutions.com:8093/image/isbn/YX3FL6LB6P/9781864879094/small
|
326
320
|
title: Lisa Hunter -- alive
|
327
321
|
uri: http://disney.com
|
328
|
-
url:
|
329
|
-
volume:
|
322
|
+
url:
|
323
|
+
volume:
|
330
324
|
YAML
|
331
325
|
end
|
@@ -1,29 +1,41 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Summon::Facet do
|
4
|
-
|
5
|
-
|
6
|
-
facet.remove_src
|
7
|
-
facet.counts.each {|f| f.remove_src }
|
8
|
-
facet.to_yaml.should == EXPECTED_FACET_YAML
|
4
|
+
before {@facet = Summon::Facet.new(@service, JSON.parse(EXAMPLE_FACET_JSON))}
|
5
|
+
subject {@facet}
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
its(:page_size) {should eql 10}
|
8
|
+
its(:display_name) {should eql "ContentType"}
|
9
|
+
its(:combine_mode) {should eql "or"}
|
10
|
+
its(:list_values_command) {should eql "listFacetValues(ContentType_sfacet,or)"}
|
11
|
+
it {should_not have_applied_value}
|
12
|
+
its(:field_name) {should eql "ContentType_sfacet"}
|
13
|
+
it {should have_limiting_value}
|
14
|
+
its(:remove_command) {should eql "removeFacetField(ContentType_sfacet)"}
|
15
|
+
|
16
|
+
describe "Summon::FacetCount" do
|
17
|
+
subject {@facet.counts.first}
|
18
|
+
it {should be_further_limiting}
|
19
|
+
it {should be_negated}
|
20
|
+
its(:value) {should eql "Book"}
|
21
|
+
its(:count) {should eql 799602}
|
22
|
+
its(:apply_command) {should eql "addFacetValueFilter(ContentType_sfacet,Book,false)"}
|
23
|
+
its(:remove_command) {should eql "eatMyShorts()"}
|
24
|
+
its(:apply_negated_command) {should eql "addFacetValueFilter(ContentType_sfacet,Book,true)"}
|
25
|
+
it {should be_applied}
|
14
26
|
end
|
15
|
-
|
27
|
+
|
16
28
|
it "should now how to escape values" do
|
17
29
|
service = mock(:service)
|
18
|
-
|
30
|
+
|
19
31
|
count = Summon::FacetCount.new(service, :value => "the quick, brown, fox")
|
20
32
|
count.value.should == "the quick, brown, fox"
|
21
33
|
count.escaped_value.should == 'the quick\, brown\, fox'
|
22
|
-
|
23
|
-
Summon::FacetCount.new(service, :value => ': everything (else) and $1 or {is} it\ ').escaped_value.should ==
|
34
|
+
|
35
|
+
Summon::FacetCount.new(service, :value => ': everything (else) and $1 or {is} it\ ').escaped_value.should ==
|
24
36
|
'\: everything \(else\) and \$1 or \{is\} it\\ '
|
25
37
|
end
|
26
|
-
|
38
|
+
|
27
39
|
EXAMPLE_FACET_JSON = <<-JSON
|
28
40
|
{
|
29
41
|
"pageSize": 10,
|
@@ -39,13 +51,13 @@ describe Summon::Facet do
|
|
39
51
|
"counts": [
|
40
52
|
{
|
41
53
|
"isFurtherLimiting": true,
|
42
|
-
"isNegated":
|
54
|
+
"isNegated": true,
|
43
55
|
"value": "Book",
|
44
56
|
"count": 799602,
|
45
57
|
"applyCommand": "addFacetValueFilter(ContentType_sfacet,Book,false)",
|
46
58
|
"removeCommand": "eatMyShorts()",
|
47
59
|
"applyNegatedCommand": "addFacetValueFilter(ContentType_sfacet,Book,true)",
|
48
|
-
"isApplied":
|
60
|
+
"isApplied": true
|
49
61
|
},
|
50
62
|
{
|
51
63
|
"isFurtherLimiting": true,
|
@@ -70,51 +82,5 @@ describe Summon::Facet do
|
|
70
82
|
]
|
71
83
|
}
|
72
84
|
JSON
|
73
|
-
|
74
|
-
EXPECTED_FACET_YAML = <<-YAML
|
75
|
-
--- !ruby/object:Summon::Facet
|
76
|
-
combine_mode: or
|
77
|
-
counts:
|
78
|
-
- !ruby/object:Summon::FacetCount
|
79
|
-
applied: false
|
80
|
-
apply_command: addFacetValueFilter(ContentType_sfacet,Book,false)
|
81
|
-
apply_negated_command: addFacetValueFilter(ContentType_sfacet,Book,true)
|
82
|
-
count: 799602
|
83
|
-
further_limiting: true
|
84
|
-
negated: false
|
85
|
-
remove_command: eatMyShorts()
|
86
|
-
service:
|
87
|
-
src:
|
88
|
-
value: Book
|
89
|
-
- !ruby/object:Summon::FacetCount
|
90
|
-
applied: false
|
91
|
-
apply_command: addFacetValueFilter(ContentType_sfacet,JournalArticle,false)
|
92
|
-
apply_negated_command: addFacetValueFilter(ContentType_sfacet,JournalArticle,true)
|
93
|
-
count: 49765
|
94
|
-
further_limiting: true
|
95
|
-
negated: false
|
96
|
-
remove_command: eatMyShorts()
|
97
|
-
service:
|
98
|
-
src:
|
99
|
-
value: JournalArticle
|
100
|
-
- !ruby/object:Summon::FacetCount
|
101
|
-
applied: false
|
102
|
-
apply_command: addFacetValueFilter(ContentType_sfacet,Journal Article,false)
|
103
|
-
apply_negated_command: addFacetValueFilter(ContentType_sfacet,Journal Article,true)
|
104
|
-
count: 179002
|
105
|
-
further_limiting: true
|
106
|
-
negated: false
|
107
|
-
remove_command: eatMyShorts()
|
108
|
-
service:
|
109
|
-
src:
|
110
|
-
value: Journal Article
|
111
|
-
display_name: ContentType
|
112
|
-
field_name: ContentType_sfacet
|
113
|
-
page_number: 1
|
114
|
-
page_size: 10
|
115
|
-
remove_command: removeFacetField(ContentType_sfacet)
|
116
|
-
remove_value_filters_command: removeFacetValueFilters(ContentType)
|
117
|
-
service:
|
118
|
-
src:
|
119
|
-
YAML
|
85
|
+
|
120
86
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: summon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 1
|
10
|
+
version: 2.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Charles Lowell
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-11-06 01:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|