rbook 0.3 → 0.4.1
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 +2 -2
 - data/examples/43.ord +18 -0
 - data/examples/pacstream.rb +3 -2
 - data/examples/titlepage_with_proxy.rb +14 -0
 - data/lib/rbook/bisac.rb +2 -0
 - data/lib/rbook/bisac/po.rb +87 -0
 - data/lib/rbook/bisac/po_line_item.rb +32 -0
 - data/lib/rbook/errors.rb +1 -0
 - data/lib/rbook/pacstream.rb +8 -5
 - data/lib/rbook/titlepage/client.rb +38 -5
 - data/test/data/bisac_po.txt +112 -0
 - data/test/unit/{bisac_test.rb → bisac/bisac_test.rb} +2 -2
 - data/test/unit/bisac/po_line_item_test.rb +38 -0
 - data/test/unit/bisac/po_test.rb +79 -0
 - metadata +25 -17
 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ require 'rake/testtask' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            require "rake/gempackagetask"
         
     | 
| 
       6 
6 
     | 
    
         
             
            require "rubygems"
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            PKG_VERSION = "0. 
     | 
| 
      
 8 
     | 
    
         
            +
            PKG_VERSION = "0.4.1"
         
     | 
| 
       9 
9 
     | 
    
         
             
            PKG_NAME = "rbook"
         
     | 
| 
       10 
10 
     | 
    
         
             
            PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
         
     | 
| 
       11 
11 
     | 
    
         
             
            RUBYFORGE_PROJECT = 'rbook'
         
     | 
| 
         @@ -49,7 +49,7 @@ spec = Gem::Specification.new do |spec| 
     | 
|
| 
       49 
49 
     | 
    
         
             
                                  ["Rakefile"]
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
51 
     | 
    
         
             
              spec.require_path = "lib"
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
              spec.bindir = "bin"
         
     | 
| 
       53 
53 
     | 
    
         
             
              spec.test_files = Dir[ "test/test_*.rb" ]
         
     | 
| 
       54 
54 
     | 
    
         
             
            	spec.has_rdoc = true
         
     | 
| 
       55 
55 
     | 
    
         
             
            	spec.extra_rdoc_files = %w{README COPYING LICENSE}
         
     | 
    
        data/examples/43.ord
    ADDED
    
    | 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 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,,
         
     | 
    
        data/examples/pacstream.rb
    CHANGED
    
    | 
         @@ -7,7 +7,8 @@ require File.dirname(__FILE__) + '/../lib/rbook/pacstream' 
     | 
