bisac 0.8.1 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -20,5 +20,6 @@ claiming otherwise.
20
20
 
21
21
  = Links
22
22
 
23
- - http://www.bisg.org/bisac/
24
- - http://www.anchordistributors.com/EDIInfo.aspx
23
+ - Project source: http://github.com/yob/bisac/tree/master
24
+ - Standards body: http://www.bisg.org/bisac/
25
+ - Partial specs: http://www.anchordistributors.com/EDIInfo.aspx
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/testtask'
6
6
  require "rake/gempackagetask"
7
7
  require 'spec/rake/spectask'
8
8
 
9
- PKG_VERSION = "0.8.1"
9
+ PKG_VERSION = "0.9"
10
10
  PKG_NAME = "bisac"
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
  RUBYFORGE_PROJECT = 'rbook'
data/lib/bisac.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
 
3
3
  # load other files from within this lib
4
+ require 'bisac/utils'
4
5
  require 'bisac/message'
5
6
  require 'bisac/product'
6
7
  require 'bisac/po'
data/lib/bisac/po.rb CHANGED
@@ -26,6 +26,7 @@ module Bisac
26
26
  # ...
27
27
  # end
28
28
  class PO
29
+ include Bisac::Utils
29
30
 
30
31
  attr_accessor :source_san, :source_suffix, :source_name
31
32
  attr_accessor :date, :filename, :format_version
@@ -176,7 +177,7 @@ module Bisac
176
177
  line[40,5] = "00001" # number of '10'-'19' records
177
178
  line[55,5] = (@items.size * 3).to_s.rjust(5,"0") # number of '40'-'49' records
178
179
  line[60,5] = "00000" # number of '50'-'59' records
179
- line[45,5] = "00000" # number of '60'-'69' records
180
+ line[65,5] = "00000" # number of '60'-'69' records
180
181
  lines << line
181
182
 
182
183
  lines.join("\n")
@@ -184,19 +185,6 @@ module Bisac
184
185
 
185
186
  private
186
187
 
187
- def yes_no(bool)
188
- bool ? "Y" : "N"
189
- end
190
-
191
- def pad_trunc(str, len, pad = " ")
192
- str = str.to_s
193
- if str.size > len
194
- str[0,len]
195
- else
196
- str.ljust(len, pad)
197
- end
198
- end
199
-
200
188
  def self.build_message(data)
201
189
  raise Bisac::InvalidFileError, 'File appears to be too short' unless data.size >= 3
202
190
  raise Bisac::InvalidFileError, 'Missing header information' unless data[0][0,2].eql?("00")
@@ -5,6 +5,7 @@ module Bisac
5
5
  # represents a single line on the purchase order. Has attributes like
6
6
  # price, qty and description
7
7
  class POLineItem
8
+ include Bisac::Utils
8
9
 
9
10
  attr_accessor :sequence_number, :po_number, :line_item_number
10
11
  attr_accessor :qty, :catalogue_code, :price
@@ -97,19 +98,5 @@ module Bisac
97
98
  lines.join("\n")
98
99
  end
99
100
 
100
- private
101
-
102
- def yes_no(bool)
103
- bool ? "Y" : "N"
104
- end
105
-
106
- def pad_trunc(str, len, pad = " ")
107
- str = str.to_s
108
- if str.size > len
109
- str[0,len]
110
- else
111
- str.ljust(len, pad)
112
- end
113
- end
114
101
  end
115
102
  end
data/lib/bisac/poa.rb CHANGED
@@ -19,6 +19,7 @@ module Bisac
19
19
  # ...
20
20
  # end
21
21
  class POA
22
+ include Bisac::Utils
22
23
 
23
24
  # file header attributes
24
25
  attr_accessor :source_san, :source_suffix, :source_name
@@ -37,14 +38,9 @@ module Bisac
37
38
  # creates a new Bisac::POA object
38
39
  def initialize
