email_vision 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/email_vision.gemspec +1 -1
- data/lib/email_vision.rb +18 -0
- data/spec/email_vision_spec.rb +1 -7
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/email_vision.gemspec
CHANGED
data/lib/email_vision.rb
CHANGED
@@ -5,6 +5,10 @@ class EmailVision
|
|
5
5
|
SESSION_TIMEOUT = 10*60
|
6
6
|
VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
|
7
7
|
attr_accessor :options
|
8
|
+
JOB_STATUS = {
|
9
|
+
:finished => 'Job_Done_Or_Does_Not_Exist',
|
10
|
+
:error => 'Error'
|
11
|
+
}
|
8
12
|
|
9
13
|
def initialize(options)
|
10
14
|
self.options = options
|
@@ -42,6 +46,20 @@ class EmailVision
|
|
42
46
|
execute(:get_member_job_status, :synchro_id => job_id)[:status]
|
43
47
|
end
|
44
48
|
|
49
|
+
def wait_for_job_to_finish(job_id, options={})
|
50
|
+
interval = options[:interval] || 5
|
51
|
+
times = options[:times] || 20
|
52
|
+
|
53
|
+
times.times do
|
54
|
+
current_status = job_status(job_id)
|
55
|
+
raise "Job failed" if current_status == JOB_STATUS[:error]
|
56
|
+
return true if current_status == JOB_STATUS[:finished]
|
57
|
+
sleep interval
|
58
|
+
end
|
59
|
+
|
60
|
+
raise "Job not finished in time! #{current_status}"
|
61
|
+
end
|
62
|
+
|
45
63
|
def columns
|
46
64
|
result = execute(:desc_member_table)
|
47
65
|
result = convert_to_hash(result[:fields], :name, :type)
|
data/spec/email_vision_spec.rb
CHANGED
@@ -9,13 +9,7 @@ describe "EmailVision" do
|
|
9
9
|
|
10
10
|
# updates need some time to finish on the server...
|
11
11
|
def wait_for_job_to_finish
|
12
|
-
|
13
|
-
20.times do
|
14
|
-
sleep 5
|
15
|
-
puts status = client.job_status(job_id)
|
16
|
-
return if status == 'Job_Done_Or_Does_Not_Exist'
|
17
|
-
end
|
18
|
-
raise "Job not finished in time!"
|
12
|
+
client.wait_for_job_to_finish yield
|
19
13
|
end
|
20
14
|
|
21
15
|
def reset_email
|