mailtruck 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -28,7 +28,7 @@ Or install it yourself with:
28
28
  ### Quick Start
29
29
 
30
30
  ```ruby
31
- mailtruck = Mailtruck.new
31
+ mailtruck = Mailtruck.start
32
32
 
33
33
  # an email address where Mailtruck can pick up your email
34
34
  address = mailtruck.email_address
@@ -66,7 +66,7 @@ When multiple emails are being sent, ask for the number of emails needed and
66
66
  it will wait for that number of emails.
67
67
 
68
68
  ```ruby
69
- mailtruck = Mailtruck.new
69
+ mailtruck = Mailtruck.start
70
70
 
71
71
  addresses = [mailtruck.email_address, mailtruck.email_address]
72
72
 
data/lib/mailtruck.rb CHANGED
@@ -1,13 +1,7 @@
1
1
  require "securerandom"
2
2
  require "faye"
3
3
 
4
- require "mailtruck/configuration"
5
- require "mailtruck/email"
6
- require "mailtruck/email_address"
7
- require "mailtruck/receiver"
8
- require "mailtruck/version"
9
-
10
- class Mailtruck
4
+ module Mailtruck
11
5
 
12
6
  class Timeout < StandardError; end
13
7
 
@@ -32,37 +26,16 @@ class Mailtruck
32
26
  @configuration ||= Configuration.new
33
27
  end
34
28
 
35
- # Generates an email address that Mailtruck can receive email at.
36
- #
37
- # @example
38
- # mailtruck = Mailtruck.new
39
- # address = mailtruck.email_address
40
- #
41
- # emails = mailtruck.wait_for_emails do
42
- # MyApp.send_email_to(address)
43
- # end
44
- #
45
- #
46
- # @yield Block to run that should trigger emails
47
- # @return [String] an email address
48
- def email_address
49
- address = EmailAddress.random
50
- addresses << address
51
-
52
- address.to_s
53
- end
54
-
55
- # Waits for emails to be sent to #email_address and returns them.
56
- #
57
- # @return [Array<Mailtruck::Email>] the received emails
58
- def wait_for_emails(&block)
59
- Receiver.wait_for(addresses, block)
60
- end
61
-
62
- private
63
-
64
- def addresses
65
- @addresses ||= []
29
+ # @return [Mailtruck::Truck] a mailtruck instance
30
+ def self.start
31
+ Mailtruck::Truck.new
66
32
  end
67
33
 
68
34
  end
35
+
36
+ require "mailtruck/configuration"
37
+ require "mailtruck/email"
38
+ require "mailtruck/email_address"
39
+ require "mailtruck/receiver"
40
+ require "mailtruck/truck"
41
+ require "mailtruck/version"
@@ -17,7 +17,6 @@ class Mailtruck::EmailAddress
17
17
  private
18
18
 
19
19
  def self.random_string
20
- # SecureRandom.urlsafe_base64
21
- "bob"
20
+ SecureRandom.urlsafe_base64
22
21
  end
23
22
  end
@@ -0,0 +1,36 @@
1
+ class Mailtruck::Truck
2
+
3
+ # Generates an email address that Mailtruck can receive email at.
4
+ #
5
+ # @example
6
+ # mailtruck = Mailtruck.start
7
+ # address = mailtruck.email_address
8
+ #
9
+ # emails = mailtruck.wait_for_emails do
10
+ # MyApp.send_email_to(address)
11
+ # end
12
+ #
13
+ #
14
+ # @yield Block to run that should trigger emails
15
+ # @return [String] an email address
16
+ def email_address
17
+ address = Mailtruck::EmailAddress.random
18
+ addresses << address
19
+
20
+ address.to_s
21
+ end
22
+
23
+ # Waits for emails to be sent to #email_address and returns them.
24
+ #
25
+ # @return [Array<Mailtruck::Email>] the received emails
26
+ def wait_for_emails(&block)
27
+ Mailtruck::Receiver.wait_for(addresses, block)
28
+ end
29
+
30
+ private
31
+
32
+ def addresses
33
+ @addresses ||= []
34
+ end
35
+
36
+ end
@@ -1,3 +1,3 @@
1
- class Mailtruck
2
- VERSION = "0.0.1"
1
+ module Mailtruck
2
+ VERSION = "0.1.0"
3
3
  end
@@ -2,7 +2,7 @@ require_relative '../spec_helper'
2
2
 
3
3
  describe Mailtruck do
4
4
 
5
- let(:mailtruck) { Mailtruck.new }
5
+ let(:mailtruck) { Mailtruck.start }
6
6
 
7
7
  before(:each) do
8
8
  Mailtruck.configure do |config|
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.0.1
4
+ version: 0.1.0
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-06-27 00:00:00.000000000 Z
12
+ date: 2013-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faye
@@ -94,6 +94,7 @@ files:
94
94
  - lib/mailtruck/email.rb
95
95
  - lib/mailtruck/email_address.rb
96
96
  - lib/mailtruck/receiver.rb
97
+ - lib/mailtruck/truck.rb
97
98
  - lib/mailtruck/version.rb
98
99
  - mailtruck.gemspec
99
100
  - spec/lib/mailtruck_spec.rb
@@ -111,18 +112,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
112
  - - ! '>='
112
113
  - !ruby/object:Gem::Version
113
114
  version: '0'
114
- segments:
115
- - 0
116
- hash: 3253366713766564001
117
115
  required_rubygems_version: !ruby/object:Gem::Requirement
118
116
  none: false
119
117
  requirements:
120
118
  - - ! '>='
121
119
  - !ruby/object:Gem::Version
122
120
  version: '0'
123
- segments:
124
- - 0
125
- hash: 3253366713766564001
126
121
  requirements: []
127
122
  rubyforge_project:
128
123
  rubygems_version: 1.8.25