efax 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -4,7 +4,6 @@ require 'rake/clean'
4
4
  require 'rake/gempackagetask'
5
5
  require 'rake/rdoctask'
6
6
  require 'rake/testtask'
7
- require 'spec/rake/spectask'
8
7
 
9
8
  begin
10
9
  require 'jeweler'
@@ -15,14 +14,17 @@ begin
15
14
  gem.email = "szimek@gmail.com"
16
15
  gem.homepage = "http://github.com/szimek/efax"
17
16
  gem.rubyforge_project = "efax"
18
-
17
+
19
18
  gem.add_dependency('hpricot', '>= 0.8.1')
19
+ gem.add_development_dependency('test-unit', '~> 2')
20
20
  gem.add_development_dependency('mocha', '>= 0.9')
21
21
  end
22
-
22
+
23
23
  Jeweler::RubyforgeTasks.new do |rubyforge|
24
24
  rubyforge.doc_task = "rdoc"
25
25
  end
26
+
27
+ Jeweler::GemcutterTasks.new
26
28
  rescue LoadError
27
29
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
28
30
  end
@@ -39,7 +41,3 @@ end
39
41
  Rake::TestTask.new do |t|
40
42
  t.test_files = FileList['test/**/*.rb']
41
43
  end
42
-
43
- Spec::Rake::SpecTask.new do |t|
44
- t.spec_files = FileList['spec/**/*.rb']
45
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.2
1
+ 1.3.3
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{efax}
8
- s.version = "1.3.2"
8
+ s.version = "1.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Szymon Nowak", "Pawel Kozlowski", "Dr Nic Williams"]
12
- s.date = %q{2009-10-09}
12
+ s.date = %q{2010-03-17}
13
13
  s.email = %q{szimek@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.rdoc"
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
  ".gitignore",
19
19
  "README.rdoc",
20
20
  "Rakefile",
21
- "TODO",
22
21
  "VERSION",
23
22
  "efax.gemspec",
24
23
  "lib/efax.rb",
@@ -33,7 +32,7 @@ Gem::Specification.new do |s|
33
32
  s.rdoc_options = ["--charset=UTF-8"]
34
33
  s.require_paths = ["lib"]
35
34
  s.rubyforge_project = %q{efax}
36
- s.rubygems_version = %q{1.3.5}
35
+ s.rubygems_version = %q{1.3.6}
37
36
  s.summary = %q{Ruby library for accessing the eFax Developer service}
38
37
  s.test_files = [
39
38
  "test/efax_inbound_test.rb",
@@ -47,13 +46,17 @@ Gem::Specification.new do |s|
47
46
 
48
47
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
48
  s.add_runtime_dependency(%q<hpricot>, [">= 0.8.1"])
49
+ s.add_development_dependency(%q<test-unit>, ["~> 2"])
50
50
  s.add_development_dependency(%q<mocha>, [">= 0.9"])
51
51
  else
52
52
  s.add_dependency(%q<hpricot>, [">= 0.8.1"])
53
+ s.add_dependency(%q<test-unit>, ["~> 2"])
53
54
  s.add_dependency(%q<mocha>, [">= 0.9"])
54
55
  end
55
56
  else
56
57
  s.add_dependency(%q<hpricot>, [">= 0.8.1"])
58
+ s.add_dependency(%q<test-unit>, ["~> 2"])
57
59
  s.add_dependency(%q<mocha>, [">= 0.9"])
58
60
  end
59
61
  end
62
+
@@ -17,7 +17,7 @@ end
17
17
 
18
18
  module EFax
19
19
  # URL of eFax web service
20
- Url = "https://secure.efaxdeveloper.com/EFax_WebFax.serv"
20
+ Url = "https://secure.efaxdeveloper.com/EFax_WebFax.serv"
21
21
  # URI of eFax web service
22
22
  Uri = URI.parse(Url)
23
23
  # Prefered content type
@@ -45,7 +45,7 @@ module EFax
45
45
  def self.account_id=(id)
46
46
  @@account_id = id
47
47
  end
48
-
48
+
49
49
  def self.params(content)
50
50
  escaped_xml = ::URI.escape(content, Regexp.new("[^#{::URI::PATTERN::UNRESERVED}]"))
51
51
  "id=#{account_id}&xml=#{escaped_xml}&respond=XML"
@@ -53,7 +53,7 @@ module EFax
53
53
 
54
54
  private_class_method :params
55
55
  end
56
-
56
+
57
57
  class OutboundRequest < Request
58
58
  def self.post(name, company, fax_number, subject, content, content_type = :html)
59
59
  xml_request = xml(name, company, fax_number, subject, content, content_type)
@@ -62,7 +62,7 @@ module EFax
62
62
  end
63
63
  OutboundResponse.new(response)
64
64
  end
65
-
65
+
66
66
  def self.xml(name, company, fax_number, subject, content, content_type = :html)
67
67
  xml_request = ""
68
68
  xml = Builder::XmlMarkup.new(:target => xml_request, :indent => 2 )
@@ -141,7 +141,7 @@ module EFax
141
141
  end
142
142
  OutboundStatusResponse.new(response)
143
143
  end
144
-
144
+
145
145
  def self.xml(doc_id)
146
146
  xml_request = ""
147
147
  xml = Builder::XmlMarkup.new(:target => xml_request, :indent => 2 )
@@ -182,7 +182,7 @@ module EFax
182
182
  @message = doc.at(:message).innerText
183
183
  @classification = doc.at(:classification).innerText.delete('"')
184
184
  @outcome = doc.at(:outcome).innerText.delete('"')
185
- if @classification.empty? && @outcome.empty?
185
+ if !sent_yet?(classification, outcome) || busy_signal?(classification)
186
186
  @status_code = QueryStatus::PENDING
187
187
  elsif @classification == "Success" && @outcome == "Success"
188
188
  @status_code = QueryStatus::SENT
@@ -194,5 +194,14 @@ module EFax
194
194
  @message = "HTTP request failed (#{response.code})"
195
195
  end
196
196
  end
197
+
198
+ def busy_signal?(classification)
199
+ classification == "Busy"
200
+ end
201
+
202
+ def sent_yet?(classification, outcome)
203
+ !classification.empty? || !outcome.empty?
204
+ end
205
+
197
206
  end
198
- end
207
+ end
@@ -10,10 +10,10 @@ module EFaxInboundTest
10
10
  EFax::InboundPostRequest.expects(:receive_by_xml).with(efax_inbound_post_xml).returns(response = mock)
11
11
  assert_equal(EFax::InboundPostRequest.receive_by_params({:xml => efax_inbound_post_xml}), response)
12
12
  end
13
-
13
+
14
14
  def test_receive_by_xml
15
15
  response = efax_inbound_post(:barcodes => %w[EFAXTEST1A EFAXTEST2A EFAXTEST3A EFAXTEST4A EFAXTEST5A])
16
-
16
+
17
17
  assert_equal efax_inbound_post_file_contents, response.encoded_file_contents
18
18
  assert_equal :pdf, response.file_type
19
19
  assert_equal '8587123600', response.sender_fax_number
@@ -31,7 +31,7 @@ module EFaxInboundTest
31
31
  assert_not_nil response.file
32
32
  assert_respond_to response.file, :read
33
33
  assert_equal response.file_contents, response.file.read
34
-
34
+
35
35
  # According to docs these will always be "Pacific Time Zone" (sometimes -8, sometimes -7 -- using -8)
36
36
  assert_equal Time.utc(2005,8,18,20,2,13), response.date_received
37
37
  assert_equal Time.utc(2005,8,18,20,2,25), response.request_date
@@ -60,7 +60,7 @@ module EFaxOutboundTest
60
60
  XML
61
61
  http_response = mock()
62
62
  http_response.expects(:is_a?).with(Net::HTTPOK).returns(true)
63
- http_response.expects(:body).returns(xml)
63
+ http_response.expects(:body).returns(xml)
64
64
  response = EFax::OutboundResponse.new(http_response)
65
65
  assert_equal EFax::RequestStatus::FAILURE, response.status_code
66
66
  assert_nil response.doc_id
@@ -88,7 +88,7 @@ module EFaxOutboundTest
88
88
  XML
89
89
  http_response = mock()
90
90
  http_response.expects(:is_a?).with(Net::HTTPOK).returns(true)
91
- http_response.expects(:body).returns(xml)
91
+ http_response.expects(:body).returns(xml)
92
92
  response = EFax::OutboundResponse.new(http_response)
93
93
  assert_equal EFax::RequestStatus::FAILURE, response.status_code
94
94
  assert_nil response.doc_id
@@ -151,7 +151,7 @@ module EFaxOutboundTest
151
151
  XML
152
152
  http_response = mock()
153
153
  http_response.expects(:is_a?).with(Net::HTTPOK).returns(true)
154
- http_response.expects(:body).returns(xml)
154
+ http_response.expects(:body).returns(xml)
155
155
  response = EFax::OutboundStatusResponse.new(http_response)
156
156
  assert_equal "Your transmission has completed.", response.message
157
157
  assert_equal "Success", response.outcome
@@ -159,6 +159,58 @@ module EFaxOutboundTest
159
159
  assert_equal EFax::QueryStatus::SENT, response.status_code
160
160
  end
161
161
 
162
+ def test_busy_response
163
+ xml = <<-XML
164
+ <?xml version="1.0"?>
165
+ <OutboundStatusResponse>
166
+ <Transmission>
167
+ <TransmissionControl>
168
+ <TransmissionID></TransmissionID>
169
+ </TransmissionControl>
170
+ <Recipients>
171
+ <Recipient>
172
+ <DOCID>12345678</DOCID>
173
+ <Name>Mike Rotch</Name>
174
+ <Company>Moe's</Company>
175
+ <Fax>12345678901</Fax>
176
+ <Status>
177
+ <Message>Your transmission is waiting to be sent.</Message>
178
+ <Classification>Busy</Classification>
179
+ <Outcome>Normal busy: remote end busy (off hook)</Outcome>
180
+ </Status>
181
+ <LastAttempt>
182
+ <LastDate></LastDate>
183
+ <LastTime></LastTime>
184
+ </LastAttempt>
185
+ <NextAttempt>
186
+ <NextDate></NextDate>
187
+ <NextTime></NextTime>
188
+ </NextAttempt>
189
+ <Pages>
190
+ <Scheduled>1</Scheduled>
191
+ <Sent>1</Sent>
192
+ </Pages>
193
+ <BaudRate>14400</BaudRate>
194
+ <Duration>0.4</Duration>
195
+ <Retries>1</Retries>
196
+ <RemoteCSID>"-"</RemoteCSID>
197
+ </Recipient>
198
+ </Recipients>
199
+ </Transmission>
200
+ </OutboundStatusResponse>
201
+ XML
202
+
203
+ http_response = mock()
204
+ http_response.expects(:is_a?).with(Net::HTTPOK).returns(true)
205
+ http_response.expects(:body).returns(xml)
206
+ response = EFax::OutboundStatusResponse.new(http_response)
207
+
208
+ assert_equal "Normal busy: remote end busy (off hook)", response.outcome
209
+ assert_equal "Busy", response.classification
210
+ assert_equal "Your transmission is waiting to be sent.", response.message
211
+ assert_equal EFax::QueryStatus::PENDING, response.status_code
212
+ end
213
+
162
214
  def test_pending_response
163
215
  xml = <<-XML
164
216
  <?xml version="1.0"?>
@@ -202,9 +254,9 @@ module EFaxOutboundTest
202
254
 
203
255
  http_response = mock()
204
256
  http_response.expects(:is_a?).with(Net::HTTPOK).returns(true)
205
- http_response.expects(:body).returns(xml)
257
+ http_response.expects(:body).returns(xml)
206
258
  response = EFax::OutboundStatusResponse.new(http_response)
207
-
259
+
208
260
  assert_equal "", response.outcome
209
261
  assert_equal "", response.classification
210
262
  assert_equal EFax::QueryStatus::PENDING, response.status_code
@@ -253,9 +305,9 @@ module EFaxOutboundTest
253
305
 
254
306
  http_response = mock()
255
307
  http_response.expects(:is_a?).with(Net::HTTPOK).returns(true)
256
- http_response.expects(:body).returns(xml)
308
+ http_response.expects(:body).returns(xml)
257
309
  response = EFax::OutboundStatusResponse.new(http_response)
258
-
310
+
259
311
  assert_equal "Your fax caused the world to end", response.message
260
312
  assert_equal "End of days", response.outcome
261
313
  assert_equal "Apocalyptic failure", response.classification
@@ -329,30 +381,4 @@ module EFaxOutboundTest
329
381
  end
330
382
  end
331
383
  end
332
-
333
- class OutboundStatusTest < Test::Unit::TestCase
334
- def test_generate_xml
335
- expected_xml = <<-XML
336
- <?xml version="1.0" encoding="UTF-8"?>
337
- <OutboundStatus>
338
- <AccessControl>
339
- <UserName>Mike Rotch</UserName>
340
- <Password>moes</Password>
341
- </AccessControl>
342
- <Transmission>
343
- <TransmissionControl>
344
- <DOCID>123456</DOCID>
345
- </TransmissionControl>
346
- </Transmission>
347
- </OutboundStatus>
348
- XML
349
-
350
- EFax::Request.user = "Mike Rotch"
351
- EFax::Request.password = "moes"
352
- EFax::OutboundStatus.publicize_class_methods do
353
- assert_equal expected_xml.delete(" "), EFax::OutboundStatus.xml("123456").delete(" ")
354
- end
355
- end
356
- end
357
-
358
384
  end
@@ -1,5 +1,6 @@
1
- require 'test/unit'
2
1
  require 'rubygems'
2
+ gem 'test-unit', '~> 2'
3
+ require 'test/unit'
3
4
  require 'mocha'
4
5
 
5
6
  class Class
@@ -16,4 +17,4 @@ class Class
16
17
  yield
17
18
  self.class_eval { private_class_method(*saved_private_class_methods) }
18
19
  end
19
- end
20
+ end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: efax
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 3
8
+ - 3
9
+ version: 1.3.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Szymon Nowak
@@ -11,29 +16,48 @@ autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
18
 
14
- date: 2009-10-09 00:00:00 +10:00
19
+ date: 2010-03-17 00:00:00 +01:00
15
20
  default_executable:
16
21
  dependencies:
17
22
  - !ruby/object:Gem::Dependency
18
23
  name: hpricot
19
- type: :runtime
20
- version_requirement:
21
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
22
26
  requirements:
23
27
  - - ">="
24
28
  - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ - 8
32
+ - 1
25
33
  version: 0.8.1
26
- version:
34
+ type: :runtime
35
+ version_requirements: *id001
27
36
  - !ruby/object:Gem::Dependency
28
- name: mocha
37
+ name: test-unit
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ version: "2"
29
46
  type: :development
30
- version_requirement:
31
- version_requirements: !ruby/object:Gem::Requirement
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: mocha
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
32
52
  requirements:
33
53
  - - ">="
34
54
  - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 9
35
58
  version: "0.9"
36
- version:
59
+ type: :development
60
+ version_requirements: *id003
37
61
  description:
38
62
  email: szimek@gmail.com
39
63
  executables: []
@@ -46,7 +70,6 @@ files:
46
70
  - .gitignore
47
71
  - README.rdoc
48
72
  - Rakefile
49
- - TODO
50
73
  - VERSION
51
74
  - efax.gemspec
52
75
  - lib/efax.rb
@@ -69,18 +92,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
92
  requirements:
70
93
  - - ">="
71
94
  - !ruby/object:Gem::Version
95
+ segments:
96
+ - 0
72
97
  version: "0"
73
- version:
74
98
  required_rubygems_version: !ruby/object:Gem::Requirement
75
99
  requirements:
76
100
  - - ">="
77
101
  - !ruby/object:Gem::Version
102
+ segments:
103
+ - 0
78
104
  version: "0"
79
- version:
80
105
  requirements: []
81
106
 
82
107
  rubyforge_project: efax
83
- rubygems_version: 1.3.5
108
+ rubygems_version: 1.3.6
84
109
  signing_key:
85
110
  specification_version: 3
86
111
  summary: Ruby library for accessing the eFax Developer service
data/TODO DELETED
@@ -1,2 +0,0 @@
1
- - provide simpler interface like EFax#send_request and EFax#query_status
2
- - raise exception if account info or credentials are not set