rbook-pacstream 0.5 → 0.6

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.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/lib/rbook/pacstream.rb +13 -9
  3. metadata +2 -2
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.5"
9
+ PKG_VERSION = "0.6"
10
10
  PKG_NAME = "rbook-pacstream"
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
  RUBYFORGE_PROJECT = 'rbook'
@@ -6,7 +6,7 @@ require 'tempfile'
6
6
  module RBook
7
7
 
8
8
  # Ruby class for sending and retrieving electronic orders
9
- # via pacstream, a service run by the ECN GRoup
9
+ # via pacstream, a service run by the ECN Group
10
10
  # (http://www.ecngroup.com.au/)
11
11
  #
12
12
  # = Basic Usage
@@ -16,10 +16,16 @@ module RBook
16
16
  # end
17
17
  class Pacstream
18
18
 
19
- FILE_EXTENSIONS = { :orders => "ORD" }
19
+ FILE_EXTENSIONS = { :orders => "ORD", :invoices => "ASN", :poacks => "POA" }
20
20
 
21
- # Iterate over each order waiting on the pacstream server, returning
22
- # each file as a string
21
+ # Iterate over each document waiting on the pacstream server, returning
22
+ # it as a string
23
+ #
24
+ # Document types available:
25
+ #
26
+ # Purchase Orders (:orders)
27
+ # Purchase Order Acknowledgements (:poacks)
28
+ # Invoices (:invoices)
23
29
  #
24
30
  # RBook::Pacstream.get(:orders, :username => "myusername", :password => "mypass") do |order|
25
31
  # puts order
@@ -29,9 +35,7 @@ module RBook
29
35
  raise ArgumentError, 'username and password must be specified'
30
36
  end
31
37
 
32
- unless FILE_EXTENSIONS.include?(type)
33
- raise ArgumentError, 'unrecognised type'
34
- end
38
+ raise ArgumentError, 'unrecognised type' unless FILE_EXTENSIONS.include?(type.to_sym)
35
39
 
36
40
  server = args[0][:servername] || "pacstream.tedis.com.au"
37
41
 
@@ -39,7 +43,7 @@ module RBook
39
43
  transaction_complete = false
40
44
  Net::FTP.open(server) do |ftp|
41
45
 
42
- file_regexp = Regexp.new(".*\.#{FILE_EXTENSIONS[type]}$", Regexp::IGNORECASE)
46
+ file_regexp = Regexp.new(".*\.#{FILE_EXTENSIONS[type.to_sym]}$", Regexp::IGNORECASE)
43
47
  ftp.login(args[0][:username].to_s, args[0][:password].to_s)
44
48
  ftp.chdir("outgoing/")
45
49
  ftp.nlst.each do |file|
@@ -48,6 +52,7 @@ module RBook
48
52
  tempfile.close
49
53
  ftp.getbinaryfile(file, tempfile.path)
50
54
  yield File.read(tempfile.path)
55
+ tempfile.unlink
51
56
  end
52
57
  end
53
58
  transaction_complete = true
@@ -59,6 +64,5 @@ module RBook
59
64
  raise "Error while communicating with the pacstream server"
60
65
  end
61
66
  end
62
-
63
67
  end
64
68
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: rbook-pacstream
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.5"
7
- date: 2007-07-03 00:00:00 +10:00
6
+ version: "0.6"
7
+ date: 2007-10-10 00:00:00 +10:00
8
8
  summary: A library for interaction with the PACSTREAM service
9
9
  require_paths:
10
10
  - lib