sru 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,19 +33,19 @@ module SRU
33
33
  @server = URI.parse base
34
34
  @parser = options.fetch(:parser, 'rexml')
35
35
  case @parser
36
- when 'libxml'
37
- begin
38
- require 'rubygems'
39
- require 'libxml'
40
- rescue
41
- raise SRU::Exception, "unknown parser: #{@parser}", caller
42
- end
43
- when 'rexml'
44
- require 'rexml/document'
45
- require 'rexml/xpath'
46
- else
47
- raise SRU::Exception, "unknown parser: #{@parser}", caller
48
- end
36
+ when 'libxml'
37
+ begin
38
+ require 'rubygems'
39
+ require 'libxml'
40
+ rescue
41
+ raise SRU::Exception, "unknown parser: #{@parser}", caller
42
+ end
43
+ when 'rexml'
44
+ require 'rexml/document'
45
+ require 'rexml/xpath'
46
+ else
47
+ raise SRU::Exception, "unknown parser: #{@parser}", caller
48
+ end
49
49
 
50
50
  # stash this away for future requests
51
51
  @version = self.explain.version
@@ -118,7 +118,11 @@ module SRU
118
118
  # fetch the xml and build/return a document object from it
119
119
  begin
120
120
  res = Net::HTTP.start(uri.host, uri.port) {|http|
121
- http.get(uri.request_uri, { "Accept" => "text/xml, application/xml"})
121
+ req = Net::HTTP::Get.new(uri.request_uri, { "Accept" => "text/xml, application/xml"})
122
+ if uri.user && uri.password
123
+ req.basic_auth uri.user, uri.password
124
+ end
125
+ http.request(req)
122
126
  }
123
127
 
124
128
  xml = res.body
@@ -126,10 +130,9 @@ module SRU
126
130
  case @parser
127
131
  when 'libxml'
128
132
  xmlObj = LibXML::XML::Parser.string(xml)
129
- # not sure why but the explain namespace does bad things to
133
+ # not sure why but the explain namespace does bad things to
130
134
  # libxml
131
- #xml = xml.gsub(' xmlns="http://explain.z3950.org/dtd/2.0/"', '')
132
-
135
+ #xml = xml.gsub(' xmlns="http://explain.z3950.org/dtd/2.0/"', '')
133
136
  return xmlObj.parse
134
137
  when 'rexml'
135
138
  return REXML::Document.new(xml)
@@ -1,6 +1,6 @@
1
1
  class TCHTTPClientTests < Test::Unit::TestCase
2
2
  def test_content_negotiation
3
- client = SRU::Client.new 'http://viaf.org/search'
3
+ client = SRU::Client.new 'http://viaf.org/viaf/search'
4
4
  assert_nothing_raised do
5
5
  results = client.search_retrieve 'local.names any twain'
6
6
  end
@@ -30,26 +30,6 @@ class TcLibxmlClientTests < Test::Unit::TestCase
30
30
  results = client.search_retrieve 'twain'
31
31
  assert_equal 10, results.entries.size
32
32
  end
33
-
34
- # need to find a target that supports scan so we can exercise it
35
- #def test_scan
36
- # # this scan response appears to be canned might need to change
37
- # client = SRU::Client.new 'http://tweed.lib.ed.ac.uk:8080/elf/search/copac'
38
- # scan = client.scan('foobar')
39
- # assert scan.entries.size > 0
40
- # assert_equal SRU::Term, scan.entries[0].class
41
- # assert_equal 'low', scan.entries[0].value
42
- # assert_equal '1', scan.entries[0].number_of_records
43
- #end
44
-
45
- def test_xml_exception
46
- assert_raise(SRU::Exception) {SRU::Client.new 'http://www.google.com'}
47
- end
48
-
49
- def test_http_exception
50
- assert_raise(SRU::Exception) {SRU::Client.new 'http://example.com'}
51
- end
52
-
53
33
  end
54
34
 
55
35
 
@@ -30,26 +30,6 @@ class TCRexmlClientTests < Test::Unit::TestCase
30
30
  results = client.search_retrieve 'twain'
31
31
  assert_equal 10, results.entries.size
32
32
  end
33
-
34
- # need to find a target that supports scan so we can exercise it
35
- #def test_scan
36
- # # this scan response appears to be canned might need to change
37
- # client = SRU::Client.new 'http://tweed.lib.ed.ac.uk:8080/elf/search/copac'
38
- # scan = client.scan('foobar')
39
- # assert scan.entries.size > 0
40
- # assert_equal SRU::Term, scan.entries[0].class
41
- # assert_equal 'low', scan.entries[0].value
42
- # assert_equal '1', scan.entries[0].number_of_records
43
- #end
44
-
45
- def test_xml_exception
46
- assert_raise(SRU::Exception) {SRU::Client.new 'http://www.google.com'}
47
- end
48
-
49
- def test_http_exception
50
- assert_raise(SRU::Exception) {SRU::Client.new 'http://example.com'}
51
- end
52
-
53
33
  end
54
34
 
55
35
 
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 8
10
+ version: 0.0.8
5
11
  platform: ruby
6
12
  authors:
7
13
  - Ed Summers
@@ -9,7 +15,7 @@ autorequire: sru
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-02-10 00:00:00 -05:00
18
+ date: 2011-04-11 00:00:00 -04:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -44,21 +50,27 @@ rdoc_options: []
44
50
  require_paths:
45
51
  - lib
46
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
47
54
  requirements:
48
55
  - - ">="
49
56
  - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
50
60
  version: "0"
51
- version:
52
61
  required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
53
63
  requirements:
54
64
  - - ">="
55
65
  - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
56
69
  version: "0"
57
- version:
58
70
  requirements: []
59
71
 
60
72
  rubyforge_project:
61
- rubygems_version: 1.3.5
73
+ rubygems_version: 1.3.7
62
74
  signing_key:
63
75
  specification_version: 3
64
76
  summary: a Ruby library for Search and Retrieve by URL