39
40
  @items = []
40
-
41
- # default values
42
- @cancellation_date = "000000"
43
- @do_not_ship_before = "000000"
44
- @backorder = true
45
41
  end
46
42
 
47
- # return all POs from a BISAC file
43
+ # return all POAs from a BISAC file
48
44
  def self.parse_file(input, &block)
49
45
  raise ArgumentError, 'no file provided' if input.nil?
50
46
  raise ArgumentError, 'Invalid file' unless File.file?(input)
@@ -53,7 +49,7 @@ module Bisac
53
49
  end
54
50
  end
55
51
 
56
- # return all POs from a BISAC string
52
+ # return all POAs from a BISAC string
57
53
  def self.parse_string(input, &block)
58
54
  raise ArgumentError, 'no data provided' if input.nil?
59
55
  data = []
@@ -61,8 +57,8 @@ module Bisac
61
57
  data << l
62
58
 
63
59
  # yield each message found in the string. A line starting with
64
- # 90 is the footer to a PO
65
- if data.last[0,2] == "90"
60
+ # 91 is the footer to a POA
61
+ if data.last[0,2] == "91"
66
62
  msg = Bisac::POA.new
67
63
  msg.build_message(data)
68
64
  yield msg
@@ -79,16 +75,27 @@ module Bisac
79
75
  end
80
76
  end
81
77
 
82
- def total_qty
83
- @items.collect { |i| i.qty }.inject { |sum, x| sum ? sum+x : x}
78
+ # total number of units ordered by the customer
79
+ #
80
+ def total_order_qty
81
+ @items.collect { |i| i.order_qty }.inject { |sum, x| sum ? sum+x : x}
82
+ end
83
+
84
+ # total number of units to ship
85
+ #
86
+ def total_shippable_qty
87
+ @items.collect { |i| i.shippable_qty }.inject { |sum, x| sum ? sum+x : x}
84
88
  end
85
89
 
90
+ # convert this POA into a standards compliant string, ready for sending
91
+ # to customers.
92
+ #
86
93
  def to_s
87
94
  lines = []
88
95
 
89
96
  # file header
90
97
  line = " " * 80
91
- line[0,2] = "00" # line type
98
+ line[0,2] = "02" # line type
92
99
  line[2,5] = "00001" # line counter
93
100
  line[7,7] = pad_trunc(@source_san, 7)
94
101
  line[14,5] = pad_trunc(@source_suffix, 5)
@@ -98,59 +105,56 @@ module Bisac
98
105
  line[60,3] = pad_trunc(@format_version, 3)
99
106
  line[63,7] = pad_trunc(@destination_san, 7)
100
107
  line[70,5] = pad_trunc(@destination_suffix, 5)
108
+ line[75,1] = pad_trunc(@ack_type, 1)
101
109
  lines << line
102
110
 
103
111
  # po header
