xisbn 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/.svn/README.txt +2 -0
- data/lib/.svn/dir-wcprops +5 -0
- data/lib/.svn/empty-file +0 -0
- data/lib/.svn/entries +22 -0
- data/lib/.svn/format +1 -0
- data/lib/.svn/prop-base/xisbn.rb.svn-base +1 -0
- data/lib/.svn/props/xisbn.rb.svn-work +1 -0
- data/lib/.svn/text-base/xisbn.rb.svn-base +18 -0
- data/lib/.svn/wcprops/xisbn.rb.svn-work +5 -0
- data/lib/xisbn.rb +18 -0
- data/test.rb +23 -0
- metadata +58 -0
data/lib/.svn/README.txt
ADDED
data/lib/.svn/empty-file
ADDED
File without changes
|
data/lib/.svn/entries
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<wc-entries
|
3
|
+
xmlns="svn:">
|
4
|
+
<entry
|
5
|
+
committed-rev="372"
|
6
|
+
name=""
|
7
|
+
committed-date="2006-02-28T06:34:26.176837Z"
|
8
|
+
url="http://www.textualize.com/svn/xisbn/trunk/lib"
|
9
|
+
last-author="ed"
|
10
|
+
kind="dir"
|
11
|
+
uuid="4dc5e89f-90f6-0310-ab54-a6a856e7c30e"
|
12
|
+
revision="372"/>
|
13
|
+
<entry
|
14
|
+
committed-rev="372"
|
15
|
+
name="xisbn.rb"
|
16
|
+
text-time="2006-02-28T15:20:47.000000Z"
|
17
|
+
committed-date="2006-02-28T06:34:26.176837Z"
|
18
|
+
checksum="2b6d73e6e65a5c3ab351fe1b4040693e"
|
19
|
+
last-author="ed"
|
20
|
+
kind="file"
|
21
|
+
prop-time="2006-02-28T15:20:47.000000Z"/>
|
22
|
+
</wc-entries>
|
data/lib/.svn/format
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
4
|
@@ -0,0 +1 @@
|
|
1
|
+
END
|
@@ -0,0 +1 @@
|
|
1
|
+
END
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
# pass in an ISBN and get back a list of related isbns
|
5
|
+
# as defined by the OCLC xisbn webservice at
|
6
|
+
# http://www.oclc.org/research/projects/xisbn/
|
7
|
+
|
8
|
+
def xisbn(isbn)
|
9
|
+
clean_isbn = isbn.gsub(/[^0-9X]/,'')
|
10
|
+
|
11
|
+
xml = Net::HTTP.get('labs.oclc.org', "/xisbn/#{clean_isbn}")
|
12
|
+
doc = REXML::Document.new(xml)
|
13
|
+
|
14
|
+
isbns = []
|
15
|
+
doc.elements.each('idlist/isbn') {|e| isbns << e.text}
|
16
|
+
|
17
|
+
return isbns
|
18
|
+
end
|
data/lib/xisbn.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
# pass in an ISBN and get back a list of related isbns
|
5
|
+
# as defined by the OCLC xisbn webservice at
|
6
|
+
# http://www.oclc.org/research/projects/xisbn/
|
7
|
+
|
8
|
+
def xisbn(isbn)
|
9
|
+
clean_isbn = isbn.gsub(/[^0-9X]/,'')
|
10
|
+
|
11
|
+
xml = Net::HTTP.get('labs.oclc.org', "/xisbn/#{clean_isbn}")
|
12
|
+
doc = REXML::Document.new(xml)
|
13
|
+
|
14
|
+
isbns = []
|
15
|
+
doc.elements.each('idlist/isbn') {|e| isbns << e.text}
|
16
|
+
|
17
|
+
return isbns
|
18
|
+
end
|
data/test.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.unshift 'lib'
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'xisbn'
|
5
|
+
|
6
|
+
class XISBNTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_lookup
|
9
|
+
isbns = xisbn('0192816640')
|
10
|
+
assert isbns.length > 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_lookup_with_dashes
|
14
|
+
isbns = xisbn('01928-16-640')
|
15
|
+
assert isbns.length > 0
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_bad_lookup
|
19
|
+
isbns = xisbn('foobar')
|
20
|
+
assert isbns.length == 0
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: xisbn
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2006-02-28 00:00:00.000000 -06:00
|
8
|
+
summary: look up related isbns with OCLCs xisbn service
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: ehs@pobox.com
|
12
|
+
homepage: http://www.textualize.com/xisbn
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire: xisbn
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: ruby
|
27
|
+
signing_key:
|
28
|
+
cert_chain:
|
29
|
+
authors:
|
30
|
+
- Ed Summers
|
31
|
+
files:
|
32
|
+
- lib/xisbn.rb
|
33
|
+
- lib/.svn/dir-wcprops
|
34
|
+
- lib/.svn/empty-file
|
35
|
+
- lib/.svn/entries
|
36
|
+
- lib/.svn/format
|
37
|
+
- lib/.svn/prop-base
|
38
|
+
- lib/.svn/props
|
39
|
+
- lib/.svn/README.txt
|
40
|
+
- lib/.svn/text-base
|
41
|
+
- lib/.svn/tmp
|
42
|
+
- lib/.svn/wcprops
|
43
|
+
- lib/.svn/prop-base/xisbn.rb.svn-base
|
44
|
+
- lib/.svn/props/xisbn.rb.svn-work
|
45
|
+
- lib/.svn/text-base/xisbn.rb.svn-base
|
46
|
+
- lib/.svn/tmp/prop-base
|
47
|
+
- lib/.svn/tmp/props
|
48
|
+
- lib/.svn/tmp/text-base
|
49
|
+
- lib/.svn/tmp/wcprops
|
50
|
+
- lib/.svn/wcprops/xisbn.rb.svn-work
|
51
|
+
test_files:
|
52
|
+
- test.rb
|
53
|
+
rdoc_options: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
executables: []
|
56
|
+
extensions: []
|
57
|
+
requirements: []
|
58
|
+
dependencies: []
|