bisac 0.8
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 +12 -0
- data/README +24 -0
- data/Rakefile +90 -0
- data/lib/bisac.rb +17 -0
- data/lib/bisac/message.rb +110 -0
- data/lib/bisac/po.rb +252 -0
- data/lib/bisac/po_line_item.rb +115 -0
- data/lib/bisac/poa.rb +212 -0
- data/lib/bisac/poa_line_item.rb +81 -0
- data/lib/bisac/product.rb +174 -0
- data/specs/data/bisac_multi_po.txt +41 -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/single_product.xml +74 -0
- data/specs/data/valid_bisac.txt +213 -0
- data/specs/data/valid_poa.txt +83 -0
- data/specs/new_bisac_spec.rb +67 -0
- data/specs/new_po_line_item_spec.rb +52 -0
- data/specs/new_po_spec.rb +85 -0
- data/specs/poa_line_item_spec.rb +36 -0
- data/specs/poa_spec.rb +70 -0
- metadata +96 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'bisac'
|
4
|
+
|
5
|
+
context "A new bisac purchase order line item object" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@valid_row = "40000030000000019629000000000107112260670000100000000000000000 000000000101 "
|
9
|
+
@valid_isbn13_row = "40000030000000019629000000000107112260670000100000000000000000 000000000101 9780711226067"
|
10
|
+
end
|
11
|
+
|
12
|
+
specify "Should load a line from a bisac po file correctly" do
|
13
|
+
item = Bisac::POALineItem.load_from_string(@valid_row)
|
14
|
+
item.should be_a_kind_of(Bisac::POALineItem)
|
15
|
+
|
16
|
+
item.sequence_number.should eql(3)
|
17
|
+
item.line_item_number.should eql("0000000001")
|
18
|
+
item.isbn.should eql("9780711226067")
|
19
|
+
item.order_qty.should eql(1)
|
20
|
+
item.unit_price.should eql(0)
|
21
|
+
item.nett_price.should eql(0)
|
22
|
+
item.special_price.should eql(" ")
|
23
|
+
item.discount.should eql(0)
|
24
|
+
item.shippable_qty.should eql(1)
|
25
|
+
item.status.should eql(1)
|
26
|
+
item.warehouse_status.should eql(0)
|
27
|
+
end
|
28
|
+
|
29
|
+
specify "Should prefer the ISBN13 over ISBN10 when available" do
|
30
|
+
item = Bisac::POLineItem.load_from_string(@valid_isbn13_row)
|
31
|
+
item.should be_a_kind_of(Bisac::POLineItem)
|
32
|
+
|
33
|
+
item.isbn.should eql("9780711226067")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/specs/poa_spec.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'bisac'
|
4
|
+
|
5
|
+
context "The BISAC POA Class" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@valid_file = File.dirname(__FILE__) + "/data/valid_poa.txt"
|
9
|
+
@invalid_file_onix = File.dirname(__FILE__) + "/data/single_product.xml"
|
10
|
+
end
|
11
|
+
|
12
|
+
specify "Should load a valid BISAC PO file from disk correctly" do
|
13
|
+
results = []
|
14
|
+
Bisac::POA.parse_file(@valid_file) do |msg|
|
15
|
+
results << msg
|
16
|
+
end
|
17
|
+
|
18
|
+
results.size.should eql(1)
|
19
|
+
results[0].should be_a_kind_of(Bisac::POA)
|
20
|
+
end
|
21
|
+
|
22
|
+
specify "Should raise an appropriate exception when an invalid file is loaded" do
|
23
|
+
lambda { msg = Bisac::POA.parse_file(@invalid_file_onix) }.should raise_error(Bisac::InvalidFileError)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "A BISAC POA object" do
|
28
|
+
|
29
|
+
setup do
|
30
|
+
@valid_file = File.dirname(__FILE__) + "/data/valid_poa.txt"
|
31
|
+
@invalid_file_onix = File.dirname(__FILE__) + "/data/single_product.xml"
|
32
|
+
end
|
33
|
+
|
34
|
+
specify "should correctly load a POA message into the object using build_message()" do
|
35
|
+
|
36
|
+
data = File.read(@valid_file).split("\n")
|
37
|
+
msg = Bisac::POA.new
|
38
|
+
msg.build_message(data)
|
39
|
+
|
40
|
+
# check file header values
|
41
|
+
msg.source_san.should eql("1111111")
|
42
|
+
msg.source_suffix.should eql("")
|
43
|
+
msg.source_name.should eql("PACSTREAM")
|
44
|
+
msg.date.should eql("080904")
|
45
|
+
msg.filename.should eql("BISACPOA19629")
|
46
|
+
msg.format_version.should eql("001")
|
47
|
+
msg.destination_san.should eql("2222222")
|
48
|
+
msg.destination_suffix.should eql("")
|
49
|
+
msg.ack_type.should eql("")
|
50
|
+
|
51
|
+
# check poa header values
|
52
|
+
msg.supplier_poa_number.should eql("0000000019629")
|
53
|
+
msg.po_number.should eql("19629")
|
54
|
+
msg.customer_san.should eql("2222222")
|
55
|
+
msg.customer_suffix.should eql("")
|
56
|
+
msg.supplier_san.should eql("1111111")
|
57
|
+
msg.supplier_suffix.should eql("")
|
58
|
+
msg.poa_date.should eql("080904")
|
59
|
+
msg.currency.should eql("")
|
60
|
+
msg.po_date.should eql("")
|
61
|
+
msg.po_cancel_date.should eql("")
|
62
|
+
msg.po_type.should eql("")
|
63
|
+
|
64
|
+
msg.items.size.should eql(53)
|
65
|
+
end
|
66
|
+
|
67
|
+
specify "Should raise an appropriate exception when an invalid file is loaded" do
|
68
|
+
lambda { msg = Bisac::POA.parse_file(@invalid_file_onix) }.should raise_error(Bisac::InvalidFileError)
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bisac
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.8"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Healy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-09-06 00:00:00 +10:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rbook-isbn
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.0"
|
24
|
+
version:
|
25
|
+
description: This library is designed to make working with various BISAC file formats easier.
|
26
|
+
email: jimmy@deefa.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README
|
33
|
+
- COPYING
|
34
|
+
- LICENSE
|
35
|
+
files:
|
36
|
+
- lib/bisac.rb
|
37
|
+
- lib/bisac
|
38
|
+
- lib/bisac/message.rb
|
39
|
+
- lib/bisac/po.rb
|
40
|
+
- lib/bisac/po_line_item.rb
|
41
|
+
- lib/bisac/product.rb
|
42
|
+
- lib/bisac/poa.rb
|
43
|
+
- lib/bisac/poa_line_item.rb
|
44
|
+
- specs/data
|
45
|
+
- specs/data/bisac_multi_po.txt
|
46
|
+
- specs/data/bisac_po.txt
|
47
|
+
- specs/data/bisac_po_no_footer.txt
|
48
|
+
- specs/data/bisac_po_no_header.txt
|
49
|
+
- specs/data/valid_bisac.txt
|
50
|
+
- specs/data/single_product.xml
|
51
|
+
- specs/data/valid_poa.txt
|
52
|
+
- specs/new_bisac_spec.rb
|
53
|
+
- specs/new_po_line_item_spec.rb
|
54
|
+
- specs/new_po_spec.rb
|
55
|
+
- specs/poa_spec.rb
|
56
|
+
- specs/poa_line_item_spec.rb
|
57
|
+
- Rakefile
|
58
|
+
- README
|
59
|
+
- COPYING
|
60
|
+
- LICENSE
|
61
|
+
has_rdoc: true
|
62
|
+
homepage: http://rbook.rubyforge.org/
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --title
|
66
|
+
- bisac Documentation
|
67
|
+
- --main
|
68
|
+
- README
|
69
|
+
- -q
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
version:
|
84
|
+
requirements: []
|
85
|
+
|
86
|
+
rubyforge_project: rbook
|
87
|
+
rubygems_version: 1.2.0
|
88
|
+
signing_key:
|
89
|
+
specification_version: 2
|
90
|
+
summary: A library for manipulating BISAC files
|
91
|
+
test_files:
|
92
|
+
- specs/new_bisac_spec.rb
|
93
|
+
- specs/new_po_line_item_spec.rb
|
94
|
+
- specs/new_po_spec.rb
|
95
|
+
- specs/poa_spec.rb
|
96
|
+
- specs/poa_line_item_spec.rb
|