104
- lines << ""
105
- lines.last << "10"
106
- lines.last << "00002" # line counter
107
- lines.last << " "
108
- lines.last << @po_number.to_s.ljust(11, " ")
109
- lines.last << " " # TODO
110
- lines.last << pad_trunc(@source_san, 7)
111
- lines.last << pad_trunc("",5) # TODO
112
- lines.last << pad_trunc(@destination_san, 7)
113
- lines.last << pad_trunc("",5) # TODO
114
- lines.last << pad_trunc(@date, 6)
115
- lines.last << pad_trunc(@cancellation_date,6)
116
- lines.last << yes_no(@backorder)
117
- lines.last << pad_trunc(@do_not_exceed_action,1)
118
- lines.last << pad_trunc(@do_not_exceed_amount,7)
119
- lines.last << pad_trunc(@invoice_copies,2)
120
- lines.last << yes_no(@special_instructions)
121
- lines.last << pad_trunc("",5) # TODO
122
- lines.last << pad_trunc(@do_not_ship_before,6)
123
-
124
- sequence = 3
112
+ line = " " * 80
113
+ line[0,2] = "11" # line type
114
+ line[2,5] = "00002" # line counter
115
+ line[7,13] = pad_trunc(@supplier_poa_number, 13)
116
+ line[20,13] = pad_trunc(@po_number, 13)
117
+ line[33,7] = pad_trunc(@customer_san, 7)
118
+ line[40,5] = pad_trunc(@customer_suffice, 5)
119
+ line[45,7] = pad_trunc(@supplier_san, 7)
120
+ line[52,5] = pad_trunc(@supplier_suffice, 5)
121
+ line[57,6] = pad_trunc(@poa_date, 6)
122
+ line[63,3] = pad_trunc(@currency, 3)
123
+ line[66,6] = pad_trunc(@po_date, 6)
124
+ line[72,6] = pad_trunc(@po_cancel_date, 6)
125
+ line[78,2] = pad_trunc(@po_type, 2)
126
+ lines << line
127
+
125
128
  @items.each_with_index do |item, idx|
126
129
  item.line_item_number = idx + 1
127
- item.sequence_number = sequence
128
- lines += item.to_s.split("\n")
129
- sequence += 3
130
+ item.sequence_number = lines.size + 1
131
+ lines << item.to_s
130
132
  end
131
133
 
132
- # PO control
134
+ # POA control
133
135
  line = " " * 80
134
- line[0,2] = "50"
136
+ line[0,2] = "59"
135
137
  line[2,5] = (lines.size + 1).to_s.rjust(5,"0") # line counter
136
- line[8,12] = @po_number.to_s.ljust(13, " ")
137
- line[20,5] = "00001" # number of POs in file
138
- line[25,10] = @items.size.to_s.rjust(10,"0")
139
- line[35,10] = total_qty.to_s.rjust(10,"0")
138
+ line[7,13] = pad_trunc(@supplier_poa_number, 13)
139
+ line[20,5] = (lines.size).to_s.rjust(5,"0") # number of lines to this point
140
+ line[25,10] = (lines.size - 2).to_s.rjust(10,"0") # number of line items in file
141
+ line[35,10] = total_shippable_qty.to_s.rjust(10,"0")
140
142
  lines << line
141
143
 
142
144
  # file trailer
143
145
  line = " " * 80
144
- line[0,2] = "90"
146
+ line[0,2] = "91"
145
147
  line[2,5] = (lines.size+1).to_s.rjust(5,"0") # line counter
146
148
  line[7,20] = @items.size.to_s.rjust(13,"0")
147
- line[20,5] = "00001" # total '10' (PO) records
148
- line[25,10] = total_qty.to_s.rjust(10,"0")
149
+ line[20,5] = "00001" # total '11' (POA) records
150
+ line[25,10] = total_shippable_qty.to_s.rjust(10,"0")
149
151
  line[35,5] = "00001" # number of '00'-'09' records
150
152
  line[40,5] = "00001" # number of '10'-'19' records
151
- line[55,5] = (@items.size * 3).to_s.rjust(5,"0") # number of '40'-'49' records
152
- line[60,5] = "00000" # number of '50'-'59' records
153
- line[45,5] = "00000" # number of '60'-'69' records
153
+ line[45,5] = "00000" # number of '20'-'29' records
154
+ line[50,5] = "00000" # number of '30'-'39' records
155
+ line[55,5] = (@items.size).to_s.rjust(5,"0") # number of '40'-'49' records
156
+ line[60,5] = "00001" # number of '50'-'59' records
157
+ line[65,5] = "00001" # number of '60'-'99' records
154
158
  lines << line
155
159
 
156
160
  lines.join("\n")
@@ -3,7 +3,9 @@ require 'bigdecimal'
3
3
  module Bisac
4
4
 
5
5
  # represents a single line on the purchase order ack
6
+ #
6
7
  class POALineItem