|
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            counter = 0
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
            RBook::Pacstream.get(:orders, :username => " 
     | 
| 
       11 
     | 
    
         
            -
              File.open("#{counter.to_s}.ord", "w") { |f| f.puts order }
         
     | 
| 
      
 10 
     | 
    
         
            +
            RBook::Pacstream.get(:orders, :username => "9021000", :password => "test", :servername => "127.0.0.1") do |order|
         
     | 
| 
      
 11 
     | 
    
         
            +
              #File.open("#{counter.to_s}.ord", "w") { |f| f.puts order }
         
     | 
| 
      
 12 
     | 
    
         
            +
              puts order
         
     | 
| 
       12 
13 
     | 
    
         
             
              counter += 1
         
     | 
| 
       13 
14 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            RBook::TitlePage::Client.use_proxy("druby://127.0.0.1:61676")
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            RBook::TitlePage::Client.open("username", "password") do |tp|
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              puts tp.find("0091835135").product.title.titleText
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/rbook/bisac.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,87 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/po_line_item'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/../errors'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module RBook
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Bisac
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                # Represents a single BISAC purchase order
         
     | 
| 
      
 8 
     | 
    
         
            +
                class PO
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  attr_accessor :source_san, :source_suffix, :source_name
         
     | 
| 
      
 11 
     | 
    
         
            +
                  attr_accessor :date, :filename, :format_version
         
     | 
| 
      
 12 
     | 
    
         
            +
                  attr_accessor :destination_san, :destination_suffix
         
     | 
| 
      
 13 
     | 
    
         
            +
                  attr_accessor :po_number, :cancellation_date, :backorder
         
     | 
| 
      
 14 
     | 
    
         
            +
                  attr_accessor :do_not_exceed_action, :do_not_exceed_amount
         
     | 
| 
      
 15 
     | 
    
         
            +
                  attr_accessor :invoice_copies, :special_instructions
         
     | 
| 
      
 16 
     | 
    
         
            +
                  attr_accessor :do_not_ship_before
         
     | 
| 
      
 17 
     | 
    
         
            +
                  attr_accessor :items
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  # creates a new RBook::Bisac::PO object
         
     | 
| 
      
 20 
     | 
    
         
            +
                  def initialize
         
     | 
| 
      
 21 
     | 
    
         
            +
                    @items = []
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  # reads a bisac text file into memory. input should be a string 
         
     | 
| 
      
 25 
     | 
    
         
            +
                  # that specifies the file path
         
     | 
| 
      
 26 
     | 
    
         
            +
                  def self.load_from_file(input)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    raise RBook::InvalidFileError, 'Invalid file' unless File.exist?(input)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    data = []
         
     | 
| 
      
 29 
     | 
    
         
            +
                    File.open(input) do |f|
         
     | 
| 
      
 30 
     | 
    
         
            +
                      f.each_line { |l| data << l }
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
                    return self.build_message(data)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  # creates a RBook::Bisac::PO object from a string. Input should
         
     | 
| 
      
 36 
     | 
    
         
            +
                  # be a complete bisac file as a string
         
     | 
| 
      
 37 
     | 
    
         
            +
                  def self.load_from_string(input)
         
     | 
| 
      
 38 
     | 
    
         
            +
                    data = input.split("\n")
         
     | 
| 
      
 39 
     | 
    
         
            +
                    return self.build_message(data)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  private
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  def self.build_message(data)
         
     | 
| 
      
 45 
     | 
    
         
            +
                    raise Rbook::InvalidFileError, 'File appears to be too short' unless data.size >= 3
         
     | 
| 
      
 46 
     | 
    
         
            +
                    raise RBook::InvalidFileError, 'Missing header information' unless data[0][0,2].eql?("00")
         
     | 
| 
      
 47 
     | 
    
         
            +
                    raise RBook::InvalidFileError, 'Missing footer information' unless data[-1][0,2].eql?("90")
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    msg = PO.new
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                    data.each do |line|
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                      case line[0,2]
         
     | 
| 
      
 54 
     | 
    
         
            +
                      when "00" # first header
         
     | 
| 
      
 55 
     | 
    
         
            +
                        msg.source_san = line[7,7].strip
         
     | 
| 
      
 56 
     | 
    
         
            +
                        msg.source_suffix = line[14,5].strip
         
     | 
| 
      
 57 
     | 
    
         
            +
                        msg.source_name = line[19,13].strip
         
     | 
| 
      
 58 
     | 
    
         
            +
                        msg.date = line[32,6].strip
         
     | 
| 
      
 59 
     | 
    
         
            +
                        msg.filename = line[38,20].strip
         
     | 
| 
      
 60 
     | 
    
         
            +
                        msg.format_version = line[60,3].strip
         
     | 
| 
      
 61 
     | 
    
         
            +
                        msg.destination_san = line[63,7].strip
         
     | 
| 
      
 62 
     | 
    
         
            +
                        msg.destination_suffix = line[70,5].strip
         
     | 
| 
      
 63 
     | 
    
         
            +
                      when "10" # second header
         
     | 
| 
      
 64 
     | 
    
         
            +
                        msg.po_number = line[7, 12].strip
         
     | 
| 
      
 65 
     | 
    
         
            +
                        msg.cancellation_date = line[50,6].strip
         
     | 
| 
      
 66 
     | 
    
         
            +
                        msg.backorder = line[56,1].eql?("Y") ? true : false
         
     | 
| 
      
 67 
     | 
    
         
            +
                        msg.do_not_exceed_action = line[57,1].strip
         
     | 
| 
      
 68 
     | 
    
         
            +
                        msg.do_not_exceed_amount = line[58,7].strip
         
     | 
| 
      
 69 
     | 
    
         
            +
                        msg.invoice_copies = line[65,2].strip
         
     | 
| 
      
 70 
     | 
    
         
            +
                        msg.special_instructions = line[67,1].eql?("Y") ? true : false
         
     | 
| 
      
 71 
     | 
    
         
            +
                        msg.do_not_ship_before = line[73,6].strip
         
     | 
| 
      
 72 
     | 
    
         
            +
                      when "40" # line item
         
     | 
| 
      
 73 
     | 
    
         
            +
                        # load each lineitem into the message
         
     | 
| 
      
 74 
     | 
    
         
            +
                        item = RBook::Bisac::POLineItem.load_from_string(line)
         
     | 
| 
      
 75 
     | 
    
         
            +
                        msg.items << item
         
     | 
| 
      
 76 
     | 
    
         
            +
                      when "90" # footer
         
     | 
| 
      
 77 
     | 
    
         
            +
                        # check the built objects match the file
         
     | 
| 
      
 78 
     | 
    
         
            +
                      end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                    end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                    # return the results
         
     | 
| 
      
 83 
     | 
    
         
            +
                    return msg
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
              end
         
     | 
| 
      
 87 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'bigdecimal'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RBook
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Bisac
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                # represents a single line on the purchase order. Has attributes like
         
     | 
| 
      
 7 
     | 
    
         
            +
                # price, qty and description
         
     | 
| 
      
 8 
     | 
    
         
            +
                class POLineItem
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  attr_accessor :sequence_number, :po_number, :line_item_number
         
     | 
| 
      
 11 
     | 
    
         
            +
                  attr_accessor :isbn, :qty, :catalogue_code, :price 
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  # returns a new RBook::Bisac::POLineItem object using the data passed in as a string
         
     | 
| 
      
 14 
     | 
    
         
            +
                  # refer to the bisac spec for the expected format of the string
         
     | 
| 
      
 15 
     | 
    
         
            +
                  def self.load_from_string(data)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    item = self.new
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                    item.sequence_number = data[2,5].to_i
         
     | 
| 
      
 19 
     | 
    
         
            +
                    item.po_number = data[7,13].strip
         
     | 
| 
      
 20 
     | 
    
         
            +
                    item.line_item_number = data[21,10].strip
         
     | 
| 
      
 21 
     | 
    
         
            +
                    item.isbn = data[31,10].strip
         
     | 
| 
      
 22 
     | 
    
         
            +
                    item.qty = data[41,5].to_i
         
     | 
| 
      
 23 
     | 
    
         
            +
                    item.catalogue_code = data[46,1].strip
         
     | 
| 
      
 24 
     | 
    
         
            +
                    item.price = BigDecimal.new(data[47,6])
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                    return item
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/rbook/errors.rb
    CHANGED
    
    
    
        data/lib/rbook/pacstream.rb
    CHANGED
    
    | 
         @@ -1,6 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../")
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require 'net/ftp'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'tempfile'
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            module RBook
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
         @@ -36,18 +37,20 @@ module RBook 
     | 
|
| 
       36 
37 
     | 
    
         | 
| 
       37 
38 
     | 
    
         
             
                  begin
         
     | 
| 
       38 
39 
     | 
    
         
             
                    Net::FTP.open(server) do |ftp|
         
     | 
| 
      
 40 
     | 
    
         
            +
                      file_regexp = Regexp.new(".*\.#{FILE_EXTENSIONS[type]}$", Regexp::IGNORECASE)
         
     | 
| 
       39 
41 
     | 
    
         
             
                      ftp.login(args[0][:username], args[0][:password])
         
     | 
| 
       40 
42 
     | 
    
         
             
                      ftp.chdir("outgoing/")
         
     | 
| 
       41 
43 
     | 
    
         
             
                      ftp.nlst.each do |file|
         
     | 
| 
       42 
     | 
    
         
            -
                        if file.match( 
     | 
| 
       43 
     | 
    
         
            -
                           
     | 
| 
       44 
     | 
    
         
            -
                           
     | 
| 
       45 
     | 
    
         
            -
                           
     | 
| 
      
 44 
     | 
    
         
            +
                        if file.match(file_regexp)
         
     | 
| 
      
 45 
     | 
    
         
            +
                          tempfile = Tempfile.new("pacstream")
         
     | 
| 
      
 46 
     | 
    
         
            +
                          tempfile.close
         
     | 
| 
      
 47 
     | 
    
         
            +
                          ftp.getbinaryfile(file, tempfile.path)
         
     | 
| 
      
 48 
     | 
    
         
            +
                          yield File.read(tempfile.path)
         
     | 
| 
       46 
49 
     | 
    
         
             
                        end
         
     | 
| 
       47 
50 
     | 
    
         
             
                      end
         
     | 
| 
       48 
51 
     | 
    
         
             
                    end
         
     | 
| 
       49 
52 
     | 
    
         
             
                  rescue Net::FTPPermError
         
     | 
| 
       50 
     | 
    
         
            -
                    raise "Error  
     | 
| 
      
 53 
     | 
    
         
            +
                    raise "Error while communicating with the pacstream server"
         
     | 
| 
       51 
54 
     | 
    
         
             
                  end
         
     | 
| 
       52 
55 
     | 
    
         
             
                end
         
     | 
| 
       53 
56 
     | 
    
         | 
| 
         @@ -3,6 +3,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../") 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'rbook/isbn'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'rbook/errors'
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'rbook/titlepage/titlepage_driver'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'drb'
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
            module RBook
         
     | 
| 
       8 
9 
     | 
    
         
             
              module TitlePage
         
     | 
| 
         @@ -16,6 +17,25 @@ module RBook 
     | 
|
| 
       16 
17 
     | 
    
         
             
                # For a basic usage overview, check out RBook::TitlePage
         
     | 
| 
       17 
18 
     | 
    
         
             
                class Client
         
     | 
| 
       18 
19 
     | 
    
         | 
| 
      
 20 
     | 
    
         
            +
                  @@uri = nil
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  # Tells all instances of this class to query the titlepage API via a Distributed Ruby
         
     | 
| 
      
 23 
     | 
    
         
            +
                  # proxy. This is useful where multiple machines need to make queries and you need to be
         
     | 
| 
      
 24 
     | 
    
         
            +
                  # careful not to exceed the maximum query rate.
         
     | 
| 
      
 25 
     | 
    
         
            +
                  #
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # There is an example proxy executable available in the bin/ directory of rbook.
         
     | 
| 
      
 27 
     | 
    
         
            +
                  #
         
     | 
| 
      
 28 
     | 
    
         
            +
                  # Assuming the proxy is running on port 61676 of the local machine, the following
         
     | 
| 
      
 29 
     | 
    
         
            +
                  # code can be used to query titlepage:
         
     | 
| 
      
 30 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 31 
     | 
    
         
            +
                  #   RBook::TitlePage::Client.use_proxy("druby://127.0.0.1:61676")
         
     | 
| 
      
 32 
     | 
    
         
            +
                  #   RBook::TitlePage::Client.open("username", "password") do |tp|
         
     | 
| 
      
 33 
     | 
    
         
            +
                  #     puts tp.find("0091835135").product.title.titleText
         
     | 
| 
      
 34 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 35 
     | 
    
         
            +
                  def self.use_proxy(uri)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @@uri = uri
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       19 
39 
     | 
    
         
             
                  # Optional driver parameter allows an alternative SOAP driver to the default to be specified.
         
     | 
| 
       20 
40 
     | 
    
         
             
                  # This is primarily for testing purposes and probably isn't useful to anyone in the real world.
         
     | 
| 
       21 
41 
     | 
    
         
             
                  def initialize(driver = nil)
         
     | 
| 
         @@ -27,24 +47,37 @@ module RBook 
     | 
|
| 
       27 
47 
     | 
    
         
             
                  def login(username, password)
         
     | 
| 
       28 
48 
     | 
    
         
             
                    raise InvalidRubyVersionError, 'Ruby 1.8.3 or higher is required to use this class' unless RUBY_VERSION >= "1.8.3"
         
     | 
| 
       29 
49 
     | 
    
         
             
                    logout if @token
         
     | 
| 
       30 
     | 
    
         
            -
                    @ 
     | 
| 
       31 
     | 
    
         
            -
                     
     | 
| 
      
 50 
     | 
    
         
            +
                    @username = username
         
     | 
| 
      
 51 
     | 
    
         
            +
                    @password = password
         
     | 
| 
      
 52 
     | 
    
         
            +
                    unless @@uri
         
     | 
| 
      
 53 
     | 
    
         
            +
                      @token = @driver.login(username, password)
         
     | 
| 
      
 54 
     | 
    
         
            +
                      return true if @token
         
     | 
| 
      
 55 
     | 
    
         
            +
                    end
         
     | 
| 
       32 
56 
     | 
    
         
             
                  end
         
     | 
| 
       33 
57 
     | 
    
         | 
| 
       34 
58 
     | 
    
         
             
                  # logout from the titlepage API
         
     | 
| 
       35 
59 
     | 
    
         
             
                  def logout
         
     | 
| 
       36 
     | 
    
         
            -
                     
     | 
| 
      
 60 
     | 
    
         
            +
                    @username = nil
         
     | 
| 
      
 61 
     | 
    
         
            +
                    @password = nil
         
     | 
| 
      
 62 
     | 
    
         
            +
                    if @token and @@uri != nil
         
     | 
| 
       37 
63 
     | 
    
         
             
                      @driver.logout(@token)
         
     | 
| 
      
 64 
     | 
    
         
            +
                    else
         
     | 
| 
      
 65 
     | 
    
         
            +
                      true
         
     | 
| 
       38 
66 
     | 
    
         
             
                    end
         
     | 
| 
       39 
67 
     | 
    
         
             
                  end
         
     | 
| 
       40 
68 
     | 
    
         | 
| 
       41 
69 
     | 
    
         
             
                  # retrieve information on a specified ISBN
         
     | 
| 
       42 
70 
     | 
    
         
             
                  def find(isbn)
         
     | 
| 
       43 
     | 
    
         
            -
                    return NotLoggedInError, 'You must login to titlepage API before performing a search' unless @token
         
     | 
| 
      
 71 
     | 
    
         
            +
                    return NotLoggedInError, 'You must login to titlepage API before performing a search' unless @token || @@uri
         
     | 
| 
       44 
72 
     | 
    
         
             
                    isbn = ISBN::convert_to_isbn13(isbn)
         
     | 
| 
       45 
73 
     | 
    
         
             
                    return nil if isbn.nil?
         
     | 
| 
       46 
74 
     | 
    
         
             
                    begin
         
     | 
| 
       47 
     | 
    
         
            -
                       
     | 
| 
      
 75 
     | 
    
         
            +
                      if @@uri
         
     | 
| 
      
 76 
     | 
    
         
            +
                        proxy = DRbObject.new_with_uri(@@uri)
         
     | 
| 
      
 77 
     | 
    
         
            +
                        result = proxy.find(@username, @password, isbn) 
         
     | 
| 
      
 78 
     | 
    
         
            +
                      else
         
     | 
| 
      
 79 
     | 
    
         
            +
                        result = @driver.SearchByEAN(@token, isbn)
         
     | 
| 
      
 80 
     | 
    
         
            +
                      end
         
     | 
| 
       48 
81 
     | 
    
         
             
                      if result.Product.nil?
         
     | 
| 
       49 
82 
     | 
    
         
             
                        return nil
         
     | 
| 
       50 
83 
     | 
    
         
             
                      else
         
     | 
| 
         @@ -0,0 +1,112 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            00000019013725     Rainbow Book 061112INTERNET.BSC          F039021000          
         
     | 
| 
      
 2 
     | 
    
         
            +
            1000002 14976       9013725     9021000     061112000000Y 000000001N00020000000 
         
     | 
| 
      
 3 
     | 
    
         
            +
            4000003 14976       Y000000000102978513220000100000000000000000000550000000     
         
     | 
| 
      
 4 
     | 
    
         
            +
            4100004 14976          Finding Sanctuary :Monastic St
         
     | 
| 
      
 5 
     | 
    
         
            +
            4200005 14976                        JAMISON ABBOT CHRISTOPH
         
     | 
| 
      
 6 
     | 
    
         
            +
            4000006 14976       Y000000000203407855780000100000000000000000000550000000     
         
     | 
| 
      
 7 
     | 
    
         
            +
            4100007 14976          In My Own Words: Padre Pio    
         
     | 
| 
      
 8 
     | 
    
         
            +
            4200008 14976                        CHIFFOLO ANTHONY       
         
     | 
| 
      
 9 
     | 
    
         
            +
            4000009 14976       Y000000000303408635440000100000000000000000000550000000     
         
     | 
| 
      
 10 
     | 
    
         
            +
            4100010 14976          Knowing God New Edn.With Study
         
     | 
| 
      
 11 
     | 
    
         
            +
            4200011 14976                        PACKER J I             
         
     | 
| 
      
 12 
     | 
    
         
            +
            4000012 14976       Y000000000403409111580000100000000000000000000550000000     
         
     | 
| 
      
 13 
     | 
    
         
            +
            4100013 14976          Everyone I See Is Luckier Than
         
     | 
| 
      
 14 
     | 
    
         
            +
            4200014 14976                        BEVAN CLARE            
         
     | 
| 
      
 15 
     | 
    
         
            +
            4000015 14976       Y000000000503409111740000100000000000000000000550000000     
         
     | 
| 
      
 16 
     | 
    
         
            +
            4100016 14976          I Want To Shout And Stamp Abou
         
     | 
| 
      
 17 
     | 
    
         
            +
            4200017 14976                        MITTON TONY            
         
     | 
| 
      
 18 
     | 
    
         
            +
            4000018 14976       Y000000000605670406230000100000000000000000000550000000     
         
     | 
| 
      
 19 
     | 
    
         
            +
            4100019 14976          Gnostics :Identifying an Ancie
         
     | 
| 
      
 20 
     | 
    
         
            +
            4200020 14976                        LOGAN, ALASTAIR        
         
     | 
| 
      
 21 
     | 
    
         
            +
            4000021 14976       Y000000000705670875140000100000000000000000000550000000     
         
     | 
| 
      
 22 
     | 
    
         
            +
            4100022 14976          Mary For All Christians       
         
     | 
| 
      
 23 
     | 
    
         
            +
            4200023 14976                        MACQUARRIE J           
         
     | 
| 
      
 24 
     | 
    
         
            +
            4000024 14976       Y000000000806425620750000100000000000000000000550000000     
         
     | 
| 
      
 25 
     | 
    
         
            +
            4100025 14976          Forgiveness and Other Acts of 
         
     | 
| 
      
 26 
     | 
    
         
            +
            4200026 14976                        DOWRICK STEPHANIE      
         
     | 
| 
      
 27 
     | 
    
         
            +
            4000027 14976       Y000000000907333174560000100000000000000000000550000000     
         
     | 
| 
      
 28 
     | 
    
         
            +
            4100028 14976          Honey and The Fires: Ancient s
         
     | 
| 
      
 29 
     | 
    
         
            +
            4200029 14976                        PULVERS ROGER & ALICE  
         
     | 
| 
      
 30 
     | 
    
         
            +
            4000030 14976       Y000000001007333179600000100000000000000000000550000000     
         
     | 
| 
      
 31 
     | 
    
         
            +
            4100031 14976          Mummy Book                    
         
     | 
| 
      
 32 
     | 
    
         
            +
            4200032 14976                        PARR TODD              
         
     | 
| 
      
 33 
     | 
    
         
            +
            4000033 14976       Y000000001107333198230000100000000000000000000550000000     
         
     | 
| 
      
 34 
     | 
    
         
            +
            4100034 14976          So Many Selves                
         
     | 
| 
      
 35 
     | 
    
         
            +
            4200035 14976                        CAREY GABRIELLE        
         
     | 
| 
      
 36 
     | 
    
         
            +
            4000036 14976       Y000000001207336159880000100000000000000000000550000000     
         
     | 
| 
      
 37 
     | 
    
         
            +
            4100037 14976          New Glucose Revolution Pocket 
         
     | 
| 
      
 38 
     | 
    
         
            +
            4200038 14976                        MILLET ET AL           
         
     | 
| 
      
 39 
     | 
    
         
            +
            4000039 14976       Y000000001307475413530000100000000000000000000550000000     
         
     | 
| 
      
 40 
     | 
    
         
            +
            4100040 14976          Achieving Emotional Literacy  
         
     | 
| 
      
 41 
     | 
    
         
            +
            4200041 14976                        STEINER CLAUDE         
         
     | 
| 
      
 42 
     | 
    
         
            +
            4000042 14976       Y000000001407499210990000100000000000000000000550000000     
         
     | 
| 
      
 43 
     | 
    
         
            +
            4100043 14976          How Meditation Heals          
         
     | 
| 
      
 44 
     | 
    
         
            +
            4200044 14976                        HARRISON ERIC          
         
     | 
| 
      
 45 
     | 
    
         
            +
            4000045 14976       Y000000001507499242170000100000000000000000000550000000     
         
     | 
| 
      
 46 
     | 
    
         
            +
            4100046 14976          Other Side and Back :A Psychic
         
     | 
| 
      
 47 
     | 
    
         
            +
            4200047 14976                        BROWNE SYLVIA          
         
     | 
| 
      
 48 
     | 
    
         
            +
            4000048 14976       Y000000001607502213130000100000000000000000000550000000     
         
     | 
| 
      
 49 
     | 
    
         
            +
            4100049 14976          I'm Worried :Your Emotions Pb 
         
     | 
| 
      
 50 
     | 
    
         
            +
            4200050 14976                        MOSES BRIAN            
         
     | 
| 
      
 51 
     | 
    
         
            +
            4000051 14976       Y000000001707502213210000100000000000000000000550000000     
         
     | 
| 
      
 52 
     | 
    
         
            +
            4100052 14976          It's Not Fair :Your Feelings P
         
     | 
| 
      
 53 
     | 
    
         
            +
            4200053 14976                        MOSES BRIAN            
         
     | 
| 
      
 54 
     | 
    
         
            +
            4000054 14976       Y000000001807538205440000100000000000000000000550000000     
         
     | 
| 
      
 55 
     | 
    
         
            +
            4100055 14976          Memory and Identity :Personal 
         
     | 
| 
      
 56 
     | 
    
         
            +
            4200056 14976                        PAUL JOHN II           
         
     | 
| 
      
 57 
     | 
    
         
            +
            4000057 14976       Y000000001908192198190000100000000000000000000550000000     
         
     | 
| 
      
 58 
     | 
    
         
            +
            4100058 14976          Gift of Faith (Morehouse) :Sho
         
     | 
| 
      
 59 
     | 
    
         
            +
            4200059 14976                        NEFF LAVONNE           
         
     | 
| 
      
 60 
     | 
    
         
            +
            4000060 14976       Y0000000020082646520X0000200000000000000000000550000000     
         
     | 
| 
      
 61 
     | 
    
         
            +
            4100061 14976          Pastoral Prayers              
         
     | 
| 
      
 62 
     | 
    
         
            +
            4200062 14976                        DEADMAN R              
         
     | 
| 
      
 63 
     | 
    
         
            +
            4000063 14976       Y000000002108264685000000200000000000000000000550000000     
         
     | 
| 
      
 64 
     | 
    
         
            +
            4100064 14976          Dignity of Difference P/B: How
         
     | 
| 
      
 65 
     | 
    
         
            +
            4200065 14976                        SACKS JONATHAN         
         
     | 
| 
      
 66 
     | 
    
         
            +
            4000066 14976       Y000000002208264733770000100000000000000000000550000000     
         
     | 
| 
      
 67 
     | 
    
         
            +
            4100067 14976          Celebrating Life :Finding happ
         
     | 
| 
      
 68 
     | 
    
         
            +
            4200068 14976                        SACKS JONATHAN         
         
     | 
| 
      
 69 
     | 
    
         
            +
            4000069 14976       Y000000002308264748100000100000000000000000000550000000     
         
     | 
| 
      
 70 
     | 
    
         
            +
            4100070 14976          From Optimism to Hope         
         
     | 
| 
      
 71 
     | 
    
         
            +
            4200071 14976                        SACKS JONATHAN         
         
     | 
| 
      
 72 
     | 
    
         
            +
            4000072 14976       Y000000002408264785570000100000000000000000000550000000     
         
     | 
| 
      
 73 
     | 
    
         
            +
            4100073 14976          Persistence of Faith :Religion
         
     | 
| 
      
 74 
     | 
    
         
            +
            4200074 14976                        JONATHAN SACKS         
         
     | 
| 
      
 75 
     | 
    
         
            +
            4000075 14976       Y000000002508264794210000100000000000000000000550000000     
         
     | 
| 
      
 76 
     | 
    
         
            +
            4100076 14976          Shape of the Liturgy New Ed.  
         
     | 
| 
      
 77 
     | 
    
         
            +
            4200077 14976                        DIX GREGORY            
         
     | 
| 
      
 78 
     | 
    
         
            +
            4000078 14976       Y000000002608601242580000200000000000000000000550000000     
         
     | 
| 
      
 79 
     | 
    
         
            +
            4100079 14976          Essence of Prayer             
         
     | 
| 
      
 80 
     | 
    
         
            +
            4200080 14976                        BURROWS RUTH           
         
     | 
| 
      
 81 
     | 
    
         
            +
            4000081 14976       Y000000002715633841400000100000000000000000000550000000     
         
     | 
| 
      
 82 
     | 
    
         
            +
            4100082 14976          Theological Perspectives On Go
         
     | 
| 
      
 83 
     | 
    
         
            +
            4200083 14976                        MILBANK & WRD          
         
     | 
| 
      
 84 
     | 
    
         
            +
            4000084 14976       Y000000002817411479210000200000000000000000000550000000     
         
     | 
| 
      
 85 
     | 
    
         
            +
            4100085 14976          David Suzuki                  
         
     | 
| 
      
 86 
     | 
    
         
            +
            4200086 14976                        SUZUKI DAVID           
         
     | 
| 
      
 87 
     | 
    
         
            +
            4000087 14976       Y000000002917411484640000100000000000000000000550000000     
         
     | 
| 
      
 88 
     | 
    
         
            +
            4100088 14976          Holism and Complementary Medic
         
     | 
| 
      
 89 
     | 
    
         
            +
            4200089 14976                        DI STEFANO VINCENT     
         
     | 
| 
      
 90 
     | 
    
         
            +
            4000090 14976       Y000000003018418129270000100000000000000000000550000000     
         
     | 
| 
      
 91 
     | 
    
         
            +
            4100091 14976          Personal power animals :for gu
         
     | 
| 
      
 92 
     | 
    
         
            +
            4200092 14976                        GAUDING MADONNA        
         
     | 
| 
      
 93 
     | 
    
         
            +
            4000093 14976       Y000000003118644894130000100000000000000000000550000000     
         
     | 
| 
      
 94 
     | 
    
         
            +
            4100094 14976          Earth Time                    
         
     | 
| 
      
 95 
     | 
    
         
            +
            4200095 14976                        SUZUKI DAVID           
         
     | 
| 
      
 96 
     | 
    
         
            +
            4000096 14976       Y000000003218650838440000100000000000000000000550000000     
         
     | 
| 
      
 97 
     | 
    
         
            +
            4100097 14976          Facing The Fifties            
         
     | 
| 
      
 98 
     | 
    
         
            +
            4200098 14976                        O'CONNOR PETER         
         
     | 
| 
      
 99 
     | 
    
         
            +
            4000099 14976       Y000000003318650891760000100000000000000000000550000000     
         
     | 
| 
      
 100 
     | 
    
         
            +
            4100100 14976          Long Way from Rome A: Why the 
         
     | 
| 
      
 101 
     | 
    
         
            +
            4200101 14976                        MCGILLION CHRIS (ED)   
         
     | 
| 
      
 102 
     | 
    
         
            +
            4000102 14976       Y000000003418891089600000100000000000000000000550000000     
         
     | 
| 
      
 103 
     | 
    
         
            +
            4100103 14976          14 Presentations for Fall (God
         
     | 
| 
      
 104 
     | 
    
         
            +
            4200104 14976                        BERRYMAN JEROME W      
         
     | 
| 
      
 105 
     | 
    
         
            +
            4000105 14976       Y000000003518891089790000100000000000000000000550000000     
         
     | 
| 
      
 106 
     | 
    
         
            +
            4100106 14976          20 Presentations for Winter (G
         
     | 
| 
      
 107 
     | 
    
         
            +
            4200107 14976                        BERRYMAN JEROME  W     
         
     | 
| 
      
 108 
     | 
    
         
            +
            4000108 14976       Y000000003618891089870000100000000000000000000550000000     
         
     | 
| 
      
 109 
     | 
    
         
            +
            4100109 14976          20 Presentations for Spring (G
         
     | 
| 
      
 110 
     | 
    
         
            +
            4200110 14976                        BERRYMAN JEROME W      
         
     | 
| 
      
 111 
     | 
    
         
            +
            5000111 14976       0011000000000360000000040                                   
         
     | 
| 
      
 112 
     | 
    
         
            +
            90001120000000000036000010000000040000010000100000000000003600001000000000000000
         
     | 
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            $LOAD_PATH.unshift(File.dirname(__FILE__) + ' 
     | 
| 
      
 1 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib')
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require 'test/unit'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'rbook/bisac'
         
     | 
| 
         @@ -37,7 +37,7 @@ class BISACTest < Test::Unit::TestCase 
     | 
|
| 
       37 
37 
     | 
    
         
             
              end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
              def test_load_from_file
         
     | 
| 
       40 
     | 
    
         
            -
                msg = RBook::Bisac::Message.load(File.dirname(__FILE__) + " 
     | 
| 
      
 40 
     | 
    
         
            +
                msg = RBook::Bisac::Message.load(File.dirname(__FILE__) + "/../../data/valid_bisac.txt")
         
     | 
| 
       41 
41 
     | 
    
         
             
                assert_equal "SAND", msg.company
         
     | 
| 
       42 
42 
     | 
    
         
             
                assert_equal "9012982", msg.san
         
     | 
| 
       43 
43 
     | 
    
         
             
                assert_equal "000001", msg.batch
         
     | 
| 
         @@ -0,0 +1,38 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'rbook/bisac'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            class POLineItemTest < Test::Unit::TestCase
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 9 
     | 
    
         
            +
                @row = "4000003 14976       Y000000000102978513220000100000000000000000000550000000"
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              # ensure the load_from_string method works as expected
         
     | 
| 
      
 13 
     | 
    
         
            +
              def test_load_from_string
         
     | 
| 
      
 14 
     | 
    
         
            +
                item = RBook::Bisac::POLineItem.load_from_string(@row)
         
     | 
| 
      
 15 
     | 
    
         
            +
                assert_kind_of RBook::Bisac::POLineItem, item
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                assert_equal item.sequence_number, 3
         
     | 
| 
      
 18 
     | 
    
         
            +
                assert_equal item.po_number, "14976"
         
     | 
| 
      
 19 
     | 
    
         
            +
                assert_equal item.line_item_number, "0000000001"
         
     | 
| 
      
 20 
     | 
    
         
            +
                assert_equal item.isbn, "0297851322"
         
     | 
| 
      
 21 
     | 
    
         
            +
                assert_equal item.qty, 1
         
     | 
| 
      
 22 
     | 
    
         
            +
                assert_equal item.catalogue_code, "0"
         
     | 
| 
      
 23 
     | 
    
         
            +
                assert_equal item.price, 0
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              # ensure the load_from_file method throws the correct exceptions
         
     | 
| 
      
 27 
     | 
    
         
            +
              # when it encounters a problem
         
     | 
| 
      
 28 
     | 
    
         
            +
              def test_product_validation
         
     | 
| 
      
 29 
     | 
    
         
            +
                
         
     | 
| 
      
 30 
     | 
    
         
            +
                #assert_raise(RVista::InvalidLineItemError) {
         
     | 
| 
      
 31 
     | 
    
         
            +
                #  item = RVista::LineItem.load_from_array(%w[D blah])
         
     | 
| 
      
 32 
     | 
    
         
            +
                #}
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,79 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'rbook/bisac'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            class POTest < Test::Unit::TestCase
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              VALID = File.dirname(__FILE__) + "/../../data/bisac_po.txt"
         
     | 
| 
      
 9 
     | 
    
         
            +
              #INVALID_MISSING_HEADER = File.dirname(__FILE__) + "/../data/invalid_missing_header.txt"
         
     | 
| 
      
 10 
     | 
    
         
            +
              #INVALID_MISSING_FOOTER = File.dirname(__FILE__) + "/../data/invalid_missing_footer.txt"
         
     | 
| 
      
 11 
     | 
    
         
            +
              #INVALID_LINE = File.dirname(__FILE__) + "/../data/invalid_line.txt"
         
     | 
| 
      
 12 
     | 
    
         
            +
              #INVALID_DOESNT_EXIST = File.dirname(__FILE__) + "/../data/blah.txt"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              # ensure the load_from_file method works as expected
         
     | 
| 
      
 15 
     | 
    
         
            +
              def test_load_from_file
         
     | 
| 
      
 16 
     | 
    
         
            +
                msg = RBook::Bisac::PO.load_from_file(VALID)
         
     | 
| 
      
 17 
     | 
    
         
            +
                assert_kind_of RBook::Bisac::PO, msg
         
     | 
| 
      
 18 
     | 
    
         
            +
                assert_equal msg.items.size, 36
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                validate_msg(msg)
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              # ensure the load_from_file method works as expected
         
     | 
| 
      
 24 
     | 
    
         
            +
              def test_load_from_string
         
     | 
| 
      
 25 
     | 
    
         
            +
                msg = RBook::Bisac::PO.load_from_string(File.read(VALID))
         
     | 
| 
      
 26 
     | 
    
         
            +
                assert_kind_of RBook::Bisac::PO, msg
         
     | 
| 
      
 27 
     | 
    
         
            +
                assert_equal msg.items.size, 36
         
     | 
| 
      
 28 
     | 
    
         
            +
                
         
     | 
| 
      
 29 
     | 
    
         
            +
                validate_msg(msg)
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              # ensure the load_from_file method throws the correct exceptions
         
     | 
| 
      
 33 
     | 
    
         
            +
              # when it encounters a problem
         
     | 
| 
      
 34 
     | 
    
         
            +
              def test_product_validation
         
     | 
| 
      
 35 
     | 
    
         
            +
                
         
     | 
| 
      
 36 
     | 
    
         
            +
                #assert_raise(RVista::InvalidFileError) {
         
     | 
| 
      
 37 
     | 
    
         
            +
                #  msg = RVista::Message.load_from_file(INVALID_MISSING_HEADER)
         
     | 
| 
      
 38 
     | 
    
         
            +
                #}
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                #assert_raise(RVista::InvalidFileError) {
         
     | 
| 
      
 41 
     | 
    
         
            +
                #  msg = RVista::Message.load_from_file(INVALID_MISSING_FOOTER)
         
     | 
| 
      
 42 
     | 
    
         
            +
                #}
         
     | 
| 
      
 43 
     | 
    
         
            +
                
         
     | 
| 
      
 44 
     | 
    
         
            +
                #assert_raise(RVista::InvalidLineItemError) {
         
     | 
| 
      
 45 
     | 
    
         
            +
                #  msg = RVista::Message.load_from_file(INVALID_LINE)
         
     | 
| 
      
 46 
     | 
    
         
            +
                #}
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                #assert_raise(RVista::InvalidFileError) {
         
     | 
| 
      
 49 
     | 
    
         
            +
                #  msg = RVista::Message.load_from_file(INVALID_DOESNT_EXIST)
         
     | 
| 
      
 50 
     | 
    
         
            +
                #}
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              private
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              # ensures the properties of the supplied RVista::Message object
         
     | 
| 
      
 57 
     | 
    
         
            +
              # match the properties specified in the VALID file
         
     | 
| 
      
 58 
     | 
    
         
            +
              def validate_msg(msg)
         
     | 
| 
      
 59 
     | 
    
         
            +
                assert_equal msg.source_san, "9013725"
         
     | 
| 
      
 60 
     | 
    
         
            +
                assert_equal msg.source_suffix, ""
         
     | 
| 
      
 61 
     | 
    
         
            +
                assert_equal msg.source_name, "Rainbow Book"
         
     | 
| 
      
 62 
     | 
    
         
            +
                assert_equal msg.date, "061112"
         
     | 
| 
      
 63 
     | 
    
         
            +
                assert_equal msg.filename, "INTERNET.BSC"
         
     | 
| 
      
 64 
     | 
    
         
            +
                assert_equal msg.format_version, "F03"
         
     | 
| 
      
 65 
     | 
    
         
            +
                assert_equal msg.destination_san, "9021000"
         
     | 
| 
      
 66 
     | 
    
         
            +
                assert_equal msg.destination_suffix, ""
         
     | 
| 
      
 67 
     | 
    
         
            +
                assert_equal msg.po_number, "14976"
         
     | 
| 
      
 68 
     | 
    
         
            +
                assert_equal msg.cancellation_date, "000000"
         
     | 
| 
      
 69 
     | 
    
         
            +
                assert_equal msg.backorder, true
         
     | 
| 
      
 70 
     | 
    
         
            +
                assert_equal msg.do_not_exceed_action, ""
         
     | 
| 
      
 71 
     | 
    
         
            +
                assert_equal msg.do_not_exceed_amount, "0000000"
         
     | 
| 
      
 72 
     | 
    
         
            +
                assert_equal msg.invoice_copies, "01"
         
     | 
| 
      
 73 
     | 
    
         
            +
                assert_equal msg.special_instructions, false
         
     | 
| 
      
 74 
     | 
    
         
            +
                assert_equal msg.do_not_ship_before, "000000"
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -3,8 +3,8 @@ rubygems_version: 0.9.0 
     | 
|
| 
       3 
3 
     | 
    
         
             
            specification_version: 1
         
     | 
| 
       4 
4 
     | 
    
         
             
            name: rbook
         
     | 
| 
       5 
5 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       6 
     | 
    
         
            -
              version:  
     | 
| 
       7 
     | 
    
         
            -
            date: 2006- 
     | 
| 
      
 6 
     | 
    
         
            +
              version: 0.4.1
         
     | 
| 
      
 7 
     | 
    
         
            +
            date: 2006-11-20 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,28 +31,35 @@ authors: 
     | 
|
| 
       31 
31 
     | 
    
         
             
            files: 
         
     | 
| 
       32 
32 
     | 
    
         
             
            - examples/www
         
     | 
| 
       33 
33 
     | 
    
         
             
            - examples/onix
         
     | 
| 
      
 34 
     | 
    
         
            +
            - examples/43.ord
         
     | 
| 
       34 
35 
     | 
    
         
             
            - examples/titlepage.rb
         
     | 
| 
       35 
     | 
    
         
            -
            - examples/gbip.rb
         
     | 
| 
       36 
36 
     | 
    
         
             
            - examples/pacstream.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - examples/gbip.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - examples/titlepage_with_proxy.rb
         
     | 
| 
       37 
39 
     | 
    
         
             
            - examples/www/list.rb
         
     | 
| 
       38 
40 
     | 
    
         
             
            - examples/www/find_cover_from_amazon.rb
         
     | 
| 
       39 
41 
     | 
    
         
             
            - examples/www/find_url_from_rainbow.rb
         
     | 
| 
       40 
42 
     | 
    
         
             
            - examples/www/find_all.rb
         
     | 
| 
       41 
43 
     | 
    
         
             
            - examples/onix/stream_reader.rb
         
     | 
| 
       42 
44 
     | 
    
         
             
            - lib/rbook
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/rbook/bisac
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib/rbook/gbip
         
     | 
| 
       43 
47 
     | 
    
         
             
            - lib/rbook/www
         
     | 
| 
       44 
48 
     | 
    
         
             
            - lib/rbook/onix
         
     | 
| 
       45 
49 
     | 
    
         
             
            - lib/rbook/titlepage
         
     | 
| 
       46 
50 
     | 
    
         
             
            - lib/rbook/titlepage.rb
         
     | 
| 
       47 
51 
     | 
    
         
             
            - lib/rbook/onix.rb
         
     | 
| 
       48 
     | 
    
         
            -
            - lib/rbook/ 
     | 
| 
      
 52 
     | 
    
         
            +
            - lib/rbook/pacstream.rb
         
     | 
| 
       49 
53 
     | 
    
         
             
            - lib/rbook/bisac.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - lib/rbook/gbip.rb
         
     | 
| 
       50 
55 
     | 
    
         
             
            - lib/rbook/www.rb
         
     | 
| 
       51 
56 
     | 
    
         
             
            - lib/rbook/isbn.rb
         
     | 
| 
       52 
     | 
    
         
            -
            - lib/rbook/ 
     | 
| 
       53 
     | 
    
         
            -
            - lib/rbook/ 
     | 
| 
       54 
     | 
    
         
            -
            - lib/rbook/ 
     | 
| 
       55 
     | 
    
         
            -
            - lib/rbook/ 
     | 
| 
      
 57 
     | 
    
         
            +
            - lib/rbook/errors.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            - lib/rbook/bisac/po.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - lib/rbook/bisac/product.rb
         
     | 
| 
      
 60 
     | 
    
         
            +
            - lib/rbook/bisac/message.rb
         
     | 
| 
      
 61 
     | 
    
         
            +
            - lib/rbook/bisac/po_line_item.rb
         
     | 
| 
      
 62 
     | 
    
         
            +
            - lib/rbook/gbip/pos.rb
         
     | 
| 
       56 
63 
     | 
    
         
             
            - lib/rbook/www/wiley_us_scraper.rb
         
     | 
| 
       57 
64 
     | 
    
         
             
            - lib/rbook/www/hha_scraper.rb
         
     | 
| 
       58 
65 
     | 
    
         
             
            - lib/rbook/www/random_au_scraper.rb
         
     | 
| 
         @@ -71,38 +78,38 @@ files: 
     | 
|
| 
       71 
78 
     | 
    
         
             
            - lib/rbook/www/base.rb
         
     | 
| 
       72 
79 
     | 
    
         
             
            - lib/rbook/www/macmillan_scraper.rb
         
     | 
| 
       73 
80 
     | 
    
         
             
            - lib/rbook/onix/lists
         
     | 
| 
       74 
     | 
    
         
            -
            - lib/rbook/onix/product.rb
         
     | 
| 
       75 
     | 
    
         
            -
            - lib/rbook/onix/lists.rb
         
     | 
| 
       76 
81 
     | 
    
         
             
            - lib/rbook/onix/sales_restriction.rb
         
     | 
| 
      
 82 
     | 
    
         
            +
            - lib/rbook/onix/stream_reader.rb
         
     | 
| 
      
 83 
     | 
    
         
            +
            - lib/rbook/onix/lists.rb
         
     | 
| 
       77 
84 
     | 
    
         
             
            - lib/rbook/onix/supply_detail.rb
         
     | 
| 
      
 85 
     | 
    
         
            +
            - lib/rbook/onix/product.rb
         
     | 
| 
       78 
86 
     | 
    
         
             
            - lib/rbook/onix/message.rb
         
     | 
| 
       79 
87 
     | 
    
         
             
            - lib/rbook/onix/xchar.rb
         
     | 
| 
       80 
     | 
    
         
            -
            - lib/rbook/onix/contributor.rb
         
     | 
| 
       81 
     | 
    
         
            -
            - lib/rbook/onix/stream_reader.rb
         
     | 
| 
       82 
88 
     | 
    
         
             
            - lib/rbook/onix/stream_writer.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
            - lib/rbook/onix/contributor.rb
         
     | 
| 
       83 
90 
     | 
    
         
             
            - lib/rbook/onix/lists/contributor_role.rb
         
     | 
| 
       84 
91 
     | 
    
         
             
            - lib/rbook/onix/lists/product_form.rb
         
     | 
| 
       85 
92 
     | 
    
         
             
            - lib/rbook/titlepage/client.rb
         
     | 
| 
       86 
93 
     | 
    
         
             
            - lib/rbook/titlepage/titlepage_utils.rb
         
     | 
| 
       87 
94 
     | 
    
         
             
            - lib/rbook/titlepage/titlepage_driver.rb
         
     | 
| 
       88 
     | 
    
         
            -
            - lib/rbook/bisac/product.rb
         
     | 
| 
       89 
     | 
    
         
            -
            - lib/rbook/bisac/message.rb
         
     | 
| 
       90 
     | 
    
         
            -
            - lib/rbook/gbip/pos.rb
         
     | 
| 
       91 
95 
     | 
    
         
             
            - test/unit
         
     | 
| 
       92 
96 
     | 
    
         
             
            - test/data
         
     | 
| 
       93 
97 
     | 
    
         
             
            - test/mocks
         
     | 
| 
       94 
98 
     | 
    
         
             
            - test/unit/onix
         
     | 
| 
       95 
99 
     | 
    
         
             
            - test/unit/titlepage_test.rb
         
     | 
| 
       96 
     | 
    
         
            -
            - test/unit/bisac_test.rb
         
     | 
| 
       97 
100 
     | 
    
         
             
            - test/unit/isbn_test.rb
         
     | 
| 
      
 101 
     | 
    
         
            +
            - test/unit/bisac
         
     | 
| 
       98 
102 
     | 
    
         
             
            - test/unit/onix/sales_restriction_test.rb
         
     | 
| 
       99 
103 
     | 
    
         
             
            - test/unit/onix/supply_detail_test.rb
         
     | 
| 
       100 
104 
     | 
    
         
             
            - test/unit/onix/product_test.rb
         
     | 
| 
       101 
105 
     | 
    
         
             
            - test/unit/onix/message_test.rb
         
     | 
| 
       102 
106 
     | 
    
         
             
            - test/unit/onix/xchar_test.rb
         
     | 
| 
       103 
     | 
    
         
            -
            - test/unit/onix/contributor_test.rb
         
     | 
| 
       104 
107 
     | 
    
         
             
            - test/unit/onix/stream_writer_test.rb
         
     | 
| 
      
 108 
     | 
    
         
            +
            - test/unit/onix/contributor_test.rb
         
     | 
| 
       105 
109 
     | 
    
         
             
            - 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
         
     | 
| 
       106 
113 
     | 
    
         
             
            - test/data/xml_not_onix.xml
         
     | 
| 
       107 
114 
     | 
    
         
             
            - test/data/abingdon.xml
         
     | 
| 
       108 
115 
     | 
    
         
             
            - test/data/invalid_no_product.xml
         
     | 
| 
         @@ -112,6 +119,7 @@ files: 
     | 
|
| 
       112 
119 
     | 
    
         
             
            - test/data/valid_bisac.txt
         
     | 
| 
       113 
120 
     | 
    
         
             
            - test/data/eerdsman.xml
         
     | 
| 
       114 
121 
     | 
    
         
             
            - test/data/augsburg.xml
         
     | 
| 
      
 122 
     | 
    
         
            +
            - test/data/bisac_po.txt
         
     | 
| 
       115 
123 
     | 
    
         
             
            - test/mocks/titlepage_driver.rb
         
     | 
| 
       116 
124 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       117 
125 
     | 
    
         
             
            - README
         
     |