messenger 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/lib/messenger/email.rb +8 -7
- data/test/test_email.rb +13 -3
- metadata +12 -22
data/VERSION.yml
CHANGED
data/lib/messenger/email.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'mail'
|
2
2
|
|
3
3
|
module Messenger
|
4
4
|
|
@@ -11,12 +11,13 @@ module Messenger
|
|
11
11
|
# :email_from => Who the email is from
|
12
12
|
# :email_subject => The subject of the email
|
13
13
|
def self.send(url, message, options={})
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
mail = Mail.new do
|
15
|
+
from options[:email_from]
|
16
|
+
to url.sub(/mailto:/, '')
|
17
|
+
subject options[:email_subject]
|
18
|
+
body message
|
19
|
+
end
|
20
|
+
mail.deliver!
|
20
21
|
[true, nil]
|
21
22
|
end
|
22
23
|
|
data/test/test_email.rb
CHANGED
@@ -1,14 +1,24 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/test_helper"
|
2
|
-
require '
|
2
|
+
require 'mail'
|
3
3
|
|
4
4
|
module Messenger
|
5
5
|
|
6
6
|
class EmailTest < Test::Unit::TestCase
|
7
7
|
|
8
8
|
context "Email notification" do
|
9
|
+
setup do
|
10
|
+
Mail.defaults do
|
11
|
+
delivery_method :test
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
9
15
|
should "send an email" do
|
10
|
-
|
11
|
-
|
16
|
+
Email.send("mailto:to_test@example.com", "Test message", :email_from => "from_test@example.com", :email_subject => "Test")
|
17
|
+
assert_equal 1, Mail::TestMailer.deliveries.length
|
18
|
+
assert_equal ["to_test@example.com"], Mail::TestMailer.deliveries.first.to
|
19
|
+
assert_equal ["from_test@example.com"], Mail::TestMailer.deliveries.first.from
|
20
|
+
assert_equal "Test", Mail::TestMailer.deliveries.first.subject
|
21
|
+
assert_equal "Test message", Mail::TestMailer.deliveries.first.body.to_s
|
12
22
|
end
|
13
23
|
end
|
14
24
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: messenger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Arbini
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-08 00:00:00 -08:00
|
13
13
|
default_executable: messenger
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,26 +22,6 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "1.15"
|
24
24
|
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: pony
|
27
|
-
type: :runtime
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: "0.6"
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: tmail
|
37
|
-
type: :runtime
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 1.2.6
|
44
|
-
version:
|
45
25
|
- !ruby/object:Gem::Dependency
|
46
26
|
name: mime-types
|
47
27
|
type: :runtime
|
@@ -102,6 +82,16 @@ dependencies:
|
|
102
82
|
- !ruby/object:Gem::Version
|
103
83
|
version: 1.2.0
|
104
84
|
version:
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: mail
|
87
|
+
type: :runtime
|
88
|
+
version_requirement:
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.1.2
|
94
|
+
version:
|
105
95
|
description: "Messenger: easy message sending"
|
106
96
|
email: brandon@zencoder.tv
|
107
97
|
executables:
|