8
+ include Bisac::Utils
7
9
 
8
10
  attr_accessor :sequence_number, :supplier_poa_number
9
11
  attr_accessor :line_item_number, :order_qty, :unit_price, :nett_price
@@ -63,6 +65,25 @@ module Bisac
63
65
  end
64
66
  end
65
67
 
68
+ def to_s
69
+ line = " " * 93
70
+ line[0,2] = "40" # line type
71
+ line[2,5] = @sequence_number.to_s.rjust(5,"0") # line counter
72
+ line[7,13] = pad_trunc(@supplier_poa_number, 13)
73
+ line[20,10] = rpad_trunc(@line_item_number, 10, "0")
74
+ line[30,10] = pad_trunc(isbn10, 10)
75
+ line[40,5] = rpad_trunc(@order_qty, 5, "0")
76
+ line[45,8] = rpad_trunc(@unit_price.to_i, 8, "0")
77
+ line[53,9] = rpad_trunc(@nett_price.to_i, 9, "0")
78
+ line[62,1] = pad_trunc(@list_nett_indicator, 1)
79
+ line[63,1] = rpad_trunc(@special_price, 1, "0")
80
+ line[64,5] = rpad_trunc(@discount.to_i, 5, "0")
81
+ line[69,5] = rpad_trunc(@shippable_qty, 5, "0")
82
+ line[74,2] = rpad_trunc(@status, 2, "0")
83
+ line[80,13] = pad_trunc(isbn, 13)
84
+ line
85
+ end
86
+
66
87
  def status_text
67
88
  case self.status
68
89
  when 1 then "Accepted: Title Shipped As Ordered"
@@ -0,0 +1,28 @@
1
+ module Bisac
2
+ module Utils
3
+
4
+ private
5
+
6
+ def yes_no(bool)
7
+ bool ? "Y" : "N"
8
+ end
9
+
10
+ def pad_trunc(str, len, pad = " ")
11
+ str = str.to_s
12
+ if str.size > len
13
+ str[0,len]
14
+ else
15
+ str.ljust(len, pad)
16
+ end
17
+ end
18
+
19
+ def rpad_trunc(str, len, pad = " ")
20
+ str = str.to_s
21
+ if str.size > len
22
+ str[0,len]
23
+ else
24
+ str.rjust(len, pad)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -4,80 +4,54 @@
4
4
  40000040000000019629000000000207148483010000400000000000000000 000000000401 9780714848303
5
5
  40000050000000019629000000000307459426440000100000000000000000 000000000101 9780745942643
6
6
  40000060000000019629000000000407459466310000600000000000000000 000000000007 9780745946634
