pling-actionmailer 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/pling/action_mailer.rb +6 -0
- data/lib/pling/action_mailer/gateway.rb +31 -0
- data/lib/pling/action_mailer/mailer.rb +18 -0
- data/pling-actionmailer.gemspec +1 -1
- data/spec/pling/{gateway/action_mailer_spec.rb → action_mailer/gateway_spec.rb} +10 -10
- data/spec/pling/{gateway/action_mailer → action_mailer}/mailer_spec.rb +7 -3
- data/spec/spec_helper.rb +2 -1
- metadata +19 -17
- data/lib/pling/gateway/action_mailer.rb +0 -42
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'pling'
|
2
|
+
require 'action_mailer'
|
3
|
+
|
4
|
+
module Pling
|
5
|
+
module ActionMailer
|
6
|
+
class Gateway < Pling::Gateway
|
7
|
+
|
8
|
+
handles :email, :mail, :actionmailer
|
9
|
+
|
10
|
+
def initialize(configuration)
|
11
|
+
super
|
12
|
+
require_configuration([:from])
|
13
|
+
end
|
14
|
+
|
15
|
+
def deliver!(message, device)
|
16
|
+
mailer = configuration[:mailer] || Pling::ActionMailer::Mailer
|
17
|
+
mailer.pling_message(message, device, configuration).deliver
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def default_configuration
|
23
|
+
super.merge({
|
24
|
+
:html => true,
|
25
|
+
:text => true
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'action_mailer'
|
2
|
+
|
3
|
+
module Pling
|
4
|
+
module ActionMailer
|
5
|
+
class Mailer < ::ActionMailer::Base
|
6
|
+
append_view_path File.expand_path('../../../../app/views', __FILE__)
|
7
|
+
|
8
|
+
def pling_message(message, device, configuration)
|
9
|
+
@message, @device, @configuration = message, device, configuration
|
10
|
+
|
11
|
+
mail(:to => device.identifier, :from => configuration[:from], :subject => message.subject) do |format|
|
12
|
+
format.text { render 'pling/mailer/pling_message' } if configuration[:text]
|
13
|
+
format.html { render 'pling/mailer/pling_message' } if configuration[:html]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/pling-actionmailer.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "pling-actionmailer"
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.3.0"
|
6
6
|
s.authors = ["benedikt", "t6d", "fabrik42"]
|
7
7
|
s.email = ["benedikt@synatic.net", "me@t6d.de", "fabrik42@gmail.com"]
|
8
8
|
s.homepage = "http://flinc.github.com/pling-actionmailer"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Pling::Gateway
|
3
|
+
describe Pling::ActionMailer::Gateway do
|
4
4
|
|
5
5
|
let(:valid_configuration) do
|
6
6
|
{ :from => 'random@example.com' }
|
@@ -12,11 +12,11 @@ describe Pling::Gateway::ActionMailer do
|
|
12
12
|
let(:mail) { mock(:deliver => true) }
|
13
13
|
|
14
14
|
before do
|
15
|
-
Pling::
|
15
|
+
Pling::ActionMailer::Mailer.stub(:pling_message => mail)
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should handle various action mailer related device types' do
|
19
|
-
Pling::Gateway
|
19
|
+
Pling::ActionMailer::Gateway.handled_types.should =~ [:mail, :email, :actionmailer]
|
20
20
|
end
|
21
21
|
|
22
22
|
context 'when created with an invalid configuration' do
|
@@ -24,7 +24,7 @@ describe Pling::Gateway::ActionMailer do
|
|
24
24
|
it "should raise an error when :#{attribute} is missing" do
|
25
25
|
configuration = valid_configuration
|
26
26
|
configuration.delete(attribute)
|
27
|
-
expect { Pling::Gateway
|
27
|
+
expect { Pling::ActionMailer::Gateway.new(configuration) }.to raise_error(ArgumentError, /:#{attribute} is missing/)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -32,9 +32,9 @@ describe Pling::Gateway::ActionMailer do
|
|
32
32
|
context 'when created with a valid configuration' do
|
33
33
|
it 'should pass the full configuration to the mailer' do
|
34
34
|
configuration = valid_configuration.merge({ :something => true })
|
35
|
-
gateway = Pling::Gateway
|
35
|
+
gateway = Pling::ActionMailer::Gateway.new(configuration)
|
36
36
|
|
37
|
-
Pling::
|
37
|
+
Pling::ActionMailer::Mailer.
|
38
38
|
should_receive(:pling_message).
|
39
39
|
with(anything, anything, hash_including(configuration)).and_return(mail)
|
40
40
|
|
@@ -47,21 +47,21 @@ describe Pling::Gateway::ActionMailer do
|
|
47
47
|
with(message, device, hash_including(valid_configuration)).
|
48
48
|
and_return(mail)
|
49
49
|
|
50
|
-
gateway = Pling::Gateway
|
50
|
+
gateway = Pling::ActionMailer::Gateway.new(valid_configuration.merge(:mailer => mailer))
|
51
51
|
|
52
52
|
gateway.deliver(message, device)
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should not change the configuration' do
|
56
56
|
configuration = valid_configuration.merge(:html => true, :text => false)
|
57
|
-
gateway = Pling::Gateway
|
57
|
+
gateway = Pling::ActionMailer::Gateway.new(configuration)
|
58
58
|
|
59
59
|
expect { gateway.deliver(message, device) }.to_not change(configuration, :count)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
describe '#deliver' do
|
64
|
-
subject { Pling::Gateway
|
64
|
+
subject { Pling::ActionMailer::Gateway.new(valid_configuration) }
|
65
65
|
|
66
66
|
it 'should raise an error if no message is given' do
|
67
67
|
expect { subject.deliver(nil, device) }.to raise_error
|
@@ -82,7 +82,7 @@ describe Pling::Gateway::ActionMailer do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'should try to deliver the given message' do
|
85
|
-
Pling::
|
85
|
+
Pling::ActionMailer::Mailer.
|
86
86
|
should_receive(:pling_message).
|
87
87
|
with(message, device, hash_including(valid_configuration)).
|
88
88
|
and_return(mail)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Pling::
|
3
|
+
describe Pling::ActionMailer::Mailer do
|
4
4
|
subject { described_class }
|
5
5
|
|
6
|
-
let(:message) { Pling::Message.new('Hello from Pling') }
|
6
|
+
let(:message) { Pling::Message.new(:body => 'Hello from Pling', :subject => 'Subject') }
|
7
7
|
let(:device) { Pling::Device.new(:identifier => 'DEVICEIDENTIFIER', :type => :email) }
|
8
8
|
let(:mail) { described_class.pling_message(message, device, configuration) }
|
9
9
|
let(:configuration) do
|
@@ -14,7 +14,7 @@ describe Pling::Gateway::ActionMailer::Mailer do
|
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
|
-
specify { described_class.ancestors =~ ActionMailer::Base }
|
17
|
+
specify { described_class.ancestors =~ ::ActionMailer::Base }
|
18
18
|
|
19
19
|
describe '.pling_message' do
|
20
20
|
|
@@ -49,6 +49,10 @@ describe Pling::Gateway::ActionMailer::Mailer do
|
|
49
49
|
mail.to.should include('DEVICEIDENTIFIER')
|
50
50
|
end
|
51
51
|
|
52
|
+
it 'should use message.subject as subject' do
|
53
|
+
mail.subject.should include('Subject')
|
54
|
+
end
|
55
|
+
|
52
56
|
it 'should use sender from the configuration' do
|
53
57
|
mail.from.should include('random@example.com')
|
54
58
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pling-actionmailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2011-
|
14
|
+
date: 2011-11-11 00:00:00.000000000Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: pling
|
18
|
-
requirement: &
|
18
|
+
requirement: &70155430875740 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: '0.1'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *70155430875740
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionmailer
|
29
|
-
requirement: &
|
29
|
+
requirement: &70155430874580 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: '3.0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *70155430874580
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rspec
|
40
|
-
requirement: &
|
40
|
+
requirement: &70155430873600 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: '2.7'
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *70155430873600
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: yard
|
51
|
-
requirement: &
|
51
|
+
requirement: &70155430872680 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: '0.7'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *70155430872680
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rake
|
62
|
-
requirement: &
|
62
|
+
requirement: &70155430871840 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
version: '0.9'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *70155430871840
|
71
71
|
description: Pling Gateway to ActionMailer
|
72
72
|
email:
|
73
73
|
- benedikt@synatic.net
|
@@ -86,10 +86,12 @@ files:
|
|
86
86
|
- Rakefile
|
87
87
|
- app/views/pling/mailer/pling_message.html.erb
|
88
88
|
- app/views/pling/mailer/pling_message.text.erb
|
89
|
-
- lib/pling/
|
89
|
+
- lib/pling/action_mailer.rb
|
90
|
+
- lib/pling/action_mailer/gateway.rb
|
91
|
+
- lib/pling/action_mailer/mailer.rb
|
90
92
|
- pling-actionmailer.gemspec
|
91
|
-
- spec/pling/
|
92
|
-
- spec/pling/
|
93
|
+
- spec/pling/action_mailer/gateway_spec.rb
|
94
|
+
- spec/pling/action_mailer/mailer_spec.rb
|
93
95
|
- spec/spec_helper.rb
|
94
96
|
homepage: http://flinc.github.com/pling-actionmailer
|
95
97
|
licenses: []
|
@@ -116,7 +118,7 @@ signing_key:
|
|
116
118
|
specification_version: 3
|
117
119
|
summary: Pling Gateway to ActionMailer
|
118
120
|
test_files:
|
119
|
-
- spec/pling/
|
120
|
-
- spec/pling/
|
121
|
+
- spec/pling/action_mailer/gateway_spec.rb
|
122
|
+
- spec/pling/action_mailer/mailer_spec.rb
|
121
123
|
- spec/spec_helper.rb
|
122
124
|
has_rdoc:
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'pling'
|
2
|
-
require 'action_mailer'
|
3
|
-
|
4
|
-
module Pling
|
5
|
-
module Gateway
|
6
|
-
class ActionMailer < Base
|
7
|
-
class Mailer < ::ActionMailer::Base
|
8
|
-
append_view_path File.expand_path('../../../../app/views', __FILE__)
|
9
|
-
|
10
|
-
def pling_message(message, device, configuration)
|
11
|
-
@message, @device, @configuration = message, device, configuration
|
12
|
-
|
13
|
-
mail(:to => device.identifier, :from => configuration[:from]) do |format|
|
14
|
-
format.text { render 'pling/mailer/pling_message' } if configuration[:text]
|
15
|
-
format.html { render 'pling/mailer/pling_message' } if configuration[:html]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
handles :email, :mail, :actionmailer
|
21
|
-
|
22
|
-
def initialize(configuration)
|
23
|
-
setup_configuration(configuration, :require => [:from])
|
24
|
-
end
|
25
|
-
|
26
|
-
def deliver!(message, device)
|
27
|
-
mailer = configuration[:mailer] || Pling::Gateway::ActionMailer::Mailer
|
28
|
-
mailer.pling_message(message, device, configuration).deliver
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def default_configuration
|
34
|
-
super.merge({
|
35
|
-
:html => true,
|
36
|
-
:text => true
|
37
|
-
})
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|