zoom 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +149 -0
- data/README +58 -0
- data/Rakefile +54 -0
- data/sample/CVS/Entries +3 -0
- data/sample/CVS/Repository +1 -0
- data/sample/CVS/Root +1 -0
- data/sample/hello.rb +8 -0
- data/sample/needle.rb +124 -0
- data/src/extconf.rb +17 -0
- data/src/rbzoom.c +32 -0
- data/src/rbzoom.h +61 -0
- data/src/rbzoomconnection.c +291 -0
- data/src/rbzoomoptions.c +112 -0
- data/src/rbzoomquery.c +116 -0
- data/src/rbzoomrecord.c +176 -0
- data/src/rbzoomresultset.c +222 -0
- data/test/CVS/Entries +4 -0
- data/test/CVS/Repository +1 -0
- data/test/CVS/Root +1 -0
- data/test/record.dat +1 -0
- data/test/record.txt +22 -0
- data/test/search_test.rb +14 -0
- metadata +69 -0
data/ChangeLog
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
v0.3.0 Tue Jul 10 11:57:40 EDT 2007
|
2
|
+
- new format for this file
|
3
|
+
- added Rakefile
|
4
|
+
- applied patch from Jason Ronallo to enable raw method on records
|
5
|
+
- added test suite
|
6
|
+
- created gem for rubyforge
|
7
|
+
|
8
|
+
2007-05-05 Ed Summers <ehs@pobox.com>
|
9
|
+
* AUTHORS
|
10
|
+
- added Ed Summers
|
11
|
+
|
12
|
+
* src/lib/*
|
13
|
+
- removed marc.rb since it isn't used and conflicts with the marc gem
|
14
|
+
|
15
|
+
2006-09-21 Laurent Sansonetti <lrz@chopine.be>
|
16
|
+
|
17
|
+
* ChangeLog,
|
18
|
+
README,
|
19
|
+
src/**/*.{c,h,rb}:
|
20
|
+
|
21
|
+
s/gnome.org/chopine.be/g.
|
22
|
+
|
23
|
+
2006-09-21 Devin Bayer <devin@freeshell.org>
|
24
|
+
|
25
|
+
* .cvsignore:
|
26
|
+
|
27
|
+
Ignores zoom.bundle.
|
28
|
+
|
29
|
+
* sample/needle.rb:
|
30
|
+
|
31
|
+
Updated the needle demo application.
|
32
|
+
|
33
|
+
* src/rbzoomconnection.c:
|
34
|
+
|
35
|
+
Do not fail when reading options.
|
36
|
+
|
37
|
+
2006-08-22 Laurent Sansonetti <lrz@chopine.be>
|
38
|
+
|
39
|
+
* AUTHORS:
|
40
|
+
|
41
|
+
- Updated my e-mail address ;
|
42
|
+
- Added Devin.
|
43
|
+
|
44
|
+
2006-08-22 Devin Bayer <devin@freeshell.org>
|
45
|
+
|
46
|
+
* src/rbzoomrecord.c:
|
47
|
+
|
48
|
+
Added ZOOM::Record#raw, to grab a marc record in marc format.
|
49
|
+
|
50
|
+
2006-08-20 Devin Bayer <devin@freeshell.org>
|
51
|
+
|
52
|
+
* sample/needle.rb:
|
53
|
+
|
54
|
+
Added new sample, contributed by Devin Bayer.
|
55
|
+
|
56
|
+
=== Ruby/ZOOM 0.2.2 ===
|
57
|
+
|
58
|
+
2005-11-08 Laurent Sansonetti <lrz@chopine.be>
|
59
|
+
|
60
|
+
* README:
|
61
|
+
|
62
|
+
Added a note about YAZ's --enable-shared problem.
|
63
|
+
|
64
|
+
* AUTHORS:
|
65
|
+
|
66
|
+
Added Pascal and Matt.
|
67
|
+
|
68
|
+
2005-11-08 Matt Vanderpol <matt@vanderpol.net>
|
69
|
+
|
70
|
+
* src/rbzoomquery.c (.new_prefix, .new_cql):
|
71
|
+
|
72
|
+
Fixed constructors.
|
73
|
+
|
74
|
+
=== Ruby/ZOOM 0.2.1 ===
|
75
|
+
|
76
|
+
2005-09-23 Pascal Terjan <pterjan@linuxfr.org>
|
77
|
+
|
78
|
+
* src/rbzoomoptions.c:
|
79
|
+
|
80
|
+
Fixes segfault when rubyfying the option name.
|
81
|
+
|
82
|
+
=== Ruby/ZOOM 0.2.0 ===
|
83
|
+
|
84
|
+
2005-08-02 Laurent Sansonetti <lrz@chopine.be>
|
85
|
+
|
86
|
+
* src/rbzoomresultset.rb (#[]):
|
87
|
+
|
88
|
+
Retrieves the record one by one using ZOOM_resultset_record instead
|
89
|
+
of getting them all in once with ZOOM_resultset_records (for a strange
|
90
|
+
reason sometimes the resultset was not empty but ZOOM_resultset_records
|
91
|
+
used to return empty records).
|
92
|
+
|
93
|
+
2005-07-19 Laurent Sansonetti <lrz@chopine.be>
|
94
|
+
|
95
|
+
* src/lib/marc.rb:
|
96
|
+
|
97
|
+
Added an experimental MARC decoder.
|
98
|
+
|
99
|
+
=== Ruby/ZOOM 0.1.0 ===
|
100
|
+
|
101
|
+
2005-03-18 Laurent Sansonetti <lrz@chopine.be>
|
102
|
+
|
103
|
+
* COPYING.LIB,
|
104
|
+
AUTHORS,
|
105
|
+
README:
|
106
|
+
|
107
|
+
Added.
|
108
|
+
|
109
|
+
* src/rbzoomconnection.c,
|
110
|
+
src/rbzoomquery.c:
|
111
|
+
|
112
|
+
Fixed documentation.
|
113
|
+
|
114
|
+
* src/rbzoomresultset.c (#[]):
|
115
|
+
|
116
|
+
- Range objects are supported ;
|
117
|
+
- Do not clone nil objects.
|
118
|
+
|
119
|
+
2005-03-17 Laurent Sansonetti <lrz@chopine.be>
|
120
|
+
|
121
|
+
* doc/.cvsignore,
|
122
|
+
doc/gendoc.sh:
|
123
|
+
|
124
|
+
Added.
|
125
|
+
|
126
|
+
* src/rbzoom.c,
|
127
|
+
src/rbzoom.h,
|
128
|
+
src/rbzoomconnection.c,
|
129
|
+
src/rbzoomoptions.c,
|
130
|
+
src/rbzoomquery.c,
|
131
|
+
src/rbzoomrecord.c,
|
132
|
+
src/rbzoomresultset.c:
|
133
|
+
|
134
|
+
Added extdoc documentation + LGPL headers.
|
135
|
+
|
136
|
+
2005-03-16 Laurent Sansonetti <lrz@chopine.be>
|
137
|
+
|
138
|
+
* src/rbzoomrecord.c (#database, #syntax, #render, #xml):
|
139
|
+
|
140
|
+
Added.
|
141
|
+
|
142
|
+
* src/rbzoom.c,
|
143
|
+
sample/hello.rb:
|
144
|
+
|
145
|
+
Renamed the module name as 'ZOOM'.
|
146
|
+
|
147
|
+
2005-03-14 Laurent Sansonetti <lrz@chopine.be>
|
148
|
+
|
149
|
+
Initial RubyForge revision.
|
data/README
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
Ruby/ZOOM
|
2
|
+
=========
|
3
|
+
|
4
|
+
Ruby/ZOOM provides a Ruby binding to the Z39.50 Object-Orientation Model
|
5
|
+
(ZOOM), an abstract object-oriented programming interface to a subset of the
|
6
|
+
services specified by the Z39.50 standard, also known as the international
|
7
|
+
standard ISO 23950.
|
8
|
+
|
9
|
+
This software is based (and therefore depends) on YAZ, a free-software
|
10
|
+
implementation of the Z39.50/SRW/SRU standards, but could be easily ported to
|
11
|
+
any ZOOM compliant implementation.
|
12
|
+
|
13
|
+
Ruby/ZOOM is free-software, covered by the GNU Lesser General Public License
|
14
|
+
and provided without any warranties of any kind.
|
15
|
+
|
16
|
+
Requirements
|
17
|
+
------------
|
18
|
+
|
19
|
+
Ruby: http://www.ruby-lang.org/
|
20
|
+
YAZ (*): http://www.indexdata.dk/yaz/
|
21
|
+
|
22
|
+
* : Make sure you did pass the --enabled-shared option to the configure
|
23
|
+
script before building YAZ. Ruby/ZOOM requires a YAZ shared library
|
24
|
+
and YAZ does not build it by default.
|
25
|
+
|
26
|
+
Install
|
27
|
+
-------
|
28
|
+
|
29
|
+
0. install Ruby
|
30
|
+
1. install YAZ
|
31
|
+
2. gem install ruby-zoom
|
32
|
+
|
33
|
+
Build from Source
|
34
|
+
-----------------
|
35
|
+
|
36
|
+
0. checkout out code from cvs at rubyforge
|
37
|
+
1. install Rake
|
38
|
+
2. rake
|
39
|
+
5. gem install pkg/zoom-*.gem
|
40
|
+
|
41
|
+
Samples
|
42
|
+
-------
|
43
|
+
|
44
|
+
Some programming examples are available in the `sample' directory.
|
45
|
+
|
46
|
+
Copying
|
47
|
+
-------
|
48
|
+
|
49
|
+
Copyright (c) 2005 Laurent Sansonetti <lrz@chopine.be>
|
50
|
+
|
51
|
+
This library is free software.
|
52
|
+
You can distribute/modify this program under the terms of
|
53
|
+
the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
|
54
|
+
|
55
|
+
Project Website
|
56
|
+
---------------
|
57
|
+
|
58
|
+
http://ruby-zoom.rubyforge.org
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
RUBY_ZOOM_VERSION = '0.3.0'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/clean'
|
6
|
+
require 'rake/testtask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/packagetask'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'mkmf'
|
11
|
+
|
12
|
+
CLEAN.include '**/*.o'
|
13
|
+
CLEAN.include '**/*.so'
|
14
|
+
CLEAN.include '**/Makefile'
|
15
|
+
CLEAN.include '**/*.log'
|
16
|
+
CLEAN.include 'pkg'
|
17
|
+
|
18
|
+
task :default => [:build, :test, :package] do |t|
|
19
|
+
end
|
20
|
+
|
21
|
+
task :build => [:clean] do |t|
|
22
|
+
Dir.chdir('src') do
|
23
|
+
system('ruby', 'extconf.rb')
|
24
|
+
system('make')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Rake::TestTask.new('test') do |t|
|
29
|
+
t.pattern = 'test/*_test.rb'
|
30
|
+
t.verbose = true
|
31
|
+
t.ruby_opts = ['-r test/unit', '-I src', '-r zoom']
|
32
|
+
end
|
33
|
+
|
34
|
+
spec = Gem::Specification.new do |s|
|
35
|
+
s.name = 'zoom'
|
36
|
+
s.version = RUBY_ZOOM_VERSION
|
37
|
+
s.homepage = 'http://ruby-zoom.rubyforge.org'
|
38
|
+
s.platform = Gem::Platform::RUBY
|
39
|
+
s.summary = 'Ruby/ZOOM provides a Ruby binding to the Z40.50 Object-Orientation Model (ZOOM), an abstract object-oriented programming interface to a subset of the services specified by the Z39.50 standard, also known as the international standard ISO 23950.'
|
40
|
+
s.autorequire = 'zoom'
|
41
|
+
s.files =
|
42
|
+
Dir.glob('src/*.c') +
|
43
|
+
Dir.glob('src/*.h') +
|
44
|
+
Dir.glob('src/*.rb') +
|
45
|
+
Dir.glob('test/**/*') +
|
46
|
+
Dir.glob('sample/**/*') +
|
47
|
+
['README', 'ChangeLog', 'Rakefile']
|
48
|
+
s.extensions = 'src/extconf.rb'
|
49
|
+
end
|
50
|
+
|
51
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
52
|
+
pkg.need_zip = true
|
53
|
+
pkg.need_tar = true
|
54
|
+
end
|
data/sample/CVS/Entries
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-zoom/sample
|
data/sample/CVS/Root
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
:ext:esummers@rubyforge.org:/var/cvs/ruby-zoom
|
data/sample/hello.rb
ADDED
data/sample/needle.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Given a list of ISBNs and Z39.50 servers, try to get a MARC record
|
4
|
+
# for each book. The servers listed here seem to be the best
|
5
|
+
# worldwide. If an ISBN cannot be found then we use the xisbn service
|
6
|
+
# to try different editions.
|
7
|
+
#
|
8
|
+
# TODO: If more then one record is found, pick the longest one.
|
9
|
+
#
|
10
|
+
# By Devin Bayer - Summer 2006 - Public Domain
|
11
|
+
#
|
12
|
+
#
|
13
|
+
require 'zoom'
|
14
|
+
require 'net/http'
|
15
|
+
Net::HTTP.version_1_2
|
16
|
+
require 'rexml/document'
|
17
|
+
|
18
|
+
servers_source = [
|
19
|
+
# Server, Username, Password
|
20
|
+
[ 'z3950.loc.gov:7090/Voyager' ], # Library of Congress
|
21
|
+
[ 'amicus.nlc-bnc.ca/ANY', 'akvadrako', 'aw4gliu' ], # Canada
|
22
|
+
[ 'catnyp.nypl.org:210/INNOPAC' ], # New York Public
|
23
|
+
[ 'z3950.copac.ac.uk:2100/COPAC' ], # United Kingdom
|
24
|
+
[ 'z3950.btj.se:210/BURK' ], # Sweden
|
25
|
+
[ '195.249.206.204:210/Default' ], # DenMark
|
26
|
+
[ 'library.ox.ac.uk:210/ADVANCE' ], # Oxford
|
27
|
+
[ '216.16.224.199:210/INNOPAC' ], # Cambridge
|
28
|
+
[ 'prodorbis.library.yale.edu:7090/Voyager' ], # Yale
|
29
|
+
[ 'zsrv.library.northwestern.edu:11090/Voyager' ]] # NorthWestern University
|
30
|
+
|
31
|
+
#########################################
|
32
|
+
# Connect to each server
|
33
|
+
#########################################
|
34
|
+
@servers = Array.new
|
35
|
+
|
36
|
+
servers_source.each do |array|
|
37
|
+
tries = 0
|
38
|
+
$stderr.puts 'INFO: connecting to ' + array[0]
|
39
|
+
begin
|
40
|
+
con = ZOOM::Connection.new()
|
41
|
+
con.preferred_record_syntax = 'MARC21'
|
42
|
+
con.element_set_name = 'F'
|
43
|
+
if array[1] then
|
44
|
+
con.user = array[1]
|
45
|
+
con.password = array[2]
|
46
|
+
end
|
47
|
+
con.connect(array[0])
|
48
|
+
@servers << con
|
49
|
+
rescue RuntimeError
|
50
|
+
$stderr.puts 'ERROR: connecting to ' + array[0] + ': ' + $!
|
51
|
+
tries += 1
|
52
|
+
retry if tries < 3
|
53
|
+
$stderr.puts 'WARNING: giving up on ' + array[0]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
#################################
|
58
|
+
# search for ISBN on each server
|
59
|
+
# return true if found
|
60
|
+
#################################
|
61
|
+
def search(isbn)
|
62
|
+
@servers.each do |con|
|
63
|
+
begin
|
64
|
+
rset = con.search("@attr 1=7 #{isbn}")
|
65
|
+
if rset.size > 0 and rset[0].to_s.chomp.length > 1 then
|
66
|
+
$stderr.puts con.host + ': ' + isbn + ': ' +
|
67
|
+
rset.size.to_s + ' records'
|
68
|
+
puts rset[0].raw('marc8')
|
69
|
+
return true
|
70
|
+
end
|
71
|
+
rescue RuntimeError
|
72
|
+
$stderr.puts 'WARNING: ' + con.host + ': ' +
|
73
|
+
isbn + ': ' + $!
|
74
|
+
end
|
75
|
+
end
|
76
|
+
return false
|
77
|
+
end
|
78
|
+
|
79
|
+
#########################################
|
80
|
+
# Lookup each ISBN
|
81
|
+
#########################################
|
82
|
+
failed_isbns = Array.new
|
83
|
+
|
84
|
+
xisbn = Net::HTTP.new('labs.oclc.org')
|
85
|
+
|
86
|
+
File.open('isbns').each_line do |isbn|
|
87
|
+
isbn = isbn.chomp.upcase
|
88
|
+
next if isbn.length < 1
|
89
|
+
if not search(isbn) then
|
90
|
+
tries = 0
|
91
|
+
# Try alternate editions
|
92
|
+
begin
|
93
|
+
xisbn.start if not xisbn.started?
|
94
|
+
xml = xisbn.get("/xisbn/#{isbn}").body
|
95
|
+
rescue SocketError, Errno::ECONNRESET, Errno::EPIPE, EOFError, Timeout::Error
|
96
|
+
xisbn.finish if xisbn.started?
|
97
|
+
if tries < 3 then
|
98
|
+
tries += 1
|
99
|
+
retry
|
100
|
+
else
|
101
|
+
$stderr.puts "ERROR: xisbn failure: " + $!
|
102
|
+
end
|
103
|
+
end
|
104
|
+
found = false
|
105
|
+
REXML::Document.new(xml).root.each_element do |elem|
|
106
|
+
alt = elem.texts.to_s.chomp.upcase
|
107
|
+
next if alt == isbn
|
108
|
+
if search(alt) then
|
109
|
+
$stderr.puts "INFO: alternate for #{isbn}: #{alt}"
|
110
|
+
found = true
|
111
|
+
break
|
112
|
+
end
|
113
|
+
end
|
114
|
+
if not found then
|
115
|
+
$stderr.puts "INFO: isbn #{isbn} not found"
|
116
|
+
failed_isbns << isbn
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
if failed_isbns.size > 0 then
|
122
|
+
$stderr.puts "ISBN's not found:"
|
123
|
+
failed_isbns.each { |isbn| $stderr.puts isbn }
|
124
|
+
end
|
data/src/extconf.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
unless system('yaz-config')
|
4
|
+
$stderr.puts 'yaz does not appear to be installed'
|
5
|
+
break
|
6
|
+
end
|
7
|
+
|
8
|
+
unless have_header('yaz/zoom.h')
|
9
|
+
$stderr.puts 'yaz zoom header not available'
|
10
|
+
break
|
11
|
+
end
|
12
|
+
|
13
|
+
$CFLAGS << " #{`yaz-config --cflags`} "
|
14
|
+
$LDFLAGS << " #{`yaz-config --libs`} "
|
15
|
+
|
16
|
+
create_makefile("zoom")
|
17
|
+
|
data/src/rbzoom.c
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2005 Laurent Sansonetti <lrz@chopine.be>
|
3
|
+
*
|
4
|
+
* This library is free software; you can redistribute it and/or
|
5
|
+
* modify it under the terms of the GNU Lesser General Public
|
6
|
+
* License as published by the Free Software Foundation; either
|
7
|
+
* version 2.1 of the License, or (at your option) any later version.
|
8
|
+
*
|
9
|
+
* This library is distributed in the hope that it will be useful,
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
* Lesser General Public License for more details.
|
13
|
+
*
|
14
|
+
* You should have received a copy of the GNU Lesser General Public
|
15
|
+
* License along with this library; if not, write to the Free Software
|
16
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "rbzoom.h"
|
20
|
+
|
21
|
+
void
|
22
|
+
Init_zoom (void)
|
23
|
+
{
|
24
|
+
VALUE mZoom;
|
25
|
+
|
26
|
+
mZoom = rb_define_module ("ZOOM");
|
27
|
+
|
28
|
+
Init_zoom_connection (mZoom);
|
29
|
+
Init_zoom_query (mZoom);
|
30
|
+
Init_zoom_resultset (mZoom);
|
31
|
+
Init_zoom_record (mZoom);
|
32
|
+
}
|