merb-mailer 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ GEM_EMAIL = "ykatz@engineyard.com"
17
17
 
18
18
  GEM_NAME = "merb-mailer"
19
19
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
20
- GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.5") + PKG_BUILD
20
+ GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.6") + PKG_BUILD
21
21
 
22
22
  RELEASE_NAME = "REL #{GEM_VERSION}"
23
23
 
@@ -35,7 +35,7 @@ spec = Gem::Specification.new do |s|
35
35
  s.author = GEM_AUTHOR
36
36
  s.email = GEM_EMAIL
37
37
  s.homepage = PROJECT_URL
38
- s.add_dependency('merb-core', '>= 0.9.5')
38
+ s.add_dependency('merb-core', '>= 0.9.6')
39
39
  s.add_dependency('mailfactory', '>= 1.2.3')
40
40
  s.require_path = 'lib'
41
41
  s.files = %w(LICENSE README.textile Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
@@ -47,14 +47,14 @@ end
47
47
 
48
48
  desc "Install the gem"
49
49
  task :install => [:package] do
50
- sh %{#{sudo} gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}
50
+ sh install_command(GEM_NAME, GEM_VERSION)
51
51
  end
52
52
 
53
53
  namespace :jruby do
54
54
 
55
55
  desc "Run :package and install the resulting .gem with jruby"
56
56
  task :install => :package do
57
- sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
57
+ sh jinstall_command(GEM_NAME, GEM_VERSION)
58
58
  end
59
59
 
60
60
  end
@@ -13,22 +13,22 @@ module Merb::Generators
13
13
 
14
14
  first_argument :name, :required => true, :desc => "mailer name"
15
15
 
16
- template :mailer do
17
- source('app/mailers/%file_name%_mailer.rb')
18
- destination("app/mailers", base_path, "#{file_name}_mailer.rb")
16
+ template :mailer do |t|
17
+ t.source = 'app/mailers/%file_name%_mailer.rb'
18
+ t.destination = File.join("app/mailers", base_path, "#{file_name}_mailer.rb")
19
19
  end
20
20
 
21
- template :notify_on_event do
22
- source('app/mailers/views/%file_name%_mailer/notify_on_event.text.erb')
23
- destination("app/mailers/views", base_path, "#{file_name}_mailer/notify_on_event.text.erb")
21
+ template :notify_on_event do |t|
22
+ t.source = 'app/mailers/views/%file_name%_mailer/notify_on_event.text.erb'
23
+ t.destination = File.join("app/mailers/views", base_path, "#{file_name}_mailer/notify_on_event.text.erb")
24
24
  end
25
25
 
26
- template :controller_spec, :testing_framework => :rspec do
27
- source('spec/mailers/%file_name%_mailer_spec.rb')
28
- destination("spec/mailers", base_path, "#{file_name}_mailer_spec.rb")
26
+ template :controller_spec, :testing_framework => :rspec do |t|
27
+ t.source = 'spec/mailers/%file_name%_mailer_spec.rb'
28
+ t.destination = File.join("spec/mailers", base_path, "#{file_name}_mailer_spec.rb")
29
29
  end
30
30
 
31
31
  end
32
32
 
33
33
  add :mailer, MailerGenerator
34
- end
34
+ end
@@ -85,7 +85,12 @@ module Merb
85
85
  def attach(file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil,
86
86
  type = nil, headers = nil)
87
87
  if file_or_files.is_a?(Array)
88
- file_or_files.each {|k,v| @mail.add_attachment_as k, *v}
88
+ file_or_files.each do |v|
89
+ if v.length < 2
90
+ v << v.first.is_a?(File) ? File.basename(v.first.path) : nil
91
+ end
92
+ @mail.add_attachment_as *v
93
+ end
89
94
  else
90
95
  raise ArgumentError, "You did not pass in a file. Instead, you sent a #{file_or_files.class}" if !file_or_files.is_a?(File)
91
96
  @mail.add_attachment_as(file_or_files, filename, type, headers)
data/spec/mailer_spec.rb CHANGED
@@ -40,7 +40,7 @@ describe "a merb mailer" do
40
40
 
41
41
  it "should be able to accept attachments" do
42
42
  setup_test_mailer
43
- @m.attach File.open("README")
43
+ @m.attach File.open("README.textile")
44
44
  @m.deliver!
45
45
  delivery = TestMailer.deliveries.last
46
46
  delivery.instance_variable_get("@attachments").size.should == 1
@@ -48,12 +48,40 @@ describe "a merb mailer" do
48
48
 
49
49
  it "should be able to accept multiple attachments" do
50
50
  setup_test_mailer
51
- @m.attach [[File.open("README")], [File.open("LICENSE")]]
51
+ @m.attach [[File.open("README.textile")], [File.open("LICENSE")]]
52
52
  @m.deliver!
53
53
  delivery = TestMailer.deliveries.last
54
54
  delivery.instance_variable_get("@attachments").size.should == 2
55
55
  end
56
-
56
+
57
+ it "should be able to accept custom options for attachments" do
58
+ setup_test_mailer
59
+ @m.attach File.open("README.textile"), 'readme', 'text/plain', 'Content-ID: <readme.txt>'
60
+ @m.deliver!
61
+ delivery = TestMailer.deliveries.last
62
+ attachments = delivery.instance_variable_get("@attachments")
63
+ attachments.size.should == 1
64
+ attachments.first["mimetype"].should eql("text/plain")
65
+ attachments.first["filename"].should eql("readme")
66
+ attachments.first["headers"].should include("Content-ID: <readme.txt>")
67
+ end
68
+
69
+ it "should be able to accept custom options for multiple attachments" do
70
+ setup_test_mailer
71
+ @m.attach [[File.open("README.textile"), 'readme', 'text/plain', 'Content-ID: <readme.txt>'],
72
+ [File.open("LICENSE"), 'license', 'text/plain', 'Content-ID: <license.txt>']]
73
+ @m.deliver!
74
+ delivery = TestMailer.deliveries.last
75
+ attachments = delivery.instance_variable_get("@attachments")
76
+ attachments.size.should == 2
77
+ attachments.first["mimetype"].should eql("text/plain")
78
+ attachments.first["filename"].should eql("readme")
79
+ attachments.first["headers"].should include("Content-ID: <readme.txt>")
80
+ attachments.last["mimetype"].should eql("text/plain")
81
+ attachments.last["filename"].should eql("license")
82
+ attachments.last["headers"].should include("Content-ID: <license.txt>")
83
+ end
84
+
57
85
  it "should be able to send mails via SMTP" do
58
86
  setup_test_mailer TestSMTPMailer
59
87
  Net::SMTP.stub!(:start).and_return(true)
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: 0.9.5
4
+ version: 0.9.6
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: 2008-08-21 00:00:00 +03:00
12
+ date: 2008-09-09 00:00:00 +03: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: 0.9.5
23
+ version: 0.9.6
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mailfactory