merb-mailer 1.0.15 → 1.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +56 -65
- data/lib/merb-mailer/mail_controller.rb +1 -1
- data/lib/merb-mailer/mailer.rb +17 -4
- data/lib/merb-mailer/version.rb +5 -0
- data/spec/mail_controller_spec.rb +1 -1
- data/spec/mailer_spec.rb +21 -7
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +15 -2
- metadata +24 -13
data/Rakefile
CHANGED
@@ -1,74 +1,65 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
##############################################################################
|
4
|
-
# Package && release
|
5
|
-
##############################################################################
|
6
|
-
RUBY_FORGE_PROJECT = "merb"
|
7
|
-
PROJECT_URL = "http://merbivore.com"
|
8
|
-
PROJECT_SUMMARY = "Merb plugin that provides mailer functionality to Merb"
|
9
|
-
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
10
|
-
|
11
|
-
GEM_AUTHOR = "Yehuda Katz"
|
12
|
-
GEM_EMAIL = "ykatz@engineyard.com"
|
13
|
-
|
14
|
-
GEM_NAME = "merb-mailer"
|
15
|
-
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
16
|
-
GEM_VERSION = Merb::VERSION + PKG_BUILD
|
17
|
-
|
18
|
-
RELEASE_NAME = "REL #{GEM_VERSION}"
|
19
|
-
|
20
|
-
require "extlib/tasks/release"
|
21
|
-
|
22
|
-
spec = Gem::Specification.new do |s|
|
23
|
-
s.rubyforge_project = RUBY_FORGE_PROJECT
|
24
|
-
s.name = GEM_NAME
|
25
|
-
s.version = GEM_VERSION
|
26
|
-
s.platform = Gem::Platform::RUBY
|
27
|
-
s.has_rdoc = true
|
28
|
-
s.extra_rdoc_files = ["README.textile", "LICENSE", 'TODO']
|
29
|
-
s.summary = PROJECT_SUMMARY
|
30
|
-
s.description = PROJECT_DESCRIPTION
|
31
|
-
s.author = GEM_AUTHOR
|
32
|
-
s.email = GEM_EMAIL
|
33
|
-
s.homepage = PROJECT_URL
|
34
|
-
s.add_dependency('merb-core', "~> #{Merb::VERSION}")
|
35
|
-
s.add_dependency('mailfactory', '>= 1.2.3')
|
36
|
-
s.require_path = 'lib'
|
37
|
-
s.files = %w(LICENSE README.textile Rakefile TODO Generators) + Dir.glob("{lib,spec}/**/*")
|
38
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
39
3
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
4
|
+
# Assume a typical dev checkout to fetch the current merb-core version
|
5
|
+
require File.expand_path('../../merb-core/lib/merb-core/version', __FILE__)
|
43
6
|
|
44
|
-
|
45
|
-
|
46
|
-
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
47
|
-
end
|
7
|
+
# Load this library's version information
|
8
|
+
require File.expand_path('../lib/merb-mailer/version', __FILE__)
|
48
9
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
10
|
+
begin
|
11
|
+
|
12
|
+
gem 'jeweler', '~> 1.4'
|
13
|
+
require 'jeweler'
|
14
|
+
|
15
|
+
Jeweler::Tasks.new do |gemspec|
|
16
|
+
|
17
|
+
gemspec.version = Merb::Mailer::VERSION
|
18
|
+
|
19
|
+
gemspec.name = "merb-mailer"
|
20
|
+
gemspec.description = "Merb plugin for mailer support"
|
21
|
+
gemspec.summary = "Merb plugin that provides mailer functionality to Merb"
|
22
|
+
|
23
|
+
gemspec.authors = [ "Yehuda Katz" ]
|
24
|
+
gemspec.email = "ykatz@engineyard.com"
|
25
|
+
gemspec.homepage = "http://merbivore.com/"
|
26
|
+
|
27
|
+
gemspec.files = %w(Generators LICENSE Rakefile README.textile TODO) + Dir['{lib,spec}/**/*']
|
28
|
+
|
29
|
+
# Runtime dependencies
|
30
|
+
gemspec.add_dependency 'merb-core', "~> #{Merb::VERSION}"
|
31
|
+
gemspec.add_dependency('mailfactory', '>= 1.2.3')
|
32
|
+
|
33
|
+
# Development dependencies
|
34
|
+
gemspec.add_development_dependency 'rspec', '>= 1.2.9'
|
53
35
|
|
54
|
-
desc "Create a gemspec file"
|
55
|
-
task :gemspec do
|
56
|
-
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
57
|
-
file.puts spec.to_ruby
|
58
36
|
end
|
37
|
+
|
38
|
+
Jeweler::GemcutterTasks.new
|
39
|
+
|
40
|
+
rescue LoadError
|
41
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
59
42
|
end
|
60
43
|
|
61
|
-
|
62
|
-
Spec::Rake::SpecTask.new(
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
|
67
|
-
else
|
68
|
-
FileList['spec/**/*_spec.rb']
|
69
|
-
end
|
70
|
-
end
|
44
|
+
require 'spec/rake/spectask'
|
45
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
46
|
+
spec.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
|
47
|
+
spec.libs << 'lib' << 'spec'
|
48
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
71
49
|
end
|
72
50
|
|
73
|
-
|
74
|
-
|
51
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
52
|
+
spec.libs << 'lib' << 'spec'
|
53
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
54
|
+
spec.rcov = true
|
55
|
+
end
|
56
|
+
|
57
|
+
task :default => :spec
|
58
|
+
|
59
|
+
require 'rake/rdoctask'
|
60
|
+
Rake::RDocTask.new do |rdoc|
|
61
|
+
rdoc.rdoc_dir = 'rdoc'
|
62
|
+
rdoc.title = "test_gem #{Merb::Mailer::VERSION}"
|
63
|
+
rdoc.rdoc_files.include('README*')
|
64
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
65
|
+
end
|
@@ -241,7 +241,7 @@ module Merb
|
|
241
241
|
rescue Merb::ControllerExceptions::TemplateNotFound => e
|
242
242
|
# An error should be logged if no template is found instead of an error raised
|
243
243
|
if @_missing_templates
|
244
|
-
Merb.logger.error(e)
|
244
|
+
Merb.logger.error(e.message)
|
245
245
|
else
|
246
246
|
@_missing_templates = true
|
247
247
|
end
|
data/lib/merb-mailer/mailer.rb
CHANGED
@@ -21,6 +21,7 @@ module Merb
|
|
21
21
|
# :pass => 'pass',
|
22
22
|
# :auth => :plain # :plain, :login, :cram_md5, the default is no auth
|
23
23
|
# :domain => "localhost.localdomain" # the HELO domain provided by the client to the server
|
24
|
+
# :tls => true/false/nil, true enables tls, default nil
|
24
25
|
# }
|
25
26
|
#
|
26
27
|
# or
|
@@ -54,9 +55,19 @@ module Merb
|
|
54
55
|
|
55
56
|
# Sends the mail using SMTP.
|
56
57
|
def net_smtp
|
57
|
-
Net::SMTP.
|
58
|
-
|
59
|
-
smtp.
|
58
|
+
smtp = Net::SMTP.new(config[:host], config[:port].to_i)
|
59
|
+
if config[:tls]
|
60
|
+
if smtp.respond_to?(:enable_starttls) # 1.9.x
|
61
|
+
smtp.enable_starttls
|
62
|
+
elsif smtp.respond_to?(:enable_tls) && smtp.respond_to?(:use_tls?)
|
63
|
+
smtp.enable_tls(OpenSSL::SSL::VERIFY_NONE) # 1.8.x with tlsmail
|
64
|
+
else
|
65
|
+
raise 'Unable to enable TLS, for Ruby 1.8.x install tlsmail'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
smtp.start(config[:domain], config[:user], config[:pass], config[:auth]) { |smtp|
|
69
|
+
to = @mail.to.is_a?(String) ? @mail.to.split(/[,;]/) : @mail.to
|
70
|
+
smtp.send_message(@mail.to_s, @mail.from.first, to)
|
60
71
|
}
|
61
72
|
end
|
62
73
|
|
@@ -92,7 +103,9 @@ module Merb
|
|
92
103
|
@mail.add_attachment_as *v
|
93
104
|
end
|
94
105
|
else
|
95
|
-
|
106
|
+
if !file_or_files.is_a?(File) && !file_or_files.is_a?(StringIO)
|
107
|
+
raise ArgumentError, "You did not pass in a file. Instead, you sent a #{file_or_files.class}"
|
108
|
+
end
|
96
109
|
@mail.add_attachment_as(file_or_files, filename, type, headers)
|
97
110
|
end
|
98
111
|
end
|
data/spec/mailer_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
class TestMailer < Merb::Mailer
|
4
4
|
self.delivery_method = :test_send
|
@@ -6,12 +6,12 @@ end
|
|
6
6
|
|
7
7
|
class TestSMTPMailer < Merb::Mailer
|
8
8
|
self.delivery_method = :net_smtp
|
9
|
-
self.config = { :
|
9
|
+
self.config = { :domain => 'localhost.localdomain',
|
10
|
+
:host => 'smtp.yourserver.com',
|
10
11
|
:port => '25',
|
11
12
|
:user => 'user',
|
12
13
|
:pass => 'pass',
|
13
14
|
:auth => :plain }
|
14
|
-
|
15
15
|
end
|
16
16
|
|
17
17
|
class TestSendmailMailer < Merb::Mailer
|
@@ -89,18 +89,32 @@ describe "a merb mailer" do
|
|
89
89
|
attachments.last["headers"].should include("Content-ID: <license.txt>")
|
90
90
|
end
|
91
91
|
|
92
|
+
it "should be able to accept objects that respond to :read as attachments" do
|
93
|
+
setup_test_mailer
|
94
|
+
@m.attach StringIO.new('This is some dummy text'), 'readme', 'text/plain', 'Content-ID: <readme.txt>'
|
95
|
+
@m.deliver!
|
96
|
+
delivery = TestMailer.deliveries.last
|
97
|
+
attachments = delivery.instance_variable_get("@attachments")
|
98
|
+
attachments.size.should == 1
|
99
|
+
attachments.first["mimetype"].should eql("text/plain")
|
100
|
+
attachments.first["filename"].should eql("readme")
|
101
|
+
attachments.first["headers"].should include("Content-ID: <readme.txt>")
|
102
|
+
end
|
103
|
+
|
92
104
|
it "should be able to send mails via SMTP" do
|
93
105
|
setup_test_mailer TestSMTPMailer
|
94
|
-
Net::SMTP.
|
95
|
-
Net::SMTP.
|
106
|
+
smtp = Net::SMTP.new(@m.config[:host], @m.config[:port])
|
107
|
+
Net::SMTP.stub!(:new).and_return(smtp)
|
108
|
+
smtp.should_receive(:start).with("localhost.localdomain", "user", "pass", :plain)
|
96
109
|
@m.deliver!
|
97
110
|
end
|
98
111
|
|
99
112
|
it "should send mails via SMTP with no auth" do
|
100
113
|
setup_test_mailer TestSMTPMailer
|
101
114
|
@m.config[:auth] = nil
|
102
|
-
Net::SMTP.
|
103
|
-
Net::SMTP.
|
115
|
+
smtp = Net::SMTP.new(@m.config[:host], @m.config[:port])
|
116
|
+
Net::SMTP.stub!(:new).and_return(smtp)
|
117
|
+
smtp.should_receive(:start).with("localhost.localdomain", "user", "pass", nil)
|
104
118
|
@m.deliver!
|
105
119
|
end
|
106
120
|
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,21 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
1
|
require "rubygems"
|
3
|
-
|
2
|
+
|
3
|
+
# Use current merb-core sources if running from a typical dev checkout.
|
4
|
+
lib = File.expand_path('../../../merb-core/lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
6
|
+
require 'merb-core'
|
7
|
+
|
8
|
+
# Use current merb-gen sources if running from a typical dev checkout.
|
9
|
+
lib = File.expand_path('../../../merb-gen/lib', __FILE__)
|
10
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
11
|
+
require 'merb-gen'
|
12
|
+
|
13
|
+
# The lib under test
|
4
14
|
require "merb-mailer"
|
5
15
|
|
16
|
+
# Satisfies Autotest and anyone else not using the Rake tasks
|
17
|
+
require 'spec'
|
18
|
+
|
6
19
|
Merb::Config.use do |c|
|
7
20
|
c[:session_store] = :memory
|
8
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-20 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.0.
|
23
|
+
version: 1.1.0.pre
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mailfactory
|
@@ -32,30 +32,40 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.2.3
|
34
34
|
version:
|
35
|
-
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.2.9
|
44
|
+
version:
|
45
|
+
description: Merb plugin for mailer support
|
36
46
|
email: ykatz@engineyard.com
|
37
47
|
executables: []
|
38
48
|
|
39
49
|
extensions: []
|
40
50
|
|
41
51
|
extra_rdoc_files:
|
42
|
-
- README.textile
|
43
52
|
- LICENSE
|
44
53
|
- TODO
|
45
54
|
files:
|
55
|
+
- Generators
|
46
56
|
- LICENSE
|
47
57
|
- README.textile
|
48
58
|
- Rakefile
|
49
59
|
- TODO
|
50
|
-
- Generators
|
51
60
|
- lib/generators/mailer_generator.rb
|
52
61
|
- lib/generators/templates/mailer/app/mailers/%file_name%_mailer.rb
|
53
62
|
- lib/generators/templates/mailer/app/mailers/views/%file_name%_mailer/notify_on_event.text.erb
|
54
63
|
- lib/generators/templates/mailer/spec/mailers/%file_name%_mailer_spec.rb
|
64
|
+
- lib/merb-mailer.rb
|
55
65
|
- lib/merb-mailer/mail_controller.rb
|
56
66
|
- lib/merb-mailer/mailer.rb
|
57
67
|
- lib/merb-mailer/mailer_mixin.rb
|
58
|
-
- lib/merb-mailer.rb
|
68
|
+
- lib/merb-mailer/version.rb
|
59
69
|
- spec/mail_controller_spec.rb
|
60
70
|
- spec/mailer_generator_spec.rb
|
61
71
|
- spec/mailer_spec.rb
|
@@ -71,14 +81,15 @@ files:
|
|
71
81
|
- spec/mailers/views/test_mail_controller/ninth.text.erb
|
72
82
|
- spec/mailers/views/test_mail_controller/second.text.erb
|
73
83
|
- spec/mailers/views/test_mail_controller/third.html.erb
|
84
|
+
- spec/spec.opts
|
74
85
|
- spec/spec_helper.rb
|
75
86
|
has_rdoc: true
|
76
|
-
homepage: http://merbivore.com
|
87
|
+
homepage: http://merbivore.com/
|
77
88
|
licenses: []
|
78
89
|
|
79
90
|
post_install_message:
|
80
|
-
rdoc_options:
|
81
|
-
|
91
|
+
rdoc_options:
|
92
|
+
- --charset=UTF-8
|
82
93
|
require_paths:
|
83
94
|
- lib
|
84
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -89,13 +100,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
100
|
version:
|
90
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
102
|
requirements:
|
92
|
-
- - "
|
103
|
+
- - ">"
|
93
104
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
105
|
+
version: 1.3.1
|
95
106
|
version:
|
96
107
|
requirements: []
|
97
108
|
|
98
|
-
rubyforge_project:
|
109
|
+
rubyforge_project:
|
99
110
|
rubygems_version: 1.3.5
|
100
111
|
signing_key:
|
101
112
|
specification_version: 3
|