apsis-on-steroids 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "apsis-on-steroids"
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kaspernj"]
12
- s.date = "2013-08-29"
12
+ s.date = "2013-10-14"
13
13
  s.description = "A Ruby API for the Apsis mail service. "
14
14
  s.email = "k@spernj.org"
15
15
  s.extra_rdoc_files = [
@@ -37,28 +37,41 @@ class ApsisOnSteroids::Subscriber < ApsisOnSteroids::SubBase
37
37
 
38
38
  # Update one or more details on the subscriber.
39
39
  def update(data)
40
- res = aos.req_json("v1/subscribers/queue", :post, :json => [data.merge(:Id => self.data(:id))])
41
- url = URI.parse(res["Result"]["PollURL"])
42
- data = nil
43
-
44
- Timeout.timeout(300) do
45
- loop do
46
- sleep 1
47
- res = aos.req_json(url.path)
40
+ begin
41
+ res = aos.req_json("v1/subscribers/queue", :post, :json => [data.merge(:Id => self.data(:id))])
42
+ url = URI.parse(res["Result"]["PollURL"])
43
+ data = nil
44
+
45
+ Timeout.timeout(300) do
46
+ loop do
47
+ sleep 1
48
+ res = aos.req_json(url.path)
49
+
50
+ if res["State"] == "2"
51
+ url_data = URI.parse(res["DataUrl"])
52
+ data = aos.req_json(url_data.path)
53
+ break
54
+ elsif res["State"] == "0" || res["State"] == "1"
55
+ # Keep waiting.
56
+ else
57
+ raise "Unknown state '#{res["State"]}': #{res}"
58
+ end
59
+ end
60
+ end
61
+
62
+ if data["FailedUpdatedSubscribers"] && data["FailedUpdatedSubscribers"].any?
63
+ msg = raise data["FailedUpdatedSubscribers"].to_s
48
64
 
49
- if res["State"] == "2"
50
- url_data = URI.parse(res["DataUrl"])
51
- data = aos.req_json(url_data.path)
52
- break
53
- elsif res["State"] == "0" || res["State"] == "1"
54
- # Keep waiting.
65
+ if msg.include?("Timeout expired.")
66
+ raise Errno::EAGAIN, msg
55
67
  else
56
- raise "Unknown state '#{res["State"]}': #{res}"
68
+ raise msg
57
69
  end
58
70
  end
71
+ rescue Errno::EAGAIN
72
+ retry
59
73
  end
60
74
 
61
- raise data["FailedUpdatedSubscribers"].to_s if data["FailedUpdatedSubscribers"] && data["FailedUpdatedSubscribers"].any?
62
75
  @details = nil
63
76
  return nil
64
77
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: apsis-on-steroids
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.6
5
+ version: 0.0.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - kaspernj
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-29 00:00:00.000000000 Z
12
+ date: 2013-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  version_requirements: !ruby/object:Gem::Requirement
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  - !ruby/object:Gem::Version
146
146
  segments:
147
147
  - 0
148
- hash: -175250249640410280
148
+ hash: 3562323748187829359
149
149
  version: '0'
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  none: false