summon 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Changelog.md CHANGED
@@ -1,3 +1,17 @@
1
+ ### 1.2.3
2
+ * 1 major enhancement
3
+ * authors are now ordered
4
+
5
+ ### 1.2.2 2011-05-22
6
+
7
+ * 1 minor enhancement:
8
+ * fixed Search.to_s
9
+
10
+ ### 1.2.1 2011-05-22
11
+
12
+ * 1 major enhancement:
13
+ * Ruby 1.9.2 compatibility fixes
14
+
1
15
  ### 1.2.0 2011-04-09
2
16
 
3
17
  * removed translations
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- summon (1.2.1)
4
+ summon (1.2.3)
5
5
  json (>= 1.2.0)
6
6
 
7
7
  GEM
@@ -9,15 +9,15 @@ GEM
9
9
  specs:
10
10
  diff-lcs (1.1.2)
11
11
  json (1.5.1)
12
- rake (0.8.7)
13
- rspec (2.4.0)
14
- rspec-core (~> 2.4.0)
15
- rspec-expectations (~> 2.4.0)
16
- rspec-mocks (~> 2.4.0)
17
- rspec-core (2.4.0)
18
- rspec-expectations (2.4.0)
12
+ rake (0.9.1)
13
+ rspec (2.6.0)
14
+ rspec-core (~> 2.6.0)
15
+ rspec-expectations (~> 2.6.0)
16
+ rspec-mocks (~> 2.6.0)
17
+ rspec-core (2.6.3)
18
+ rspec-expectations (2.6.0)
19
19
  diff-lcs (~> 1.1.2)
20
- rspec-mocks (2.4.0)
20
+ rspec-mocks (2.6.0)
21
21
 
22
22
  PLATFORMS
23
23
  ruby
@@ -7,7 +7,7 @@ class Summon::Document < Summon::Schema
7
7
  attr :publication_series_title
8
8
  attr :content_type
9
9
 
10
- attr :authors, :json_name => "Author"
10
+ attr :authors, :json_name => "Author_xml"
11
11
  attr :corporate_authors, :json_name => "CorporateAuthor"
12
12
  attr :publishers, :json_name => "Publisher"
13
13
  attr :volume
@@ -89,7 +89,7 @@ class Summon::Document < Summon::Schema
89
89
  end
90
90
 
91
91
  def authors
92
- @authors.map {|n| Summon::Author.new(n)}
92
+ @authors.map {|n| Summon::Author.new(n["fullname"], n["surname"], n["givenname"], n["middlename"])}
93
93
  end
94
94
 
95
95
  def corporate_authors
@@ -110,10 +110,25 @@ class Summon::Document < Summon::Schema
110
110
 
111
111
  end
112
112
 
113
- class Summon::Author < Struct.new(:name)
114
- def name(*args)
113
+ class Summon::Author < Struct.new(:fullname, :surname, :givenname, :middlename)
114
+ def fullname(*args)
115
+ if super()
116
+ super()
117
+ else
118
+ [givenname, middlename, surname].compact.join(' ')
119
+ end
120
+ end
121
+ def surname(*args)
122
+ super()
123
+ end
124
+ def givenname(*args)
115
125
  super()
116
126
  end
127
+ def middlename(*args)
128
+ super()
129
+ end
130
+
131
+ alias_method :name, :fullname
117
132
  end
118
133
 
119
134
  class Summon::LibGuideTab < Struct.new(:name, :uri)
@@ -33,6 +33,6 @@ class Summon::Search < Summon::Schema
33
33
  end
34
34
 
35
35
  def to_s(options = {})
36
- "<Summon::Search>{records: #{result_count}, pages:#{page_count}, :query_time: #{query.query_time}ms, request_time:#{total_request_time}ms}"
36
+ "<Summon::Search>{records: #{record_count}, pages: #{page_count}, query_time: #{query_time}ms, request_time: #{total_request_time}ms}"
37
37
  end
38
38
  end
