gbip 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,8 +1,12 @@
1
- v0.8.0 (7th November)
1
+ v0.8.1 (11th June 2009)
2
+ - Fix parsing of API responses that contain multiple results
3
+ - small update to specs
4
+
5
+ v0.8.0 (7th November 2008)
2
6
  - Add checks for additional error codes, and raise an appropriate error
3
7
  - overhauled specs
4
8
 
5
- v0.7.1 (14th October)
9
+ v0.7.1 (14th October 2008)
6
10
  - Correctly parse API responses that contain a # in their data
7
11
  - Use ISBN13s in queries. No change to user API (we accept ISBN10s or ISBN13s)
8
12
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/testtask'
5
5
  require "rake/gempackagetask"
6
6
  require 'spec/rake/spectask'
7
7
 
8
- PKG_VERSION = "0.8.0"
8
+ PKG_VERSION = "0.8.1"
9
9
  PKG_NAME = "gbip"
10
10
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
11
11
  RUBYFORGE_PROJECT = 'rbook'
data/lib/gbip/pos.rb CHANGED
@@ -26,6 +26,7 @@ module GBIP
26
26
  # Supported options:
27
27
  # :markets => only search the specified markets. comma sperated list
28
28
  # :timeout => amount of time in seconds to wait for a reponse from the server before timing out. Defaults to 10.
29
+ #
29
30
  def find(type, isbn, options = {})
30
31
  case type
31
32
  when :first then default_return = nil
@@ -88,15 +89,11 @@ module GBIP
88
89
  body.shift
89
90
  end
90
91
 
91
- titles_arr = [[]]
92
- body.each do |element|
93
- if element == "#" && titles_arr.last.size > 15
94
- titles_arr << []
95
- else
96
- titles_arr.last << element
97
- end
98
- #titles_arr << arr.split("\t")
99
- #titles_arr[-1] = titles_arr.last[1,titles_arr.last.size-1]
92
+ titles_arr = []
93
+ while body.size > 0
94
+ warehouse_count = body[21].to_i
95
+ extract_count = 22 + (5 * warehouse_count)
96
+ titles_arr << body.slice!(0, extract_count)
100
97
  end
101
98
 
102
99
  if titles_arr.size == 0
@@ -2,11 +2,10 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
2
2
 
3
3
  require 'gbip'
4
4
  require File.dirname(__FILE__) + "/spec_helper"
5
- require File.dirname(__FILE__) + "/timeout_tcpsocket"
6
5
 
7
6
  context "A new POS object" do
8
7
 
9
- setup do
8
+ before(:all) do
10
9
  @username = "user"
11
10
  @password = "pass"
12
11
  @isbn10 = "1741146712"
@@ -230,6 +229,18 @@ context "A new POS object" do
230
229
  result.should be_empty
231
230
  end
232
231
 
232
+ specify "should return an Array with multiple items when a query returns multiple matches" do
233
+ # Mock TCPSocket to return a valid response with no matches
234
+ data = File.read(File.dirname(__FILE__) + "/responses/multiple_response.txt").strip
235
+ socket = TCPSocket.stub_instance(:print => true, :close => true, :gets => data)
236
+ TCPSocket.stub_method(:new => socket)
237
+
238
+ pos = GBIP::POS.new(@username, @password)
239
+ result = pos.find(:all, @isbn13)
240
+ result.should be_a_kind_of(Array)
241
+ result.size.should eql(3)
242
+ end
243
+
233
244
  specify "should return an empty array when any object is supplied as an ISBN when searching for :all" do
234
245
  pos = GBIP::POS.new(@username, @password)
235
246
  result = pos.find(:all, nil)
@@ -0,0 +1 @@
1
+ 3 rainbowbook 3 # 57073276 1 AUS Hallucinogens and Your Neurons:The Incredibly Disgusting Story 978-0-8239-3391-4 Library Binding Active Record Cefrey, Holly Rosen Publishing Group, Incorporated, The 032000 29.95 UNITED STATES 22896 $ DRUG ABUSE_JUVENILE LITERATURE JUVENILE NONFICTION / Health & Daily Living / Substance Abuse PERSONAL & SOCIAL ISSUES: DRUGS & ADDICTION (CHILDREN'S/YA) ING 1 Ingram Book Company, La Vergne, TN Available for order 0 06/10/2009# 51552044 1 USA Hallucinogens and Your Neurons:The Incredibly Disgusting Story 978-0-8239-3391-4 Library Binding Active Record Cefrey, Holly Rosen Publishing Group, Incorporated, The 012005 25.25 UNITED STATES 22896 $ DRUG ABUSE_JUVENILE LITERATURE JUVENILE NONFICTION / Health & Daily Living / Substance Abuse DRUG ABUSE PERSONAL & SOCIAL ISSUES: DRUGS & ADDICTION (CHILDREN'S/YA) ING 1 Ingram Book Company, La Vergne, TN Available for order 0 06/10/2009# 53231792 1 CAN Hallucinogens and Your Neurons:The Incredibly Disgusting Story 978-0-8239-3391-4 Library Binding Active Record Cefrey, Holly Rosen Publishing Group, Incorporated, The 2000 28.45 UNITED STATES 22896 $ DRUG ABUSE_JUVENILE LITERATURE JUVENILE NONFICTION / Health & Daily Living / Substance Abuse PERSONAL & SOCIAL ISSUES: DRUGS & ADDICTION (CHILDREN'S/YA) ING 1 Ingram Book Company, La Vergne, TN Available for order 0 06/10/2009
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gbip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
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-11-07 00:00:00 +11:00
12
+ date: 2009-06-11 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "1.0"
24
24
  version:
25
- description: gbip is a small library to interact with the globalbooksinprint.com API. The API is based on raw TCP sockets.
25
+ description: " gbip is a small library to interact with the\n globalbooksinprint.com API. The API is based\n on raw TCP sockets.\n"
26
26
  email: jimmy@deefa.com
27
27
  executables: []
28
28
 
@@ -36,12 +36,10 @@ extra_rdoc_files:
36
36
  files:
37
37
  - examples/gbip.rb
38
38
  - lib/gbip.rb
39
- - lib/gbip
40
39
  - lib/gbip/pos.rb
41
40
  - lib/gbip/title.rb
42
41
  - lib/gbip/warehouse.rb
43
42
  - specs/pos_class_spec.rb
44
- - specs/responses
45
43
  - specs/responses/invalid_login.txt
46
44
  - specs/responses/no_result.txt
47
45
  - specs/responses/no_warehouses.txt
@@ -51,6 +49,7 @@ files:
51
49
  - specs/responses/invalid_bad_data.txt
52
50
  - specs/responses/invalid_request.txt
53
51
  - specs/responses/invalid_system_unavailable.txt
52
+ - specs/responses/multiple_response.txt
54
53
  - specs/spec_helper.rb
55
54
  - Rakefile
56
55
  - CHANGELOG
@@ -59,6 +58,8 @@ files:
59
58
  - LICENSE
60
59
  has_rdoc: true
61
60
  homepage: http://rbook.rubyforge.org/
61
+ licenses: []
62
+
62
63
  post_install_message:
63
64
  rdoc_options:
64
65
  - --title
@@ -83,9 +84,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
84
  requirements: []
84
85
 
85
86
  rubyforge_project: rbook
86
- rubygems_version: 1.2.0
87
+ rubygems_version: 1.3.3
87
88
  signing_key:
88
- specification_version: 2
89
+ specification_version: 3
89
90
  summary: A library for access the globalbooksinprint.com API
90
91
  test_files:
91
92
  - specs/pos_class_spec.rb