7
- 4100007000000001962900000 000000
8
- 40000080000000019629000000000507459493040000200000000000000000 000000000201 9780745949307
9
- 40000090000000019629000000000607459493550000200000000000000000 000000000007 9780745949352
10
- 4100010000000001962900000 000000
11
- 40000110000000019629000000000707459493630000100000000000000000 000000000007 9780745949369
12
- 4100012000000001962900000 000000
13
- 40000130000000019629000000000807459496650000100000000000000000 000000000101 9780745949666
14
- 40000140000000019629000000000907459496810000100000000000000000 000000000007 9780745949680
15
- 4100015000000001962900000 000000
16
- 40000160000000019629000000001007459497970000300000000000000000 000000000301 9780745949796
17
- 40000170000000019629000000001107459499670000300000000000000000 000000000301 9780745949963
18
- 40000180000000019629000000001207459522240000100000000000000000 000000000101 9780745952222
19
- 40000190000000019629000000001307459523480000200000000000000000 000000000007 9780745952345
20
- 4100020000000001962900000 000000
21
- 400002100000000196290000000014074595278X0000100000000000000000 000000000101 9780745952789
22
- 40000220000000019629000000001507459531900000100000000000000000 000000000105 9780745953199
23
- 4100023000000001962900001 000000
24
- 40000240000000019629000000001607459600490000200000000000000000 000000000201 9780745960043
25
- 400002500000000196290000000017074596012X0000200000000000000000 000000000007 9780745960128
26
- 4100026000000001962900000 000000
27
- 40000270000000019629000000001807459601620000700000000000000000 000000000701 9780745960166
28
- 40000280000000019629000000001907459607070000100000000000000000 000000000101 9780745960708
29
- 40000290000000019629000000002007459608470000200000000000000000 000000000201 9780745960845
30
- 40000300000000019629000000002107459608630000500000000000000000 000000000110 9780745960869
31
- 4100031000000001962900001 000000
32
- 40000320000000019629000000002207459609520000100000000000000000 000000000007 9780745960951
33
- 4100033000000001962900000 000000
34
- 40000340000000019629000000002307459610450000600000000000000000 000000000605 9780745961040
35
- 4100035000000001962900006 000000
36
- 40000360000000019629000000002407459610530000200000000000000000 000000000201 9780745961057
37
- 40000370000000019629000000002507459610880000500000000000000000 000000000501 9780745961088
38
- 40000380000000019629000000002607459612230000700000000000000000 000000001409 9780745961224
39
- 40000390000000019629000000002707459690460000400000000000000000 000000000007 9780745969046
40
- 4100040000000001962900000 000000
41
- 40000410000000019629000000002807624166960000200000000000000000 000000000201 9780762416691
42
- 40000420000000019629000000002908979349380000200000000000000000 000000000201 9780897934930
43
- 40000430000000019629000000003015925825400000700000000000000000 000000000701 9781592582549
44
- 40000440000000019629000000003118453930070000400000000000000000 000000000401 9781845393007
45
- 400004500000000196290000000032184666411X0000100000000000000000 000000000101 9781846664113
46
- 40000460000000019629000000003318516848240000600000000000000000 000000000007 9781851684823
47
- 4100047000000001962900000 000000
48
- 40000480000000019629000000003418542483400000100000000000000000 000000000007 9781854248343
49
- 4100049000000001962900000 000000
50
- 400005000000000196290000000035185424874X0000100000000000000000 000000000116 9781854248749
51
- 40000510000000019629000000003618589426160000200000000000000000 000000000007 9781858942612
52
- 4100052000000001962900000 000000
53
- 40000530000000019629000000003718589426240000200000000000000000 000000000007 9781858942629
54
- 4100054000000001962900000 000000
55
- 400005500000000196290000000038185985334X0000600000000000000000 000000000007 9781859853344
56
- 4100056000000001962900000 000000
57
- 40000570000000019629000000003918598549310000200000000000000000 000000000201 9781859854938
58
- 40000580000000019629000000004018598552450000100000000000000000 000000000007 9781859855249
59
- 4100059000000001962900000 000000
60
- 40000600000000019629000000004118598562760000500000000000000000 000000000007 9781859856277
61
- 4100061000000001962900000 000000
62
- 40000620000000019629000000004218598562840000500000000000000000 000000000007 9781859856284
63
- 4100063000000001962900000 000000
64
- 40000640000000019629000000004318598563060000100000000000000000 000000000101 9781859856307
65
- 40000650000000019629000000004418598563220000300000000000000000 000000000301 9781859856321
66
- 40000660000000019629000000004518598566320000200000000000000000 000000000007 9781859856635
67
- 4100067000000001962900000 000000
68
- 40000680000000019629000000004618598566400000200000000000000000 000000000007 9781859856642
69
- 4100069000000001962900000 000000
70
- 400007000000000196290000000047185985673X0000300000000000000000 000000000301 9781859856734
71
- 40000710000000019629000000004818598569690000100000000000000000 000000000007 9781859856963
72
- 4100072000000001962900000 000000
73
- 40000730000000019629000000004918598576120000100000000000000000 000000000007 9781859857618
74
- 4100074000000001962900000 000000
75
- 40000750000000019629000000005018598576710000900000000000000000 000000000905 9781859857670
76
- 4100076000000001962900009 000000
77
- 400007700000000196290000000051185985768X0001100000000000000000 000000001105 9781859857687
78
- 4100078000000001962900011 000000
79
- 40000790000000019629000000005218942229620000400000000000000000 000000000008 9781894222969
80
- 40000800000000019629000000005319052793450000100000000000000000 000000000007 9781905279340
81
- 4100081000000001962900000 000000
82
- 590008200000000196290008100000000530000000104
83
- 9100083000000000005300001000000010400000000000000000000000000000000000
7
+ 40000070000000019629000000000507459493040000200000000000000000 000000000201 9780745949307
8
+ 40000080000000019629000000000607459493550000200000000000000000 000000000007 9780745949352
9
+ 40000090000000019629000000000707459493630000100000000000000000 000000000007 9780745949369
10
+ 40000100000000019629000000000807459496650000100000000000000000 000000000101 9780745949666
11
+ 40000110000000019629000000000907459496810000100000000000000000 000000000007 9780745949680
12
+ 40000120000000019629000000001007459497970000300000000000000000 000000000301 9780745949796
13
+ 40000130000000019629000000001107459499670000300000000000000000 000000000301 9780745949963
14
+ 40000140000000019629000000001207459522240000100000000000000000 000000000101 9780745952222
15
+ 40000150000000019629000000001307459523480000200000000000000000 000000000007 9780745952345
16
+ 400001600000000196290000000014074595278X0000100000000000000000 000000000101 9780745952789
17
+ 40000170000000019629000000001507459531900000100000000000000000 000000000105 9780745953199
18
+ 40000180000000019629000000001607459600490000200000000000000000 000000000201 9780745960043
19
+ 400001900000000196290000000017074596012X0000200000000000000000 000000000007 9780745960128
20
+ 40000200000000019629000000001807459601620000700000000000000000 000000000701 9780745960166
21
+ 40000210000000019629000000001907459607070000100000000000000000 000000000101 9780745960708
22
+ 40000220000000019629000000002007459608470000200000000000000000 000000000201 9780745960845
23
+ 40000230000000019629000000002107459608630000500000000000000000 000000000110 9780745960869
24
+ 40000240000000019629000000002207459609520000100000000000000000 000000000007 9780745960951
25
+ 40000250000000019629000000002307459610450000600000000000000000 000000000605 9780745961040
26
+ 40000260000000019629000000002407459610530000200000000000000000 000000000201 9780745961057
27
+ 40000270000000019629000000002507459610880000500000000000000000 000000000501 9780745961088
28
+ 40000280000000019629000000002607459612230000700000000000000000 000000001409 9780745961224
29
+ 40000290000000019629000000002707459690460000400000000000000000 000000000007 9780745969046
30
+ 40000300000000019629000000002807624166960000200000000000000000 000000000201 9780762416691
31
+ 40000310000000019629000000002908979349380000200000000000000000 000000000201 9780897934930
32
+ 40000320000000019629000000003015925825400000700000000000000000 000000000701 9781592582549
33
+ 40000330000000019629000000003118453930070000400000000000000000 000000000401 9781845393007
34
+ 400003400000000196290000000032184666411X0000100000000000000000 000000000101 9781846664113
35
+ 40000350000000019629000000003318516848240000600000000000000000 000000000007 9781851684823
36
+ 40000360000000019629000000003418542483400000100000000000000000 000000000007 9781854248343
37
+ 400003700000000196290000000035185424874X0000100000000000000000 000000000116 9781854248749
38
+ 40000380000000019629000000003618589426160000200000000000000000 000000000007 9781858942612
39
+ 40000390000000019629000000003718589426240000200000000000000000 000000000007 9781858942629
40
+ 400004000000000196290000000038185985334X0000600000000000000000 000000000007 9781859853344
41
+ 40000410000000019629000000003918598549310000200000000000000000 000000000201 9781859854938
42
+ 40000420000000019629000000004018598552450000100000000000000000 000000000007 9781859855249
43
+ 40000430000000019629000000004118598562760000500000000000000000 000000000007 9781859856277
44
+ 40000440000000019629000000004218598562840000500000000000000000 000000000007 9781859856284
45
+ 40000450000000019629000000004318598563060000100000000000000000 000000000101 9781859856307
46
+ 40000460000000019629000000004418598563220000300000000000000000 000000000301 9781859856321
47
+ 40000470000000019629000000004518598566320000200000000000000000 000000000007 9781859856635
48
+ 40000480000000019629000000004618598566400000200000000000000000 000000000007 9781859856642
49
+ 400004900000000196290000000047185985673X0000300000000000000000 000000000301 9781859856734
50
+ 40000500000000019629000000004818598569690000100000000000000000 000000000007 9781859856963
51
+ 40000510000000019629000000004918598576120000100000000000000000 000000000007 9781859857618
52
+ 40000520000000019629000000005018598576710000900000000000000000 000000000905 9781859857670
53
+ 400005300000000196290000000051185985768X0001100000000000000000 000000001105 9781859857687
54
+ 40000540000000019629000000005218942229620000400000000000000000 000000000008 9781894222969
55
+ 40000550000000019629000000005319052793450000100000000000000000 000000000007 9781905279340
56
+ 590005600000000196290005500000000530000000104
57
+ 9100057000000000005300001000000010400001000010000000000000530000100001
@@ -27,10 +27,15 @@ context "A new bisac purchase order line item object" do
27
27
  end
