mailtruck 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,11 +14,17 @@ class Mailtruck::Receiver
14
14
 
15
15
  def wait(block)
16
16
  Timeout::timeout(Mailtruck.configuration.timeout) do
17
- EM.run {
18
- subscribe_to_addresses
17
+ Thread.new do
18
+ EM.run {
19
+ subscribe_to_addresses
19
20
 
20
- block.call
21
- }
21
+ block.call
22
+ }
23
+ end
24
+ end
25
+
26
+ while(missing_emails) do
27
+ sleep 0.1
22
28
  end
23
29
 
24
30
  @emails
@@ -29,9 +35,12 @@ class Mailtruck::Receiver
29
35
  private
30
36
 
31
37
  def subscribe_to_addresses
32
- client.subscribe("/bob") do |message|
33
- @emails << Mailtruck::Email.new(message)
34
- check_emails
38
+ @addresses.each do |address|
39
+ channel = "/" + address.prefix
40
+
41
+ client.subscribe(channel) do |message|
42
+ @emails << Mailtruck::Email.new(message)
43
+ end
35
44
  end
36
45
  end
37
46
 
@@ -39,10 +48,8 @@ class Mailtruck::Receiver
39
48
  @client ||= Faye::Client.new(Mailtruck.configuration.receiver_url)
40
49
  end
41
50
 
42
- def check_emails
43
- if @emails.size >= @addresses.size
44
- EM.stop_event_loop
45
- end
51
+ def missing_emails
52
+ @emails.size < @addresses.size
46
53
  end
47
54
 
48
55
  end
@@ -1,3 +1,3 @@
1
1
  module Mailtruck
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailtruck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-20 00:00:00.000000000 Z
12
+ date: 2013-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faye