@@ -37,6 +37,32 @@
37
37
  "Author": [
38
38
  "Hunter, Lisa"
39
39
  ],
40
+ "Author_xml": [
41
+ {
42
+ "sequence": 1,
43
+ "fullname": "Liang, Yong X",
44
+ "surname": "Liang",
45
+ "givenname": "Yong X"
46
+ },
47
+ {
48
+ "sequence": 2,
49
+ "fullname": "Gu, Miao N",
50
+ "surname": "Gu",
51
+ "givenname": "Miao N"
52
+ },
53
+ {
54
+ "sequence": 3,
55
+ "fullname": "Wang, Shi D",
56
+ "surname": "Wang",
57
+ "givenname": "Shi D"
58
+ },
59
+ {
60
+ "sequence": 4,
61
+ "fullname": "Chu, Hai C",
62
+ "surname": "Chu",
63
+ "givenname": "Hai C"
64
+ }
65
+ ],
40
66
  "Genre": [
41
67
  "Obituary",
42
68
  "Obituary"
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Summon
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.3"
4
4
  end
@@ -23,6 +23,20 @@ describe Summon::Document do
23
23
  doc.from_library?.should be(false)
24
24
  end
25
25
  end
26
+
27
+ describe "authors" do
28
+ before do
29
+ document_data = JSON.parse(EXAMPLE_DOCUMENT_JSON)
30
+ @doc = Summon::Document.new(@service, document_data)
31
+ end
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"]
38
+ end
39
+ end
26
40
 
27
41
  EXAMPLE_DOCUMENT_JSON = <<-JSON
28
42
  {
@@ -69,6 +83,31 @@ describe Summon::Document do
69
83
  "Author": [
70
84
  "Hunter, Lisa"
71
85
  ],
86
+ "Author_xml": [
87
+ {
88
+ "sequence": 1,
89
+ "fullname": "Liang, Yong X",
90
+ "surname": "Liang",
91
+ "givenname": "Yong X"
92
+ },
93
+ {
94
+ "sequence": 2,
95
+ "fullname": "Gu, Miao N",
96
+ "surname": "Gu",
97
+ "givenname": "Miao N"
98
+ },
99
+ {
100
+ "sequence": 3,
101
+ "surname": "Wang",
102
+ "givenname": "Shi"
103
+ },
104
+ {
105
+ "sequence": 4,
106
+ "surname": "Chu",
107
+ "middlename": "C",
108
+ "givenname": "Hai"
109
+ }
110
+ ],
72
111
  "CorporateAuthor": [
73
112
  "Hunter, Rick",
74
113
  "Crusher, Beverly"
@@ -112,13 +151,6 @@ describe Summon::Document do
112
151
  "http://disney.com"
113
152
  ],
114
153
  "openUrl": "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",
115
- "Author_xml": [
116
- {
117
- "fullname": "Hunter, Lisa",
118
- "surname": "Hunter",
119
- "givenname": "Lisa"
120
- }
121
- ],
122
154
  "Library": [
123
155
  "Women's Center Library"
124
156
  ],
@@ -1,8 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
3
  describe Summon::Search do
4
- it "maps" do
5
- search = Summon::Search.new(@service, JSON.parse(<<-JSON))
4
+ before do
5
+ @search = Summon::Search.new(@service, JSON.parse(<<-JSON))
6
6
  {
7
7
  "pageCount": 0,
8
8
  "didYouMeanSuggestions": [
@@ -23,14 +23,17 @@ describe Summon::Search do
23
23
  "sessionId": "cfaa4020-1abe-4a9d-ae6e-e433a36c1069",
24
24
  "query": {}
25
25
  }
26
- JSON
27
- search.page_count.should == 0
28
- search.record_count.should == 4589937
29
- search.query_time.should == 124
30
- search.session_id.should == "cfaa4020-1abe-4a9d-ae6e-e433a36c1069"
31
- search.documents.should == []
32
- search.version.should == "1.0.0"
33
- search.query.should be_kind_of(Summon::Query)
26
+ JSON
27
+ end
28
+
29
+ it "maps" do
30
+ @search.page_count.should == 0
31
+ @search.record_count.should == 4589937
32
+ @search.query_time.should == 124
33
+ @search.session_id.should == "cfaa4020-1abe-4a9d-ae6e-e433a36c1069"
34
+ @search.documents.should == []
35
+ @search.version.should == "1.0.0"
36
+ @search.query.should be_kind_of(Summon::Query)
34
37
  end
35
38
 
36
39
  it "should handle an error case" do
@@ -58,5 +61,11 @@ JSON
58
61
  Summon::Search.new(@service, {}).should be_empty
59
62
  Summon::Search.new(@service, {"documents" => [{}]}).should_not be_empty
60
63
  end
64
+
65
+ context "to_s" do
66
+ it "renders correctly" do
67
+ @search.to_s.should == "<Summon::Search>{records: 4589937, pages: 0, query_time: 124ms, request_time: 129ms}"
68
+ end
69
+ end
61
70
 
62
71
  end
data/spec/summon_spec.rb CHANGED
@@ -21,7 +21,7 @@ describe "Summon Gem Integration Test" do
21
21
  d = documents[0]
22
22
  d.id.should == 'proquest_dll_1839009301'
23
23
  d.content_type.should == 'Newspaper Article'
24
- d.authors.map{|a| a.name}.should == ["Hunter, Lisa"]
24
+ d.authors.map{|a| a.name}.should == ["Liang, Yong X", "Gu, Miao N", "Wang, Shi D", "Chu, Hai C"]
25
25
  d.open_url.should == "ctx_ver=Z39.88-2004&rfr_id=info:sid/summon.serialssolutions.com&rft_val_fmt=info:ofi/fmt:kevLmtx:journal&rft.genre=article&rft.atitle=OBITUARIES&rft.jtitle=Arizona+Republic&rft.date=2002-03-16&rft.issn=0892-8711&rft.spage=B.5&rft.externalDBID=AREP&rft.externalDocID=1839009301"
26
26
  d.fulltext?.should be(false)
27
27
 
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: 29
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 3
10
+ version: 1.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Charles Lowell
@@ -16,14 +16,11 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-05-23 00:00:00 -05:00
19
+ date: 2011-06-03 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- name: json
24
- prerelease: false
25
- type: :runtime
26
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
27
24
  none: false
28
25
  requirements:
29
26
  - - ">="
@@ -34,12 +31,12 @@ dependencies:
34
31
  - 2
35
32
  - 0
36
33
  version: 1.2.0
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: rspec
40
34
  prerelease: false
41
- type: :development
42
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ type: :runtime
36
+ requirement: *id001
37
+ name: json
38
+ - !ruby/object:Gem::Dependency
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
43
40
  none: false
44
41
  requirements:
45
42
  - - ">="
@@ -50,12 +47,12 @@ dependencies:
50
47
  - 0
51
48
  - 0
52
49
  version: 2.0.0
53
- version_requirements: *id002
54
- - !ruby/object:Gem::Dependency
55
- name: rake
56
50
  prerelease: false
57
51
  type: :development
58
- requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirement: *id002
53
+ name: rspec
54
+ - !ruby/object:Gem::Dependency
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
59
56
  none: false
60
57
  requirements:
61
58
  - - ">="
@@ -64,7 +61,10 @@ dependencies:
64
61
  segments:
65
62
  - 0
66
63
  version: "0"
67
- version_requirements: *id003
64
+ prerelease: false
65
+ type: :development
66
+ requirement: *id003
67
+ name: rake
68
68
  description: Ruby language bindings for Serials Solutions Summon Unified Discovery Service
69
69
  email:
70
70
  - cowboyd@thefrontside.net
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  requirements: []
171
171
 
172
172
  rubyforge_project:
173
- rubygems_version: 1.6.0
173
+ rubygems_version: 1.6.2
174
174
  signing_key:
175
175
  specification_version: 3
176
176
  summary: Ruby language bindings for Serials Solutions Summon Unified Discovery Service