rbook-pacstream 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/rbook/pacstream.rb +13 -9
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/rbook/pacstream.rb
CHANGED
@@ -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
|
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
|
22
|
-
#
|
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.
|
7
|
-
date: 2007-
|
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
|