rbook-bisac 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/COPYING +340 -0
- data/LICENSE +13 -0
- data/README +0 -0
- data/Rakefile +90 -0
- data/lib/rbook/bisac.rb +35 -0
- data/lib/rbook/bisac/message.rb +99 -0
- data/lib/rbook/bisac/po.rb +96 -0
- data/lib/rbook/bisac/po_line_item.rb +36 -0
- data/lib/rbook/bisac/product.rb +176 -0
- data/lib/rbook/errors.rb +9 -0
- data/specs/data/bisac_po.bsc +112 -0
- data/specs/data/bisac_po.txt +112 -0
- data/specs/data/bisac_po_no_footer.txt +111 -0
- data/specs/data/bisac_po_no_header.txt +111 -0
- data/specs/data/valid_bisac.txt +213 -0
- data/specs/new_bisac_spec.rb +68 -0
- data/specs/new_po_line_item_spec.rb +31 -0
- data/specs/new_po_spec.rb +66 -0
- metadata +82 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'rbook/bisac'
|
4
|
+
include RBook
|
5
|
+
|
6
|
+
context "A new bisac object" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@valid_item1 = RBook::Bisac::Product.new("0743285689")
|
10
|
+
@valid_item1.title = "Enemy Combatant"
|
11
|
+
@valid_item1.author = "Begg, Moazzam"
|
12
|
+
@valid_item1.price = "2995"
|
13
|
+
@valid_item1.pubdate = "060101"
|
14
|
+
@valid_item1.publisher = "Simon and Schuster"
|
15
|
+
@valid_item1.imprint = "Free Press"
|
16
|
+
@valid_item1.volumes = "1"
|
17
|
+
@valid_item1.edition = "1"
|
18
|
+
@valid_item1.binding = "PB"
|
19
|
+
@valid_item1.volume = "1"
|
20
|
+
@valid_item1.status = "O/O"
|
21
|
+
|
22
|
+
@valid_item2 = RBook::Bisac::Product.new("0975240277")
|
23
|
+
@valid_item2.title = "HTML Utopia Designing Without Tables Using CSS"
|
24
|
+
@valid_item2.author = "Andrew, Rachel; Shafer, Dan"
|
25
|
+
@valid_item2.price = "5995"
|
26
|
+
@valid_item2.pubdate = "060401"
|
27
|
+
@valid_item2.publisher = "Sitepoint"
|
28
|
+
@valid_item2.imprint = "Sitepoint"
|
29
|
+
@valid_item2.volumes = "1"
|
30
|
+
@valid_item2.edition = "2"
|
31
|
+
@valid_item2.binding = "PB"
|
32
|
+
@valid_item2.volume = "1"
|
33
|
+
@valid_item2.status = "ACT"
|
34
|
+
end
|
35
|
+
|
36
|
+
specify "Should have product lines that are exactly 259 chars long" do
|
37
|
+
bisac = RBook::Bisac::Message.new("Rainbow","1234567","test","1")
|
38
|
+
bisac << @valid_item1
|
39
|
+
bisac << @valid_item2
|
40
|
+
|
41
|
+
bisac.to_s.split("\n").each do |line|
|
42
|
+
line.length.should eql(259)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
specify "Should load a valid BISAC file from disk correctly" do
|
47
|
+
msg = RBook::Bisac::Message.load(File.dirname(__FILE__) + "/data/valid_bisac.txt")
|
48
|
+
msg.company.should eql("SAND")
|
49
|
+
msg.san.should eql("9012982")
|
50
|
+
msg.batch.should eql("000001")
|
51
|
+
msg.code.should eql("0")
|
52
|
+
msg.products.size.should eql(212)
|
53
|
+
|
54
|
+
product = msg.products[0]
|
55
|
+
product.isbn.should eql("0715200615")
|
56
|
+
product.title.should eql("GODS YOUNG CHURCH PB")
|
57
|
+
product.author.should eql("Barclay, W")
|
58
|
+
product.price.should eql("2272")
|
59
|
+
product.publisher.should eql("SAND")
|
60
|
+
product.imprint.should eql("STANP")
|
61
|
+
product.volumes.should eql("")
|
62
|
+
product.volume.should eql("000")
|
63
|
+
product.edition.should eql("")
|
64
|
+
product.binding.should eql("")
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'rbook/bisac'
|
4
|
+
include RBook
|
5
|
+
|
6
|
+
context "A new bisac purchase order line item object" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@valid_row = "4000003 14976 Y000000000102978513220000100000000000000000000550000000"
|
10
|
+
@invalid_row_nil = nil
|
11
|
+
@invalid_row_num = 23
|
12
|
+
end
|
13
|
+
|
14
|
+
specify "Should load a line from a bisac po file correctly" do
|
15
|
+
item = RBook::Bisac::POLineItem.load_from_string(@valid_row)
|
16
|
+
item.should be_a_kind_of(RBook::Bisac::POLineItem)
|
17
|
+
|
18
|
+
item.sequence_number.should eql(3)
|
19
|
+
item.po_number.should eql("14976")
|
20
|
+
item.line_item_number.should eql("0000000001")
|
21
|
+
item.isbn.should eql("0297851322")
|
22
|
+
item.qty.should eql(1)
|
23
|
+
item.catalogue_code.should eql("0")
|
24
|
+
item.price.should eql(0)
|
25
|
+
end
|
26
|
+
|
27
|
+
specify "Should raise an appropriate exception when an invalid file is loaded" do
|
28
|
+
lambda { item = RBook::Bisac::POLineItem.load_from_string(@invalid_row_nil) }.should raise_error(RBook::InvalidArgumentError)
|
29
|
+
lambda { item = RBook::Bisac::POLineItem.load_from_string(@invalid_row_num) }.should raise_error(RBook::InvalidArgumentError)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'rbook/bisac'
|
4
|
+
include RBook
|
5
|
+
|
6
|
+
context "A new bisac purchase order object" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@valid_file = File.dirname(__FILE__) + "/data/bisac_po.txt"
|
10
|
+
@invalid_file_no_header = File.dirname(__FILE__) + "/data/bisac_po_no_header.txt"
|
11
|
+
@invalid_file_no_footer = File.dirname(__FILE__) + "/data/bisac_po_no_footer.txt"
|
12
|
+
@invalid_file_onix = File.dirname(__FILE__) + "/data/single_product.xml"
|
13
|
+
end
|
14
|
+
|
15
|
+
specify "Should load a valid BISAC PO file from disk correctly" do
|
16
|
+
msg = RBook::Bisac::PO.load_from_file(@valid_file)
|
17
|
+
msg.should be_a_kind_of(RBook::Bisac::PO)
|
18
|
+
msg.items.size.should eql(36)
|
19
|
+
|
20
|
+
msg.source_san.should eql("9013725")
|
21
|
+
msg.source_suffix.should eql("")
|
22
|
+
msg.source_name.should eql("Rainbow Book")
|
23
|
+
msg.date.should eql("061112")
|
24
|
+
msg.filename.should eql("INTERNET.BSC")
|
25
|
+
msg.format_version.should eql("F03")
|
26
|
+
msg.destination_san.should eql("9021000")
|
27
|
+
msg.destination_suffix.should eql("")
|
28
|
+
msg.po_number.should eql("14976")
|
29
|
+
msg.cancellation_date.should eql("000000")
|
30
|
+
msg.backorder.should be_true
|
31
|
+
msg.do_not_exceed_action.should eql("")
|
32
|
+
msg.do_not_exceed_amount.should eql("0000000")
|
33
|
+
msg.invoice_copies.should eql("01")
|
34
|
+
msg.special_instructions.should be_false
|
35
|
+
msg.do_not_ship_before.should eql("000000")
|
36
|
+
end
|
37
|
+
|
38
|
+
specify "Should load a valid BISAC PO file from a string correctly" do
|
39
|
+
msg = RBook::Bisac::PO.load_from_string(File.read(@valid_file))
|
40
|
+
msg.should be_a_kind_of(RBook::Bisac::PO)
|
41
|
+
msg.items.size.should eql(36)
|
42
|
+
|
43
|
+
msg.source_san.should eql("9013725")
|
44
|
+
msg.source_suffix.should eql("")
|
45
|
+
msg.source_name.should eql("Rainbow Book")
|
46
|
+
msg.date.should eql("061112")
|
47
|
+
msg.filename.should eql("INTERNET.BSC")
|
48
|
+
msg.format_version.should eql("F03")
|
49
|
+
msg.destination_san.should eql("9021000")
|
50
|
+
msg.destination_suffix.should eql("")
|
51
|
+
msg.po_number.should eql("14976")
|
52
|
+
msg.cancellation_date.should eql("000000")
|
53
|
+
msg.backorder.should be_true
|
54
|
+
msg.do_not_exceed_action.should eql("")
|
55
|
+
msg.do_not_exceed_amount.should eql("0000000")
|
56
|
+
msg.invoice_copies.should eql("01")
|
57
|
+
msg.special_instructions.should be_false
|
58
|
+
msg.do_not_ship_before.should eql("000000")
|
59
|
+
end
|
60
|
+
|
61
|
+
specify "Should raise an appropriate exception when an invalid file is loaded" do
|
62
|
+
lambda { msg = RBook::Bisac::PO.load_from_file(@invalid_file_no_header) }.should raise_error(RBook::InvalidFileError)
|
63
|
+
lambda { msg = RBook::Bisac::PO.load_from_file(@invalid_file_no_footer) }.should raise_error(RBook::InvalidFileError)
|
64
|
+
lambda { msg = RBook::Bisac::PO.load_from_file(@invalid_file_onix) }.should raise_error(RBook::InvalidFileError)
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: rbook-bisac
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "0.5"
|
7
|
+
date: 2007-07-03 00:00:00 +10:00
|
8
|
+
summary: A library for manipulating BISAC files
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: jimmy@deefa.com
|
12
|
+
homepage: http://rbook.rubyforge.org/
|
13
|
+
rubyforge_project: rbook
|
14
|
+
description: This library is designed to make working with various BISAC file formats easier.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- James Healy
|
31
|
+
files:
|
32
|
+
- lib/rbook
|
33
|
+
- lib/rbook/bisac
|
34
|
+
- lib/rbook/bisac/po.rb
|
35
|
+
- lib/rbook/bisac/product.rb
|
36
|
+
- lib/rbook/bisac/po_line_item.rb
|
37
|
+
- lib/rbook/bisac/message.rb
|
38
|
+
- lib/rbook/bisac.rb
|
39
|
+
- lib/rbook/errors.rb
|
40
|
+
- specs/data
|
41
|
+
- specs/data/bisac_po_no_header.txt
|
42
|
+
- specs/data/bisac_po_no_footer.txt
|
43
|
+
- specs/data/bisac_po.txt
|
44
|
+
- specs/data/valid_bisac.txt
|
45
|
+
- specs/data/bisac_po.bsc
|
46
|
+
- specs/new_po_spec.rb
|
47
|
+
- specs/new_bisac_spec.rb
|
48
|
+
- specs/new_po_line_item_spec.rb
|
49
|
+
- Rakefile
|
50
|
+
- README
|
51
|
+
- COPYING
|
52
|
+
- LICENSE
|
53
|
+
test_files:
|
54
|
+
- specs/new_po_spec.rb
|
55
|
+
- specs/new_bisac_spec.rb
|
56
|
+
- specs/new_po_line_item_spec.rb
|
57
|
+
rdoc_options:
|
58
|
+
- --title
|
59
|
+
- bisac Documentation
|
60
|
+
- --main
|
61
|
+
- README
|
62
|
+
- -q
|
63
|
+
extra_rdoc_files:
|
64
|
+
- README
|
65
|
+
- COPYING
|
66
|
+
- LICENSE
|
67
|
+
executables: []
|
68
|
+
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
dependencies:
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: rbook-isbn
|
76
|
+
version_requirement:
|
77
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "1.0"
|
82
|
+
version:
|