rbook 0.4.1 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/examples/gbip.rb +2 -2
- data/examples/pacstream.rb +2 -3
- data/examples/titlepage_www.rb +18 -0
- data/examples/www/find_cover_from_amazon.rb +5 -1
- data/lib/rbook/bisac/po.rb +10 -0
- data/lib/rbook/bisac/po_line_item.rb +1 -0
- data/lib/rbook/gbip.rb +2 -0
- data/lib/rbook/gbip/pos.rb +84 -6
- data/lib/rbook/gbip/title.rb +36 -0
- data/lib/rbook/gbip/warehouse.rb +27 -0
- data/lib/rbook/isbn.rb +8 -2
- data/lib/rbook/onix/message.rb +7 -1
- data/lib/rbook/pacstream.rb +16 -10
- data/lib/rbook/titlepage.rb +1 -0
- data/lib/rbook/titlepage/wwwclient.rb +96 -0
- data/lib/rbook/www.rb +1 -1
- data/lib/rbook/www/ban_scraper.rb +62 -0
- data/test/unit/bisac/po_test.rb +3 -0
- data/test/unit/isbn_test.rb +5 -1
- metadata +25 -21
- data/examples/43.ord +0 -18
data/Rakefile
CHANGED
data/examples/gbip.rb
CHANGED
@@ -7,6 +7,6 @@ require File.dirname(__FILE__) + '/../lib/rbook/gbip'
|
|
7
7
|
|
8
8
|
gbip = RBook::GBIP::POS.new("username", "password")
|
9
9
|
|
10
|
-
puts gbip.find("0091835135").inspect
|
11
|
-
|
10
|
+
#puts gbip.find("0091835135").inspect
|
11
|
+
puts gbip.find("1741146712").inspect
|
12
12
|
|
data/examples/pacstream.rb
CHANGED
@@ -7,8 +7,7 @@ require File.dirname(__FILE__) + '/../lib/rbook/pacstream'
|
|
7
7
|
|
8
8
|
counter = 0
|
9
9
|
|
10
|
-
RBook::Pacstream.get(:orders, :username => "
|
11
|
-
|
12
|
-
puts order
|
10
|
+
RBook::Pacstream.get(:orders, :username => "myusername", :password => "mypass") do |order|
|
11
|
+
File.open("#{counter.to_s}.ord", "w") { |f| f.puts order }
|
13
12
|
counter += 1
|
14
13
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# assuming you have rbook installed via rubygems,
|
2
|
+
# in a regular script, replace the following require
|
3
|
+
# line with these 2 lines:
|
4
|
+
# require 'rubygems'
|
5
|
+
# require 'rbook/titlepage'
|
6
|
+
require File.dirname(__FILE__) + '/../lib/rbook/titlepage'
|
7
|
+
require File.dirname(__FILE__) + '/../lib/rbook/onix'
|
8
|
+
|
9
|
+
client = RBook::TitlePage::WWWClient.new
|
10
|
+
|
11
|
+
client.login("username", "password")
|
12
|
+
|
13
|
+
text = client.get_onix_file("9780060000707")
|
14
|
+
#msg = RBook::Onix::Message.load_from_string(text)
|
15
|
+
#puts msg.to_s
|
16
|
+
puts text
|
17
|
+
|
18
|
+
client.logout
|
@@ -8,5 +8,9 @@
|
|
8
8
|
require File.dirname(__FILE__) + '/../../lib/rbook/www'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
result = RBook::WWW.find_cover(:first, ARGV[0], :amazon_uk)
|
12
|
+
|
13
|
+
unless result.nil?
|
14
|
+
File.open("cover.jpg","w") { |of| of.write result[:data]}
|
15
|
+
end
|
12
16
|
|
data/lib/rbook/bisac/po.rb
CHANGED
@@ -73,6 +73,16 @@ module RBook
|
|
73
73
|
# load each lineitem into the message
|
74
74
|
item = RBook::Bisac::POLineItem.load_from_string(line)
|
75
75
|
msg.items << item
|
76
|
+
when "41"
|
77
|
+
if line.length > 21
|
78
|
+
title = line[21, line.length - 21]
|
79
|
+
msg.items.last.title = title.strip unless title.nil?
|
80
|
+
end
|
81
|
+
when "42"
|
82
|
+
if line.length > 21
|
83
|
+
author = line[21, line.length - 21]
|
84
|
+
msg.items.last.author = author.strip unless author.nil?
|
85
|
+
end
|
76
86
|
when "90" # footer
|
77
87
|
# check the built objects match the file
|
78
88
|
end
|
@@ -9,6 +9,7 @@ module RBook
|
|
9
9
|
|
10
10
|
attr_accessor :sequence_number, :po_number, :line_item_number
|
11
11
|
attr_accessor :isbn, :qty, :catalogue_code, :price
|
12
|
+
attr_accessor :author, :title
|
12
13
|
|
13
14
|
# returns a new RBook::Bisac::POLineItem object using the data passed in as a string
|
14
15
|
# refer to the bisac spec for the expected format of the string
|
data/lib/rbook/gbip.rb
CHANGED
data/lib/rbook/gbip/pos.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'socket'
|
2
|
+
require 'enumerator'
|
2
3
|
|
3
4
|
module RBook
|
4
5
|
|
@@ -8,7 +9,8 @@ module RBook
|
|
8
9
|
# RBook::GBIP has basic usage examples.
|
9
10
|
class POS
|
10
11
|
|
11
|
-
|
12
|
+
# don't think we really need these
|
13
|
+
#attr_accessor :username, :password
|
12
14
|
|
13
15
|
POS_SERVER = "pos.bowker.com"
|
14
16
|
POS_PORT = 7052
|
@@ -21,18 +23,94 @@ module RBook
|
|
21
23
|
|
22
24
|
# search for the specified ISBN on globalbooksinprint.com.
|
23
25
|
# Accepts both ISBN10 and ISBN13's.
|
24
|
-
def find(isbn)
|
26
|
+
def find(type, isbn, options = {})
|
27
|
+
if type != :first && type != :all
|
28
|
+
raise ArgumentError, 'type must by :first or :all'
|
29
|
+
end
|
30
|
+
|
31
|
+
# global only accepts ISBNs as 10 digits at this stage
|
25
32
|
isbn = RBook::ISBN::convert_to_isbn10(isbn)
|
26
33
|
return nil if isbn.nil?
|
27
34
|
|
28
|
-
|
35
|
+
request_format = "POS"
|
36
|
+
account_type = "3"
|
37
|
+
product = "2"
|
38
|
+
username = "#{@username}"
|
39
|
+
password = "#{@password}"
|
40
|
+
version = "2"
|
41
|
+
supplier = ""
|
42
|
+
request = "bn=#{isbn}"
|
43
|
+
filters = "1|1|1|1|1|1|1|1|1|1"
|
44
|
+
if type.eql?(:first)
|
45
|
+
records = "1,0"
|
46
|
+
else
|
47
|
+
records = "10,0"
|
48
|
+
end
|
49
|
+
sort_order = "1"
|
50
|
+
markets = options[:markets] || ""
|
51
|
+
|
52
|
+
request_string = "#{request_format}\t#{account_type}\t#{product}\t#{username}\t#{password}\t"
|
53
|
+
request_string << "#{version}\t#{supplier}\t#{request}\t#{filters}\t#{records}\t#{sort_order}\t"
|
54
|
+
request_string << "#{markets}\t"
|
55
|
+
|
29
56
|
gbip = TCPSocket.new(POS_SERVER, POS_PORT)
|
30
|
-
gbip.print
|
31
|
-
response = gbip.gets(nil)
|
57
|
+
gbip.print request_string
|
58
|
+
response = gbip.gets(nil).split("#")
|
32
59
|
gbip.close
|
33
|
-
|
60
|
+
|
61
|
+
header = nil
|
62
|
+
titles_arr = []
|
63
|
+
response.each do |arr|
|
64
|
+
if header.nil?
|
65
|
+
header = arr.split("\t")
|
66
|
+
else
|
67
|
+
titles_arr << arr.split("\t")
|
68
|
+
titles_arr[-1] = titles_arr.last[1,titles_arr.last.size-1]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# raise an exception if incorrect login details were provided
|
73
|
+
if header.first.eql?("66")
|
74
|
+
raise ArgumentError, "Invalid username or password"
|
75
|
+
end
|
76
|
+
|
77
|
+
if titles_arr.size == 0
|
78
|
+
# return nil if no matching records found
|
79
|
+
return nil
|
80
|
+
else
|
81
|
+
|
82
|
+
titles = []
|
83
|
+
titles_arr.each do |arr|
|
84
|
+
title = build_object_tree(arr)
|
85
|
+
titles << title unless title.nil?
|
86
|
+
end
|
87
|
+
|
88
|
+
if type.eql?(:first)
|
89
|
+
return titles.first
|
90
|
+
else
|
91
|
+
return titles
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
34
95
|
end
|
35
96
|
|
97
|
+
private
|
98
|
+
|
99
|
+
def build_object_tree(arr)
|
100
|
+
raise ArgumentError, 'arr must be an array' unless arr.class == Array
|
101
|
+
return nil if arr.size < 18
|
102
|
+
|
103
|
+
title_arr = arr[0, 15]
|
104
|
+
warehouse_arr = arr[15,arr.size - 15]
|
105
|
+
title = Title.new(title_arr)
|
106
|
+
|
107
|
+
warehouse_arr.each_slice(5) do |slice|
|
108
|
+
warehouse_obj = Warehouse.new(slice)
|
109
|
+
title.warehouses << warehouse_obj unless warehouse_obj.nil?
|
110
|
+
end
|
111
|
+
|
112
|
+
return title
|
113
|
+
end
|
36
114
|
end
|
37
115
|
|
38
116
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'bigdecimal'
|
2
|
+
|
3
|
+
module RBook
|
4
|
+
module GBIP
|
5
|
+
|
6
|
+
# models a warehouse supply detail from the Global Books in Print API
|
7
|
+
class Title
|
8
|
+
|
9
|
+
|
10
|
+
attr_accessor :market, :title, :isbn, :binding, :status, :edition
|
11
|
+
attr_accessor :contributor, :publisher, :publication_date
|
12
|
+
attr_accessor :rrp, :supplier, :suppliers_with_stock
|
13
|
+
attr_accessor :warehouses
|
14
|
+
|
15
|
+
def initialize(arr)
|
16
|
+
raise ArgumentError, "arr must be an array" unless arr.class == Array
|
17
|
+
#raise ArgumentError, "Invalid number of array elements" unless arr.size == 14
|
18
|
+
|
19
|
+
self.market = arr[2].strip
|
20
|
+
self.title = arr[3].strip
|
21
|
+
self.isbn = RBook::ISBN.convert_to_isbn13(arr[4].strip) || arr[4].strip
|
22
|
+
self.binding = arr[5].strip
|
23
|
+
self.status = arr[6].strip
|
24
|
+
self.edition = arr[7].strip
|
25
|
+
self.contributor = arr[8].strip
|
26
|
+
self.publisher = arr[9].strip
|
27
|
+
self.publication_date = arr[10].strip
|
28
|
+
self.rrp = BigDecimal.new(arr[11].strip)
|
29
|
+
self.supplier = arr[12].strip
|
30
|
+
self.suppliers_with_stock = arr[13].strip
|
31
|
+
|
32
|
+
@warehouses = []
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module RBook
|
4
|
+
module GBIP
|
5
|
+
|
6
|
+
# models a warehouse supply detail from the Global Books in Print API
|
7
|
+
class Warehouse
|
8
|
+
|
9
|
+
|
10
|
+
attr_accessor :name, :status, :onhand, :onorder, :updated_at
|
11
|
+
|
12
|
+
def initialize(arr)
|
13
|
+
raise ArgumentError, "arr must be an array" unless arr.class == Array
|
14
|
+
raise ArgumentError, "Invalid number of array elements" unless arr.size == 5
|
15
|
+
|
16
|
+
puts arr.inspect
|
17
|
+
self.name = arr[0].strip
|
18
|
+
self.status = arr[1].strip
|
19
|
+
self.onhand = arr[2].to_i
|
20
|
+
self.onorder = arr[3].to_i
|
21
|
+
tmpdate = arr[4]
|
22
|
+
puts tmpdate
|
23
|
+
self.updated_at = Date.civil(tmpdate[6,4].to_i, tmpdate[0,2].to_i, tmpdate[3,2].to_i)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/rbook/isbn.rb
CHANGED
@@ -31,7 +31,6 @@ module RBook
|
|
31
31
|
calc = calc.insert(15, "-")
|
32
32
|
return calc
|
33
33
|
end
|
34
|
-
|
35
34
|
end
|
36
35
|
|
37
36
|
# Returns true if the supplied string is a valid isbn10 or isbn13
|
@@ -59,6 +58,7 @@ module RBook
|
|
59
58
|
# ISBN::valid_isbn10?("not an isbn")
|
60
59
|
# #=> false
|
61
60
|
def ISBN::valid_isbn10?(isbn)
|
61
|
+
isbn.gsub!("-","") if isbn.class == String
|
62
62
|
if isbn.nil?
|
63
63
|
false
|
64
64
|
elsif isbn.class != String
|
@@ -68,7 +68,12 @@ module RBook
|
|
68
68
|
elsif isbn[/[^\dxX]/]
|
69
69
|
false
|
70
70
|
else
|
71
|
-
|
71
|
+
checkdigit = ISBN::calc_isbn10_check(isbn.to_s[0,9])
|
72
|
+
if checkdigit.eql?("X")
|
73
|
+
isbn == isbn[0,9] + "x" || isbn == isbn[0,9] + "X"
|
74
|
+
else
|
75
|
+
isbn == isbn[0,9] + checkdigit
|
76
|
+
end
|
72
77
|
end
|
73
78
|
end
|
74
79
|
|
@@ -83,6 +88,7 @@ module RBook
|
|
83
88
|
# ISBN::valid_isbn13?("not an isbn")
|
84
89
|
# #=> false
|
85
90
|
def ISBN::valid_isbn13?(isbn)
|
91
|
+
isbn.gsub!("-","") if isbn.class == String
|
86
92
|
if isbn.nil?
|
87
93
|
false
|
88
94
|
elsif isbn.class != String
|
data/lib/rbook/onix/message.rb
CHANGED
@@ -15,8 +15,14 @@ module RBook
|
|
15
15
|
@products = []
|
16
16
|
end
|
17
17
|
|
18
|
+
# Attempts to create a message object using thge supplied xml string
|
19
|
+
def self.load_from_string(str)
|
20
|
+
doc = REXML::Document.new(str)
|
21
|
+
self.load_from_xmldoc(doc)
|
22
|
+
end
|
23
|
+
|
18
24
|
# Attempts to create a message object using thge supplied xml document
|
19
|
-
def
|
25
|
+
def self.load_from_xmldoc(doc)
|
20
26
|
raise ArgumentError, 'load_from_xmldoc expects a REXML document object' unless doc.class == REXML::Document
|
21
27
|
if REXML::XPath.first(doc, '/ONIXMessage/').nil? ||
|
22
28
|
REXML::XPath.first(doc, '/ONIXMessage/Header').nil? ||
|
data/lib/rbook/pacstream.rb
CHANGED
@@ -36,19 +36,25 @@ module RBook
|
|
36
36
|
server = args[0][:servername] || "pacstream.tedis.com.au"
|
37
37
|
|
38
38
|
begin
|
39
|
+
transaction_complete = false
|
39
40
|
Net::FTP.open(server) do |ftp|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
|
42
|
+
file_regexp = Regexp.new(".*\.#{FILE_EXTENSIONS[type]}$", Regexp::IGNORECASE)
|
43
|
+
ftp.login(args[0][:username].to_s, args[0][:password].to_s)
|
44
|
+
ftp.chdir("outgoing/")
|
45
|
+
ftp.nlst.each do |file|
|
46
|
+
if file.match(file_regexp)
|
47
|
+
tempfile = Tempfile.new("pacstream")
|
48
|
+
tempfile.close
|
49
|
+
ftp.getbinaryfile(file, tempfile.path)
|
50
|
+
yield File.read(tempfile.path)
|
51
|
+
end
|
49
52
|
end
|
50
|
-
|
53
|
+
transaction_complete = true
|
54
|
+
#ftp.quit
|
51
55
|
end
|
56
|
+
rescue EOFError
|
57
|
+
raise "Connection terminated by remote server" unless transaction_complete
|
52
58
|
rescue Net::FTPPermError
|
53
59
|
raise "Error while communicating with the pacstream server"
|
54
60
|
end
|
data/lib/rbook/titlepage.rb
CHANGED
@@ -0,0 +1,96 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/../")
|
2
|
+
|
3
|
+
require 'rbook/isbn'
|
4
|
+
require 'rbook/errors'
|
5
|
+
|
6
|
+
module RBook
|
7
|
+
module TitlePage
|
8
|
+
|
9
|
+
# You should be aware of any limits of query volume imposed by the provider - currently a
|
10
|
+
# maximum of 30 queries per minute is permitted.
|
11
|
+
class WWWClient
|
12
|
+
|
13
|
+
TITLEPAGE_DOMAIN = "www.titlepage.com"
|
14
|
+
@@uri = nil
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_onix_file(isbn)
|
20
|
+
isbn = RBook::ISBN.convert_to_isbn13(isbn)
|
21
|
+
raise ArgumentError, 'Invalid ISBN supplied' if isbn.nil?
|
22
|
+
|
23
|
+
headers = { 'Cookie' => @cookie }
|
24
|
+
|
25
|
+
login_response = Net::HTTP.start(TITLEPAGE_DOMAIN, 80) do |http|
|
26
|
+
data = [
|
27
|
+
"posted=yes",
|
28
|
+
"quicksearch=#{isbn}",
|
29
|
+
"qsrchby=ean",
|
30
|
+
"detailed=Search"
|
31
|
+
].join("&")
|
32
|
+
http.post('/results.php', data, headers)
|
33
|
+
end
|
34
|
+
regex = /onclick=\"bookPopUp\(\'(.+)\'\);\"/
|
35
|
+
code = login_response.body.match(regex)
|
36
|
+
if code.nil?
|
37
|
+
return nil
|
38
|
+
else
|
39
|
+
code = code[1]
|
40
|
+
end
|
41
|
+
onix_file = Net::HTTP.start(TITLEPAGE_DOMAIN, 80) do |http|
|
42
|
+
data = [
|
43
|
+
"download=Download",
|
44
|
+
"rr=#{code}"
|
45
|
+
].join("&")
|
46
|
+
http.post('/detail.php', data, headers)
|
47
|
+
end
|
48
|
+
return onix_file.body
|
49
|
+
end
|
50
|
+
|
51
|
+
# login to the titlepage website.
|
52
|
+
def login(username, password)
|
53
|
+
login_response = Net::HTTP.start(TITLEPAGE_DOMAIN, 80) do |http|
|
54
|
+
data = [
|
55
|
+
"usr=#{username}",
|
56
|
+
"pwd=#{password}",
|
57
|
+
"login=Login"
|
58
|
+
].join("&")
|
59
|
+
http.post('/index.php', data)
|
60
|
+
end
|
61
|
+
@cookie = login_response['set-cookie']
|
62
|
+
end
|
63
|
+
|
64
|
+
# logout from the titlepage API
|
65
|
+
def logout
|
66
|
+
if @cookie
|
67
|
+
login_response = Net::HTTP.start(TITLEPAGE_DOMAIN, 80) do |http|
|
68
|
+
http.get("/logout.php")
|
69
|
+
end
|
70
|
+
@cookie = nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# a convenience method to make queries to title page a little cleaner. This function
|
75
|
+
# essentially calls the login and logout functions for you automatically.
|
76
|
+
#
|
77
|
+
# RBook::TitlePage::WWWClient.open("username","password") do |tp|
|
78
|
+
# result = tp.get_onix_file("9780091835132")
|
79
|
+
# end
|
80
|
+
def self.open(username, password)
|
81
|
+
|
82
|
+
tp = self.new
|
83
|
+
|
84
|
+
begin
|
85
|
+
tp.login(username, password)
|
86
|
+
|
87
|
+
yield(tp)
|
88
|
+
|
89
|
+
ensure
|
90
|
+
tp.logout
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/rbook/www.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
module RBook
|
3
|
+
module WWW
|
4
|
+
|
5
|
+
class BarnesAndNobleScraper < Base
|
6
|
+
|
7
|
+
SCRAPER_ID = :barnesandnoble
|
8
|
+
SCRAPER_NAME = "Barnes and Noble".freeze
|
9
|
+
SCRAPER_SITE = "http://www.barnesandnole.com/".freeze
|
10
|
+
|
11
|
+
add_scraper( self )
|
12
|
+
|
13
|
+
def get_info(isbn)
|
14
|
+
|
15
|
+
@protocol = "http://"
|
16
|
+
@host = "search.barnesandnoble.com"
|
17
|
+
@path = "/booksearch/isbninquiry.asp?z=y&cds2Pid=9481&isbn="
|
18
|
+
@imgviewer_path = "/booksearch/imageviewer.asp?z=y&ean="
|
19
|
+
@link = @protocol + @host + @path + ISBN::convert_to_isbn10(isbn)
|
20
|
+
@imgviewer_link = @protocol + @host + @imgviewer_path + ISBN::convert_to_isbn10(isbn)
|
21
|
+
|
22
|
+
main = Scraper.define do
|
23
|
+
process "h1#title", :title => :text
|
24
|
+
process "h2#contributor>a", :author => :text
|
25
|
+
process "li.format", :form => :text
|
26
|
+
process "div#coverImage>a>noscript>img", :cover_thumb => "@src"
|
27
|
+
result :title, :author, :form, :cover_thumb
|
28
|
+
end
|
29
|
+
|
30
|
+
imgscraper = Scraper.define do
|
31
|
+
process "div>img[alt=Cover Image]", :cover_large => "@src"
|
32
|
+
result :cover_large
|
33
|
+
end
|
34
|
+
|
35
|
+
content = Net::HTTP.get URI.parse(@link)
|
36
|
+
result = main.scrape(content)
|
37
|
+
if result.title.nil?
|
38
|
+
return nil
|
39
|
+
else
|
40
|
+
|
41
|
+
info = {}
|
42
|
+
info[:isbn] = isbn
|
43
|
+
info[:title] = result.title unless result.title.nil?
|
44
|
+
info[:author] = result.author unless result.author.nil?
|
45
|
+
info[:format] = result.form unless result.form.nil?
|
46
|
+
info[:cover_thumb] = result.cover_thumb
|
47
|
+
info[:link] = @link
|
48
|
+
info[:from_name] = SCRAPER_NAME
|
49
|
+
info[:from_url] = SCRAPER_SITE
|
50
|
+
|
51
|
+
content = Net::HTTP.get URI.parse(@imgviewer_link)
|
52
|
+
result = imgscraper.scrape(content)
|
53
|
+
|
54
|
+
info[:cover_large] = result unless result.nil?
|
55
|
+
|
56
|
+
return info
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/test/unit/bisac/po_test.rb
CHANGED
@@ -26,6 +26,9 @@ class POTest < Test::Unit::TestCase
|
|
26
26
|
assert_kind_of RBook::Bisac::PO, msg
|
27
27
|
assert_equal msg.items.size, 36
|
28
28
|
|
29
|
+
assert_equal "Finding Sanctuary :Monastic St", msg.items.first.title
|
30
|
+
assert_equal "JAMISON ABBOT CHRISTOPH", msg.items.first.author
|
31
|
+
|
29
32
|
validate_msg(msg)
|
30
33
|
end
|
31
34
|
|
data/test/unit/isbn_test.rb
CHANGED
@@ -32,6 +32,8 @@ include RBook
|
|
32
32
|
assert_equal ISBN::valid_isbn10?('020161622X'), true
|
33
33
|
assert_equal ISBN::valid_isbn10?('020161622'), false
|
34
34
|
assert_equal ISBN::valid_isbn10?('023252565X'), true
|
35
|
+
assert_equal ISBN::valid_isbn10?('023252565x'), true
|
36
|
+
assert_equal ISBN::valid_isbn10?('020-161-622-X'), true
|
35
37
|
assert_equal ISBN::valid_isbn10?('9780764812200'), false
|
36
38
|
assert_equal ISBN::valid_isbn10?('12345'), false
|
37
39
|
assert_equal ISBN::valid_isbn10?('12345 7890'), false
|
@@ -49,6 +51,7 @@ include RBook
|
|
49
51
|
assert_equal ISBN::valid_isbn13?('9780201616224'), true
|
50
52
|
assert_equal ISBN::valid_isbn13?('978020161622'), false
|
51
53
|
assert_equal ISBN::valid_isbn13?('9780764812200'), true
|
54
|
+
assert_equal ISBN::valid_isbn13?('978-02016-1622-4'), true
|
52
55
|
assert_equal ISBN::valid_isbn13?('978076481220'), false
|
53
56
|
assert_equal ISBN::valid_isbn13?('978 NCR 4611'), false
|
54
57
|
assert_equal ISBN::valid_isbn13?('12345'), false
|
@@ -121,8 +124,9 @@ include RBook
|
|
121
124
|
assert_equal ISBN::convert_to_isbn13('0764812203'), '9780764812200'
|
122
125
|
assert_equal ISBN::convert_to_isbn13('1856075338'), '9781856075336'
|
123
126
|
assert_equal ISBN::convert_to_isbn13('023252565X'), '9780232525656'
|
127
|
+
assert_equal ISBN::convert_to_isbn13('023252565x'), '9780232525656'
|
124
128
|
assert_equal ISBN::convert_to_isbn13('1863951342'), '9781863951340'
|
125
|
-
assert_equal ISBN::convert_to_isbn13('186-395-134-2'),
|
129
|
+
assert_equal ISBN::convert_to_isbn13('186-395-134-2'), '9781863951340'
|
126
130
|
|
127
131
|
#already isbn13
|
128
132
|
assert_equal ISBN::convert_to_isbn13('9781856075336'), '9781856075336'
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.1
|
3
3
|
specification_version: 1
|
4
4
|
name: rbook
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date:
|
6
|
+
version: 0.4.3
|
7
|
+
date: 2007-01-25 00:00:00 +11:00
|
8
8
|
summary: A collection of classes and modules for working with bibliographic data
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -31,15 +31,15 @@ authors:
|
|
31
31
|
files:
|
32
32
|
- examples/www
|
33
33
|
- examples/onix
|
34
|
-
- examples/43.ord
|
35
34
|
- examples/titlepage.rb
|
36
35
|
- examples/pacstream.rb
|
37
36
|
- examples/gbip.rb
|
37
|
+
- examples/titlepage_www.rb
|
38
38
|
- examples/titlepage_with_proxy.rb
|
39
|
-
- examples/www/list.rb
|
40
39
|
- examples/www/find_cover_from_amazon.rb
|
41
40
|
- examples/www/find_url_from_rainbow.rb
|
42
41
|
- examples/www/find_all.rb
|
42
|
+
- examples/www/list.rb
|
43
43
|
- examples/onix/stream_reader.rb
|
44
44
|
- lib/rbook
|
45
45
|
- lib/rbook/bisac
|
@@ -47,8 +47,8 @@ files:
|
|
47
47
|
- lib/rbook/www
|
48
48
|
- lib/rbook/onix
|
49
49
|
- lib/rbook/titlepage
|
50
|
-
- lib/rbook/titlepage.rb
|
51
50
|
- lib/rbook/onix.rb
|
51
|
+
- lib/rbook/titlepage.rb
|
52
52
|
- lib/rbook/pacstream.rb
|
53
53
|
- lib/rbook/bisac.rb
|
54
54
|
- lib/rbook/gbip.rb
|
@@ -57,14 +57,16 @@ files:
|
|
57
57
|
- lib/rbook/errors.rb
|
58
58
|
- lib/rbook/bisac/po.rb
|
59
59
|
- lib/rbook/bisac/product.rb
|
60
|
-
- lib/rbook/bisac/message.rb
|
61
60
|
- lib/rbook/bisac/po_line_item.rb
|
61
|
+
- lib/rbook/bisac/message.rb
|
62
62
|
- lib/rbook/gbip/pos.rb
|
63
|
-
- lib/rbook/
|
63
|
+
- lib/rbook/gbip/title.rb
|
64
|
+
- lib/rbook/gbip/warehouse.rb
|
64
65
|
- lib/rbook/www/hha_scraper.rb
|
65
|
-
- lib/rbook/www/
|
66
|
+
- lib/rbook/www/ban_scraper.rb
|
67
|
+
- lib/rbook/www/wiley_us_scraper.rb
|
66
68
|
- lib/rbook/www/oup_scraper.rb
|
67
|
-
- lib/rbook/www/
|
69
|
+
- lib/rbook/www/random_au_scraper.rb
|
68
70
|
- lib/rbook/www/penguin_scraper.rb
|
69
71
|
- lib/rbook/www/harper_au_scraper.rb
|
70
72
|
- lib/rbook/www/aau_scraper.rb
|
@@ -76,9 +78,9 @@ files:
|
|
76
78
|
- lib/rbook/www/random_us_scraper.rb
|
77
79
|
- lib/rbook/www/harper_us_scraper.rb
|
78
80
|
- lib/rbook/www/base.rb
|
81
|
+
- lib/rbook/www/pearson_au_scraper.rb
|
79
82
|
- lib/rbook/www/macmillan_scraper.rb
|
80
83
|
- lib/rbook/onix/lists
|
81
|
-
- lib/rbook/onix/sales_restriction.rb
|
82
84
|
- lib/rbook/onix/stream_reader.rb
|
83
85
|
- lib/rbook/onix/lists.rb
|
84
86
|
- lib/rbook/onix/supply_detail.rb
|
@@ -87,39 +89,41 @@ files:
|
|
87
89
|
- lib/rbook/onix/xchar.rb
|
88
90
|
- lib/rbook/onix/stream_writer.rb
|
89
91
|
- lib/rbook/onix/contributor.rb
|
90
|
-
- lib/rbook/onix/
|
92
|
+
- lib/rbook/onix/sales_restriction.rb
|
91
93
|
- lib/rbook/onix/lists/product_form.rb
|
94
|
+
- lib/rbook/onix/lists/contributor_role.rb
|
92
95
|
- lib/rbook/titlepage/client.rb
|
93
96
|
- lib/rbook/titlepage/titlepage_utils.rb
|
97
|
+
- lib/rbook/titlepage/wwwclient.rb
|
94
98
|
- lib/rbook/titlepage/titlepage_driver.rb
|
95
99
|
- test/unit
|
96
100
|
- test/data
|
97
101
|
- test/mocks
|
102
|
+
- test/unit/bisac
|
98
103
|
- test/unit/onix
|
99
104
|
- test/unit/titlepage_test.rb
|
100
105
|
- test/unit/isbn_test.rb
|
101
|
-
- test/unit/bisac
|
102
|
-
- test/unit/
|
106
|
+
- test/unit/bisac/po_test.rb
|
107
|
+
- test/unit/bisac/bisac_test.rb
|
108
|
+
- test/unit/bisac/po_line_item_test.rb
|
103
109
|
- test/unit/onix/supply_detail_test.rb
|
104
110
|
- test/unit/onix/product_test.rb
|
105
111
|
- test/unit/onix/message_test.rb
|
106
112
|
- test/unit/onix/xchar_test.rb
|
107
113
|
- test/unit/onix/stream_writer_test.rb
|
108
114
|
- test/unit/onix/contributor_test.rb
|
115
|
+
- test/unit/onix/sales_restriction_test.rb
|
109
116
|
- test/unit/onix/stream_reader_test.rb
|
110
|
-
- test/unit/bisac/bisac_test.rb
|
111
|
-
- test/unit/bisac/po_test.rb
|
112
|
-
- test/unit/bisac/po_line_item_test.rb
|
113
|
-
- test/data/xml_not_onix.xml
|
114
117
|
- test/data/abingdon.xml
|
115
|
-
- test/data/invalid_no_product.xml
|
116
118
|
- test/data/single_product.xml
|
119
|
+
- test/data/invalid_no_product.xml
|
117
120
|
- test/data/chalice.xml
|
118
121
|
- test/data/not_xml.csv
|
119
|
-
- test/data/
|
122
|
+
- test/data/xml_not_onix.xml
|
123
|
+
- test/data/bisac_po.txt
|
120
124
|
- test/data/eerdsman.xml
|
121
125
|
- test/data/augsburg.xml
|
122
|
-
- test/data/
|
126
|
+
- test/data/valid_bisac.txt
|
123
127
|
- test/mocks/titlepage_driver.rb
|
124
128
|
- Rakefile
|
125
129
|
- README
|
data/examples/43.ord
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
H,1111111,9021000,,14977,,,,061120,,,,,,,,,,,
|
2
|
-
D,,,9780140441147,,2,,,0.00,,,,
|
3
|
-
D,,,9780142405369,,1,,,0.00,,,,
|
4
|
-
D,,,9780143300373,,1,,,0.00,,,,
|
5
|
-
D,,,9780143300380,,1,,,0.00,,,,
|
6
|
-
D,,,9780349115320,,2,,,0.00,,,,
|
7
|
-
D,,,9780751536829,,2,,,0.00,,,,
|
8
|
-
D,,,9780756614690,,1,,,0.00,,,,
|
9
|
-
D,,,9780782417173,,6,,,0.00,,,,
|
10
|
-
D,,,9780782417340,,9,,,0.00,,,,
|
11
|
-
D,,,9780782442977,,6,,,0.00,,,,
|
12
|
-
D,,,9780782443004,,3,,,0.00,,,,
|
13
|
-
D,,,9780785263135,,1,,,0.00,,,,
|
14
|
-
D,,,9780785283546,,1,,,0.00,,,,
|
15
|
-
D,,,9781405303255,,1,,,0.00,,,,
|
16
|
-
D,,,9781920885151,,10,,,0.00,,,,
|
17
|
-
D,,,9781921145346,,1,,,0.00,,,,
|
18
|
-
S,16,,
|