28
28
 
29
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)
30
+ item = Bisac::POALineItem.load_from_string(@valid_isbn13_row)
31
+ item.should be_a_kind_of(Bisac::POALineItem)
32
32
 
33
33
  item.isbn.should eql("9780711226067")
34
34
  end
35
35
 
36
+ specify "Should correctly convert into a string" do
37
+ item = Bisac::POALineItem.load_from_string(@valid_isbn13_row)
38
+ item.to_s.should eql(@valid_isbn13_row)
39
+ end
40
+
36
41
  end
data/specs/poa_spec.rb CHANGED
@@ -67,4 +67,14 @@ context "A BISAC POA object" do
67
67
  specify "Should raise an appropriate exception when an invalid file is loaded" do
68
68
  lambda { msg = Bisac::POA.parse_file(@invalid_file_onix) }.should raise_error(Bisac::InvalidFileError)
69
69
  end
70
+
71
+ specify "Should correctly convert into a string" do
72
+ original = File.read(@valid_file).split("\n")
73
+ Bisac::POA.parse_file(@valid_file) do |msg|
74
+ msg.to_s.split("\n").size.should eql(57)
75
+ msg.to_s.split("\n").each_with_index do |line, idx|
76
+ line.strip.should eql(original[idx].strip)
77
+ end
78
+ end
79
+ end
70
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bisac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: "0.9"
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-08 00:00:00 +10:00
12
+ date: 2008-11-24 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -41,6 +41,7 @@ files:
41
41
  - lib/bisac/product.rb
42
42
  - lib/bisac/poa.rb
43
43
  - lib/bisac/poa_line_item.rb
44
+ - lib/bisac/utils.rb
44
45
  - specs/data
45
46
  - specs/data/bisac_multi_po.txt
46
47
  - specs/data/bisac_po.txt
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  requirements: []
85
86
 
86
87
  rubyforge_project: rbook
87
- rubygems_version: 1.2.0
88
+ rubygems_version: 1.3.1
88
89
  signing_key:
89
90
  specification_version: 2
90
91
  summary: A library for manipulating BISAC files