rbook 0.4.3 → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +13 -176
- metadata +57 -117
- data/COPYING +0 -340
- data/LICENSE +0 -13
- data/README +0 -17
- data/examples/gbip.rb +0 -12
- data/examples/onix/stream_reader.rb +0 -13
- data/examples/pacstream.rb +0 -13
- data/examples/titlepage.rb +0 -14
- data/examples/titlepage_with_proxy.rb +0 -14
- data/examples/titlepage_www.rb +0 -18
- data/examples/www/find_all.rb +0 -23
- data/examples/www/find_cover_from_amazon.rb +0 -16
- data/examples/www/find_url_from_rainbow.rb +0 -12
- data/examples/www/list.rb +0 -13
- data/lib/rbook/bisac.rb +0 -31
- data/lib/rbook/bisac/message.rb +0 -99
- data/lib/rbook/bisac/po.rb +0 -97
- data/lib/rbook/bisac/po_line_item.rb +0 -33
- data/lib/rbook/bisac/product.rb +0 -176
- data/lib/rbook/errors.rb +0 -8
- data/lib/rbook/gbip.rb +0 -21
- data/lib/rbook/gbip/pos.rb +0 -118
- data/lib/rbook/gbip/title.rb +0 -36
- data/lib/rbook/gbip/warehouse.rb +0 -27
- data/lib/rbook/isbn.rb +0 -255
- data/lib/rbook/onix.rb +0 -70
- data/lib/rbook/onix/contributor.rb +0 -60
- data/lib/rbook/onix/lists.rb +0 -2
- data/lib/rbook/onix/lists/contributor_role.rb +0 -10
- data/lib/rbook/onix/lists/product_form.rb +0 -100
- data/lib/rbook/onix/message.rb +0 -112
- data/lib/rbook/onix/product.rb +0 -189
- data/lib/rbook/onix/sales_restriction.rb +0 -51
- data/lib/rbook/onix/stream_reader.rb +0 -120
- data/lib/rbook/onix/stream_writer.rb +0 -40
- data/lib/rbook/onix/supply_detail.rb +0 -68
- data/lib/rbook/onix/xchar.rb +0 -98
- data/lib/rbook/pacstream.rb +0 -64
- data/lib/rbook/titlepage.rb +0 -37
- data/lib/rbook/titlepage/client.rb +0 -126
- data/lib/rbook/titlepage/titlepage_driver.rb +0 -137
- data/lib/rbook/titlepage/titlepage_utils.rb +0 -379
- data/lib/rbook/titlepage/wwwclient.rb +0 -96
- data/lib/rbook/www.rb +0 -172
- data/lib/rbook/www/aau_scraper.rb +0 -76
- data/lib/rbook/www/amazon_uk_scraper.rb +0 -44
- data/lib/rbook/www/ban_scraper.rb +0 -62
- data/lib/rbook/www/base.rb +0 -87
- data/lib/rbook/www/harper_au_scraper.rb +0 -56
- data/lib/rbook/www/harper_us_scraper.rb +0 -55
- data/lib/rbook/www/hha_scraper.rb +0 -50
- data/lib/rbook/www/macmillan_scraper.rb +0 -62
- data/lib/rbook/www/orbis_scraper.rb +0 -48
- data/lib/rbook/www/oup_scraper.rb +0 -64
- data/lib/rbook/www/paulist_scraper.rb +0 -53
- data/lib/rbook/www/pearson_au_scraper.rb +0 -52
- data/lib/rbook/www/penguin_scraper.rb +0 -45
- data/lib/rbook/www/random_au_scraper.rb +0 -90
- data/lib/rbook/www/random_us_scraper.rb +0 -59
- data/lib/rbook/www/sas_scraper.rb +0 -54
- data/lib/rbook/www/unireps_scraper.rb +0 -58
- data/lib/rbook/www/wiley_us_scraper.rb +0 -54
- data/test/data/abingdon.xml +0 -38931
- data/test/data/augsburg.xml +0 -39009
- data/test/data/bisac_po.txt +0 -112
- data/test/data/chalice.xml +0 -10851
- data/test/data/eerdsman.xml +0 -36942
- data/test/data/invalid_no_product.xml +0 -9
- data/test/data/not_xml.csv +0 -1
- data/test/data/single_product.xml +0 -50
- data/test/data/valid_bisac.txt +0 -213
- data/test/data/xml_not_onix.xml +0 -7
- data/test/mocks/titlepage_driver.rb +0 -111
- data/test/unit/bisac/bisac_test.rb +0 -96
- data/test/unit/bisac/po_line_item_test.rb +0 -38
- data/test/unit/bisac/po_test.rb +0 -82
- data/test/unit/isbn_test.rb +0 -153
- data/test/unit/onix/contributor_test.rb +0 -50
- data/test/unit/onix/message_test.rb +0 -119
- data/test/unit/onix/product_test.rb +0 -101
- data/test/unit/onix/sales_restriction_test.rb +0 -48
- data/test/unit/onix/stream_reader_test.rb +0 -22
- data/test/unit/onix/stream_writer_test.rb +0 -32
- data/test/unit/onix/supply_detail_test.rb +0 -53
- data/test/unit/onix/xchar_test.rb +0 -37
- data/test/unit/titlepage_test.rb +0 -140
@@ -1,48 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rexml/document'
|
5
|
-
require 'rbook/onix'
|
6
|
-
|
7
|
-
class SalesRestrictionTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def test_load_from_element
|
10
|
-
|
11
|
-
file = File.open(File.dirname(__FILE__)+"/../../data/single_product.xml", "r")
|
12
|
-
doc = REXML::Document.new(file)
|
13
|
-
restriction = RBook::Onix::SalesRestriction.load_from_element(REXML::XPath.first(doc, '/ONIXMessage/Product/SalesRestriction'))
|
14
|
-
|
15
|
-
file.close
|
16
|
-
|
17
|
-
assert_equal('00', restriction.type)
|
18
|
-
assert_equal('Unknown', restriction.detail)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_load_from_element_not_sales_restriction
|
22
|
-
|
23
|
-
element = REXML::Element.new('NonRestriction')
|
24
|
-
element.add_element('Type').text = 'blah'
|
25
|
-
|
26
|
-
assert_raise(LoadError) {
|
27
|
-
product = RBook::Onix::SalesRestriction.load_from_element(element)
|
28
|
-
}
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
# ensure product information is output to xml correctly
|
33
|
-
def test_to_element
|
34
|
-
|
35
|
-
restriction = RBook::Onix::SalesRestriction.new
|
36
|
-
restriction.type = '00'
|
37
|
-
restriction.detail = 'Unknown'
|
38
|
-
|
39
|
-
doc = restriction.to_element
|
40
|
-
|
41
|
-
assert_not_equal(nil,REXML::XPath.first(doc, '/SalesRestrictionType'), 'Sales Restriction Type must not be nil')
|
42
|
-
assert_equal("00", REXML::XPath.first(doc, '/SalesRestrictionType').text)
|
43
|
-
assert_not_equal(nil,REXML::XPath.first(doc, '/SalesRestrictionDetail'), 'Sales Restriction Detail must not be nil')
|
44
|
-
assert_equal("Unknown", REXML::XPath.first(doc, '/SalesRestrictionDetail').text)
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rexml/document'
|
5
|
-
require 'rbook/onix'
|
6
|
-
|
7
|
-
class TestStreamReader < Test::Unit::TestCase
|
8
|
-
|
9
|
-
# test the stream reader works without throwing an exception
|
10
|
-
def test_stream_reader
|
11
|
-
counter = 0
|
12
|
-
|
13
|
-
assert_nothing_raised() {
|
14
|
-
reader = RBook::Onix::StreamReader.new(File.dirname(__FILE__)+"/../../data/single_product.xml")
|
15
|
-
reader.each do |product|
|
16
|
-
counter += 1
|
17
|
-
end
|
18
|
-
}
|
19
|
-
|
20
|
-
assert_equal 1, counter
|
21
|
-
end
|
22
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rexml/document'
|
5
|
-
require 'rbook/onix'
|
6
|
-
require 'stringio'
|
7
|
-
|
8
|
-
class TestStreamWriter < Test::Unit::TestCase
|
9
|
-
|
10
|
-
# test the stream writer works without throwing an exception
|
11
|
-
def test_stream_writer
|
12
|
-
|
13
|
-
assert_nothing_raised() {
|
14
|
-
reader = RBook::Onix::StreamReader.new(File.dirname(__FILE__)+"/../../data/single_product.xml")
|
15
|
-
|
16
|
-
output = StringIO.new
|
17
|
-
msg = RBook::Onix::Message.new
|
18
|
-
msg.from_company = "Test Company"
|
19
|
-
msg.from_person = "James Healy"
|
20
|
-
|
21
|
-
writer = RBook::Onix::StreamWriter.new(output, msg)
|
22
|
-
writer.start_document
|
23
|
-
|
24
|
-
reader.each do |product|
|
25
|
-
writer << product
|
26
|
-
end
|
27
|
-
|
28
|
-
writer.end_document
|
29
|
-
}
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rexml/document'
|
5
|
-
require 'rbook/onix'
|
6
|
-
|
7
|
-
class SupplyDetailTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def test_load_from_element
|
10
|
-
|
11
|
-
file = File.open(File.dirname(__FILE__)+"/../../data/single_product.xml", "r")
|
12
|
-
doc = REXML::Document.new(file)
|
13
|
-
supply_detail = RBook::Onix::SupplyDetail.load_from_element(REXML::XPath.first(doc, '/ONIXMessage/Product/SupplyDetail'))
|
14
|
-
|
15
|
-
file.close
|
16
|
-
|
17
|
-
assert_equal('Chalice', supply_detail.supplier_name)
|
18
|
-
assert_equal('CS', supply_detail.availability_code)
|
19
|
-
assert_equal('99', supply_detail.intermediary_availability_code)
|
20
|
-
assert_equal(29.95, supply_detail.price)
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_load_from_element_not_supply_detail
|
24
|
-
|
25
|
-
element = REXML::Element.new('NonSupplyDetail')
|
26
|
-
element.add_element('SupplierName').text = 'blah'
|
27
|
-
|
28
|
-
assert_raise(LoadError) {
|
29
|
-
supply_detail = RBook::Onix::SupplyDetail.load_from_element(element)
|
30
|
-
}
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
# ensure product information is output to xml correctly
|
35
|
-
def test_to_element
|
36
|
-
|
37
|
-
supply_detail = RBook::Onix::SupplyDetail.new
|
38
|
-
supply_detail.supplier_name = 'Walker'
|
39
|
-
supply_detail.availability_code = 'CS'
|
40
|
-
supply_detail.price = 38.05
|
41
|
-
|
42
|
-
doc = supply_detail.to_element
|
43
|
-
|
44
|
-
assert_not_equal(nil,REXML::XPath.first(doc, '/SupplierName'), 'Supplier Name must not be nil')
|
45
|
-
assert_equal("Walker", REXML::XPath.first(doc, '/SupplierName').text)
|
46
|
-
assert_not_equal(nil,REXML::XPath.first(doc, '/AvailabilityCode'), 'Availability Code must not be nil')
|
47
|
-
assert_equal("CS", REXML::XPath.first(doc, '/AvailabilityCode').text)
|
48
|
-
assert_not_equal(nil,REXML::XPath.first(doc, '/Price/PriceAmount'), 'Price Amount must not be nil')
|
49
|
-
assert_equal("38.05", REXML::XPath.first(doc, '/Price/PriceAmount').text)
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rbook/onix'
|
5
|
-
|
6
|
-
class TestXmlEscaping < Test::Unit::TestCase
|
7
|
-
def test_ascii
|
8
|
-
assert_equal 'abc', 'abc'.to_xs
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_predefined
|
12
|
-
assert_equal '&', '&'.to_xs # ampersand
|
13
|
-
assert_equal '<', '<'.to_xs # left angle bracket
|
14
|
-
assert_equal '>', '>'.to_xs # right angle bracket
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_invalid
|
18
|
-
assert_equal '*', "\x00".to_xs # null
|
19
|
-
assert_equal '*', "\x0C".to_xs # form feed
|
20
|
-
assert_equal '*', "\xEF\xBF\xBF".to_xs # U+FFFF
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_iso_8859_1
|
24
|
-
assert_equal 'ç', "\xE7".to_xs # small c cedilla
|
25
|
-
assert_equal '©', "\xA9".to_xs # copyright symbol
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_win_1252
|
29
|
-
assert_equal '’', "\x92".to_xs # smart quote
|
30
|
-
assert_equal '€', "\x80".to_xs # euro
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_utf8
|
34
|
-
assert_equal '’', "\xE2\x80\x99".to_xs # right single quote
|
35
|
-
assert_equal '©', "\xC2\xA9".to_xs # copy
|
36
|
-
end
|
37
|
-
end
|
data/test/unit/titlepage_test.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rbook/titlepage'
|
5
|
-
require File.dirname(__FILE__) + '/../mocks/titlepage_driver'
|
6
|
-
|
7
|
-
class TitlePageTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@tp = RBook::TitlePage::Client.new(RBook::TitlePage::MockTitlePageDriver.new)
|
11
|
-
end
|
12
|
-
|
13
|
-
# ensure a SOAP exception is raised if incorrect login details are provided
|
14
|
-
def test_bad_login
|
15
|
-
unless RUBY_VERSION >= "1.8.3"
|
16
|
-
warn "Ruby version >= 1.8.3 required to use the titlepage library. Skipping unit test"
|
17
|
-
return
|
18
|
-
end
|
19
|
-
|
20
|
-
assert_raise(SOAP::FaultError) {
|
21
|
-
@tp.login("bad","login")
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
# ensure searching for a title using the open method works
|
26
|
-
def test_search_using_block
|
27
|
-
unless RUBY_VERSION >= "1.8.3"
|
28
|
-
warn "Ruby version >= 1.8.3 required to use the titlepage library. Skipping unit test"
|
29
|
-
return
|
30
|
-
end
|
31
|
-
|
32
|
-
RBook::TitlePage::Client.open("test","apa", RBook::TitlePage::MockTitlePageDriver.new) do |tp|
|
33
|
-
|
34
|
-
result = tp.find("9780091835132")
|
35
|
-
|
36
|
-
assert_kind_of RBook::TitlePage::SearchResults, result
|
37
|
-
assert_not_equal nil, result.Product
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# ensure searching for a title using the static method works
|
43
|
-
def test_search_using_static_method
|
44
|
-
unless RUBY_VERSION >= "1.8.3"
|
45
|
-
warn "Ruby version >= 1.8.3 required to use the titlepage library. Skipping unit test"
|
46
|
-
return
|
47
|
-
end
|
48
|
-
|
49
|
-
result = RBook::TitlePage::Client.find("test","apa", "9780091835132", RBook::TitlePage::MockTitlePageDriver.new)
|
50
|
-
|
51
|
-
assert_kind_of RBook::TitlePage::SearchResults, result
|
52
|
-
assert_not_equal nil, result.Product
|
53
|
-
end
|
54
|
-
|
55
|
-
# ensure searching for a title that is in stock returns a SearchResults object
|
56
|
-
def test_title_in_stock
|
57
|
-
|
58
|
-
unless RUBY_VERSION >= "1.8.3"
|
59
|
-
warn "Ruby version >= 1.8.3 required to use the titlepage library. Skipping unit test"
|
60
|
-
return
|
61
|
-
end
|
62
|
-
|
63
|
-
@tp.login("test","apa")
|
64
|
-
result = @tp.find("9780091835132")
|
65
|
-
|
66
|
-
assert_kind_of RBook::TitlePage::SearchResults, result
|
67
|
-
assert_not_equal nil, result.Product
|
68
|
-
|
69
|
-
@tp.logout
|
70
|
-
end
|
71
|
-
|
72
|
-
# ensure searching for a title that is out of stock returns a SearchResults object
|
73
|
-
def test_title_no_stock
|
74
|
-
|
75
|
-
unless RUBY_VERSION >= "1.8.3"
|
76
|
-
warn "Ruby version >= 1.8.3 required to use the titlepage library. Skipping unit test"
|
77
|
-
return
|
78
|
-
end
|
79
|
-
|
80
|
-
@tp.login("test","apa")
|
81
|
-
result = @tp.find("9780672327568")
|
82
|
-
|
83
|
-
assert_kind_of RBook::TitlePage::SearchResults, result
|
84
|
-
assert_not_equal nil, result.Product
|
85
|
-
|
86
|
-
@tp.logout
|
87
|
-
end
|
88
|
-
|
89
|
-
# ensure searching for a title that isn't listed on titlepage returns nil
|
90
|
-
def test_title_not_found
|
91
|
-
|
92
|
-
unless RUBY_VERSION >= "1.8.3"
|
93
|
-
warn "Ruby version >= 1.8.3 required to use the titlepage library. Skipping unit test"
|
94
|
-
return
|
95
|
-
end
|
96
|
-
|
97
|
-
@tp.login("test","apa")
|
98
|
-
result = @tp.find("9780522848670")
|
99
|
-
|
100
|
-
assert_equal nil, result
|
101
|
-
|
102
|
-
@tp.logout
|
103
|
-
end
|
104
|
-
|
105
|
-
# ensure searching for whack ISBNs returns nil
|
106
|
-
def test_boundaries
|
107
|
-
|
108
|
-
unless RUBY_VERSION >= "1.8.3"
|
109
|
-
warn "Ruby version >= 1.8.3 required to use the titlepage library. Skipping unit test"
|
110
|
-
return
|
111
|
-
end
|
112
|
-
|
113
|
-
@tp.login("test","apa")
|
114
|
-
|
115
|
-
assert_equal nil, @tp.find("978052284867")
|
116
|
-
assert_equal nil, @tp.find("978-0522-84867")
|
117
|
-
assert_equal nil, @tp.find(nil)
|
118
|
-
assert_equal nil, @tp.find(:test)
|
119
|
-
assert_equal nil, @tp.find(Array.new)
|
120
|
-
assert_equal nil, @tp.find(-1)
|
121
|
-
|
122
|
-
@tp.logout
|
123
|
-
end
|
124
|
-
|
125
|
-
# ensure logging out works
|
126
|
-
def test_logout
|
127
|
-
|
128
|
-
unless RUBY_VERSION >= "1.8.3"
|
129
|
-
warn "Ruby version >= 1.8.3 required to use the titlepage library. Skipping unit test"
|
130
|
-
return
|
131
|
-
end
|
132
|
-
|
133
|
-
@tp.login("test","apa")
|
134
|
-
result = @tp.find("9780522848670")
|
135
|
-
|
136
|
-
assert @tp.logout
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
|