summon 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.specification +58 -0
  2. data/History.txt +4 -0
  3. data/Manifest.txt +52 -0
  4. data/PostInstall.txt +4 -0
  5. data/README.rdoc +77 -0
  6. data/Rakefile +25 -0
  7. data/bin/summon +10 -0
  8. data/bin/summonh +19 -0
  9. data/ispec/integration_spec.rb +61 -0
  10. data/lib/summon.rb +41 -0
  11. data/lib/summon/cli.rb +136 -0
  12. data/lib/summon/log.rb +40 -0
  13. data/lib/summon/schema.rb +109 -0
  14. data/lib/summon/schema/availability.rb +14 -0
  15. data/lib/summon/schema/citation.rb +11 -0
  16. data/lib/summon/schema/date.rb +23 -0
  17. data/lib/summon/schema/document.rb +84 -0
  18. data/lib/summon/schema/error.rb +4 -0
  19. data/lib/summon/schema/facet.rb +51 -0
  20. data/lib/summon/schema/query.rb +96 -0
  21. data/lib/summon/schema/range.rb +52 -0
  22. data/lib/summon/schema/search.rb +37 -0
  23. data/lib/summon/schema/suggestion.rb +5 -0
  24. data/lib/summon/service.rb +44 -0
  25. data/lib/summon/transport.rb +13 -0
  26. data/lib/summon/transport/canned.json +2327 -0
  27. data/lib/summon/transport/canned.rb +9 -0
  28. data/lib/summon/transport/errors.rb +12 -0
  29. data/lib/summon/transport/headers.rb +55 -0
  30. data/lib/summon/transport/http.rb +114 -0
  31. data/lib/summon/transport/qstring.rb +49 -0
  32. data/script/console +10 -0
  33. data/script/destroy +14 -0
  34. data/script/generate +14 -0
  35. data/spec/spec.opts +1 -0
  36. data/spec/spec_helper.rb +19 -0
  37. data/spec/summon/log_spec.rb +28 -0
  38. data/spec/summon/schema/availability_spec.rb +31 -0
  39. data/spec/summon/schema/citation_spec.rb +34 -0
  40. data/spec/summon/schema/date_spec.rb +12 -0
  41. data/spec/summon/schema/document_spec.rb +235 -0
  42. data/spec/summon/schema/facet_spec.rb +115 -0
  43. data/spec/summon/schema/query_spec.rb +163 -0
  44. data/spec/summon/schema/range_spec.rb +45 -0
  45. data/spec/summon/schema/search_spec.rb +62 -0
  46. data/spec/summon/schema_spec.rb +143 -0
  47. data/spec/summon/service_spec.rb +18 -0
  48. data/spec/summon/transport/headers_spec.rb +47 -0
  49. data/spec/summon/transport/http_spec.rb +29 -0
  50. data/spec/summon/transport/qstring_spec.rb +24 -0
  51. data/spec/summon_spec.rb +48 -0
  52. data/summon.gemspec +41 -0
  53. metadata +145 -0
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Summon::Service do
4
+
5
+ it "can be configured" do
6
+ Object.new.tap do |log|
7
+ Summon::Transport::Http.should_receive(:new).with(hash_including(:url => "http://google.com", :access_id => "Bob", :session_id => "foo", :client_key => "Justice", :secret_key => "Happiness"))
8
+ @service = Summon::Service.new :url => "http://google.com", :access_id => "Bob", :secret_key => "Happiness", :session_id => "foo", :client_key => "Justice"
9
+ @service.url.should == "http://google.com"
10
+ @service.access_id.should == "Bob"
11
+ end
12
+ end
13
+
14
+ it "has a default url which is the public production summon url" do
15
+ Summon::Service.new.url.should == "http://api.summon.serialssolutions.com"
16
+ end
17
+
18
+ end
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Summon::Transport::Headers do
4
+
5
+ before(:each) do
6
+ Time.httpdate("Tue, 30 Jun 2009 12:10:24 GMT").tap do |point|
7
+ Time.stub!(:now).and_return(point)
8
+ end
9
+ end
10
+
11
+ it "give the request parameters, it represents the correct headers" do
12
+ Summon::Transport::Headers.new(
13
+ :url => "http://magg1.beta.projectmagnolia.net:8083/summon-search-api/search2",
14
+ :access_id => "test",
15
+ :client_key => "PX3FK6GB6M",
16
+ :secret_key => "ed2ee2e0-65c1-11de-8a39-0800200c9a66",
17
+ :accept => "xml",
18
+ :params => {'s.ff' => 'ContentType,or,1,15', 's.q' => 'forest'}
19
+ ).should == {
20
+ 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf8',
21
+ 'Accept' => 'application/xml',
22
+ 'x-summon-date' => 'Tue, 30 Jun 2009 12:10:24 GMT',
23
+ 'Authorization' => 'Summon test;PX3FK6GB6M;g1SZb73Vg6bV7VhFQ2KkCLy98rE=',
24
+ 'Host' => 'magg1.beta.projectmagnolia.net:8083'
25
+ }
26
+ end
27
+
28
+ it "successfully handles array parameters" do
29
+ Summon::Transport::Headers.new(
30
+ :url => "http://magg1.beta.projectmagnolia.net:8083/summon-search-api/search2",
31
+ :access_id => "test",
32
+ :client_key => "PX3FK6GB6M",
33
+ :secret_key => "ed2ee2e0-65c1-11de-8a39-0800200c9a66",
34
+ :session_id => "Session-3000!",
35
+ :accept => "xml",
36
+ :params => {'s.ff' => ['ContentType,or,1,15'], 's.q' => ['forest']}
37
+ ).should == {
38
+ 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf8',
39
+ 'Accept' => 'application/xml',
40
+ 'x-summon-date' => 'Tue, 30 Jun 2009 12:10:24 GMT',
41
+ 'x-summon-session-id' => "Session-3000!",
42
+ 'Authorization' => 'Summon test;PX3FK6GB6M;g1SZb73Vg6bV7VhFQ2KkCLy98rE=',
43
+ 'Host' => 'magg1.beta.projectmagnolia.net:8083'
44
+ }
45
+
46
+ end
47
+ end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Summon::Transport::Http do
4
+ attr_reader :http
5
+
6
+ before do
7
+ @http = Summon::Transport::Http.new
8
+ end
9
+
10
+ describe "parse" do
11
+ it "should parse json" do
12
+ response = stub("response", :content_type => "application/json",
13
+ :body => '{"some":"json","foo":[1,2],"bar":3}')
14
+ http.parse(response).should == {"some" => "json", "foo" => [1,2], "bar" => 3}
15
+ end
16
+
17
+ it "should parse text" do
18
+ response = stub("response", :content_type => "text/plain",
19
+ :body => "some string\r\nand another one\r\n")
20
+ http.parse(response).should == "some string\r\nand another one\r\n"
21
+ end
22
+
23
+ it "should raise error on anything else" do
24
+ response = stub("response", :content_type => "text/xml",
25
+ :body => "<some>xml</some>")
26
+ proc {http.parse(response)}.should raise_error(Summon::Transport::ServiceError, "service returned unexpected text/xml : <some>xml</some>")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Summon::Transport::Qstring do
4
+ before(:each) do
5
+ extend Summon::Transport::Qstring
6
+ end
7
+
8
+ it "can decode a query string into hash parameters" do
9
+ from_query_string("foo=bar&baz=bang").should == {"foo" => "bar", "baz" => "bang"}
10
+ end
11
+
12
+ it "stuffs multiple keys into the same value as a list" do
13
+ from_query_string("foo=bar&foo=baz&bar=bang").should == {"foo" => ["bar", "baz"], "bar" => "bang"}
14
+ end
15
+
16
+ it "url decodes keys and values" do
17
+ from_query_string("foo=bar%20bar&baz=bang+bang").should == {"foo" => "bar bar", "baz" => "bang bang"}
18
+ end
19
+
20
+ it "returns an empty hash if the query string is blank" do
21
+ from_query_string(nil).should be_empty
22
+ from_query_string("").should be_empty
23
+ end
24
+ end
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "Summon Gem Integration Test" do
4
+ it "maps an api request correctly" do
5
+ service = Summon::Service.new(:transport => Summon::Transport::Canned.new)
6
+ search = service.search
7
+ search.should_not be_nil
8
+ search.record_count.should == 1506825
9
+ search.page_count.should == 100456
10
+ search.total_request_time.should == 80
11
+ search.query_time.should == 57
12
+ search.suggestions.should_not be_nil
13
+ search.suggestions.length.should == 1
14
+ dym = search.suggestions.first
15
+ dym.original_query.should == "louis rmstrong"
16
+ dym.suggested_query.should == "louis armstrong"
17
+
18
+ documents = search.documents
19
+ documents.should_not be_nil
20
+ documents.length.should == 15
21
+ d = documents[0]
22
+ d.id.should == "gvsu_catalog_b16644323"
23
+ d.content_type.should == "Audio Recording"
24
+ d.authors.map{|a| a.name}.should == ["Hunter, Lisa"]
25
+ d.open_url.should == "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"
26
+ d.fulltext?.should be(false)
27
+
28
+
29
+ facets = search.facets
30
+ facets.should_not be_nil
31
+ facets.length.should >= 5
32
+ ctype = facets[2]
33
+ ctype.display_name.should == "ContentType"
34
+ ctype.combine_mode.should == 'or'
35
+ end
36
+
37
+ it "should now how to escape values" do
38
+ check_escape("the quick, brown, fox", 'the quick\, brown\, fox')
39
+ Summon.escape(': everything (else) and $1 or {is} it\ ').should == '\: everything \(else\) and \$1 or \{is\} it\\ '
40
+ end
41
+
42
+ def check_escape(unescaped, escaped)
43
+ Summon.escape(unescaped).should == escaped
44
+ Summon.unescape(escaped).should == unescaped
45
+ Summon.unescape(Summon.escape(unescaped)).should == unescaped
46
+ Summon.escape(Summon.unescape(escaped)).should == escaped
47
+ end
48
+ end
data/summon.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{summon}
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Charles Lowell"]
9
+ s.date = %q{2009-09-28}
10
+ s.description = %q{Ruby language bindings for Serials Solutions Summon Unified Discovery Service}
11
+ s.email = ["cowboyd@thefrontside.net"]
12
+ s.executables = ["summon", "summonh"]
13
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
14
+ s.files = [".specification", "History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "bin/summon", "bin/summonh", "ispec/integration_spec.rb", "lib/summon.rb", "lib/summon/cli.rb", "lib/summon/log.rb", "lib/summon/schema.rb", "lib/summon/schema/availability.rb", "lib/summon/schema/citation.rb", "lib/summon/schema/date.rb", "lib/summon/schema/document.rb", "lib/summon/schema/error.rb", "lib/summon/schema/facet.rb", "lib/summon/schema/query.rb", "lib/summon/schema/range.rb", "lib/summon/schema/search.rb", "lib/summon/schema/suggestion.rb", "lib/summon/service.rb", "lib/summon/transport.rb", "lib/summon/transport/canned.json", "lib/summon/transport/canned.rb", "lib/summon/transport/errors.rb", "lib/summon/transport/headers.rb", "lib/summon/transport/http.rb", "lib/summon/transport/qstring.rb", "script/console", "script/destroy", "script/generate", "spec/spec.opts", "spec/spec_helper.rb", "spec/summon/log_spec.rb", "spec/summon/schema/availability_spec.rb", "spec/summon/schema/citation_spec.rb", "spec/summon/schema/date_spec.rb", "spec/summon/schema/document_spec.rb", "spec/summon/schema/facet_spec.rb", "spec/summon/schema/query_spec.rb", "spec/summon/schema/range_spec.rb", "spec/summon/schema/search_spec.rb", "spec/summon/schema_spec.rb", "spec/summon/service_spec.rb", "spec/summon/transport/headers_spec.rb", "spec/summon/transport/http_spec.rb", "spec/summon/transport/qstring_spec.rb", "spec/summon_spec.rb", "summon.gemspec"]
15
+ s.homepage = %q{http://summon.rubyforge.org}
16
+ s.post_install_message = %q{PostInstall.txt}
17
+ s.rdoc_options = ["--main", "README.rdoc"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{summon}
20
+ s.rubygems_version = %q{1.3.5}
21
+ s.summary = %q{Ruby language bindings for Serials Solutions Summon Unified Discovery Service}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<json_pure>, [">= 1.1.7"])
29
+ s.add_development_dependency(%q<rspec>, [">= 1.2.7"])
30
+ s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
31
+ else
32
+ s.add_dependency(%q<json_pure>, [">= 1.1.7"])
33
+ s.add_dependency(%q<rspec>, [">= 1.2.7"])
34
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
35
+ end
36
+ else
37
+ s.add_dependency(%q<json_pure>, [">= 1.1.7"])
38
+ s.add_dependency(%q<rspec>, [">= 1.2.7"])
39
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: summon
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Charles Lowell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-29 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: json_pure
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.1.7
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.7
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.3.3
44
+ version:
45
+ description: Ruby language bindings for Serials Solutions Summon Unified Discovery Service
46
+ email:
47
+ - cowboyd@thefrontside.net
48
+ executables:
49
+ - summon
50
+ - summonh
51
+ extensions: []
52
+
53
+ extra_rdoc_files:
54
+ - History.txt
55
+ - Manifest.txt
56
+ - PostInstall.txt
57
+ files:
58
+ - .specification
59
+ - History.txt
60
+ - Manifest.txt
61
+ - PostInstall.txt
62
+ - README.rdoc
63
+ - Rakefile
64
+ - bin/summon
65
+ - bin/summonh
66
+ - ispec/integration_spec.rb
67
+ - lib/summon.rb
68
+ - lib/summon/cli.rb
69
+ - lib/summon/log.rb
70
+ - lib/summon/schema.rb
71
+ - lib/summon/schema/availability.rb
72
+ - lib/summon/schema/citation.rb
73
+ - lib/summon/schema/date.rb
74
+ - lib/summon/schema/document.rb
75
+ - lib/summon/schema/error.rb
76
+ - lib/summon/schema/facet.rb
77
+ - lib/summon/schema/query.rb
78
+ - lib/summon/schema/range.rb
79
+ - lib/summon/schema/search.rb
80
+ - lib/summon/schema/suggestion.rb
81
+ - lib/summon/service.rb
82
+ - lib/summon/transport.rb
83
+ - lib/summon/transport/canned.json
84
+ - lib/summon/transport/canned.rb
85
+ - lib/summon/transport/errors.rb
86
+ - lib/summon/transport/headers.rb
87
+ - lib/summon/transport/http.rb
88
+ - lib/summon/transport/qstring.rb
89
+ - script/console
90
+ - script/destroy
91
+ - script/generate
92
+ - spec/spec.opts
93
+ - spec/spec_helper.rb
94
+ - spec/summon/log_spec.rb
95
+ - spec/summon/schema/availability_spec.rb
96
+ - spec/summon/schema/citation_spec.rb
97
+ - spec/summon/schema/date_spec.rb
98
+ - spec/summon/schema/document_spec.rb
99
+ - spec/summon/schema/facet_spec.rb
100
+ - spec/summon/schema/query_spec.rb
101
+ - spec/summon/schema/range_spec.rb
102
+ - spec/summon/schema/search_spec.rb
103
+ - spec/summon/schema_spec.rb
104
+ - spec/summon/service_spec.rb
105
+ - spec/summon/transport/headers_spec.rb
106
+ - spec/summon/transport/http_spec.rb
107
+ - spec/summon/transport/qstring_spec.rb
108
+ - spec/summon_spec.rb
109
+ - summon.gemspec
110
+ has_rdoc: true
111
+ homepage: http://summon.rubyforge.org
112
+ licenses: []
113
+
114
+ post_install_message: |
115
+
116
+ For comprehensive documentation on Summon API options and usage visit:
117
+
118
+ http://api.summon.serialssolutions.com
119
+
120
+ rdoc_options:
121
+ - --main
122
+ - README.rdoc
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: "0"
130
+ version:
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: "0"
136
+ version:
137
+ requirements: []
138
+
139
+ rubyforge_project: summon
140
+ rubygems_version: 1.3.5
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: Ruby language bindings for Serials Solutions Summon Unified Discovery Service
144
+ test_files: []
145
+