padrino-mailer 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -54,7 +54,7 @@ or if you like the method_missing approach:
54
54
 
55
55
  And that will then deliver the email according the the configured options. This is really all you need to send emails.
56
56
 
57
- Be sure to check out the
57
+ Be sure to check out the
58
58
  {Padrino Mailer}[http://wiki.github.com/padrino/padrino-framework/padrino-mailer] guide for more details on usage.
59
59
 
60
60
  == Copyright
data/Rakefile CHANGED
@@ -63,4 +63,4 @@ Rake::RDocTask.new do |rdoc|
63
63
  rdoc.title = "padrino-mailer #{version}"
64
64
  rdoc.rdoc_files.include('README*')
65
65
  rdoc.rdoc_files.include('lib/**/*.rb')
66
- end
66
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.6
1
+ 0.9.7
@@ -10,15 +10,15 @@ Dir[File.dirname(__FILE__) + '/padrino-mailer/**/*.rb'].each { |file| require fi
10
10
 
11
11
  module Padrino
12
12
  ##
13
- # This component uses an enhanced version of the excellent pony library (vendored) for a powerful but simple mailer
13
+ # This component uses an enhanced version of the excellent pony library (vendored) for a powerful but simple mailer
14
14
  # system within Padrino (and Sinatra).
15
- # There is full support for using an html content type as well as for file attachments.
15
+ # There is full support for using an html content type as well as for file attachments.
16
16
  # The MailerPlugin has many similarities to ActionMailer but is much lighterweight and (arguably) easier to use.
17
- #
17
+ #
18
18
  module Mailer
19
19
  ##
20
20
  # Used Padrino::Application for register Padrino::Mailer::Base::views_path
21
- #
21
+ #
22
22
  def self.registered(app)
23
23
  Padrino::Mailer::Base::views_path << app.views
24
24
  end
@@ -2,9 +2,9 @@ module Padrino
2
2
  module Mailer
3
3
  ##
4
4
  # This is the abstract class that other mailers will inherit from in order to send mail
5
- #
5
+ #
6
6
  # You can set the default delivery settings through:
7
- #
7
+ #
8
8
  # Padrino::Mailer::Base.smtp_settings = {
9
9
  # :host => 'smtp.yourserver.com',
10
10
  # :port => '25',
@@ -13,17 +13,20 @@ module Padrino
13
13
  # :auth => :plain # :plain, :login, :cram_md5, no auth by default
14
14
  # :domain => "localhost.localdomain" # the HELO domain provided by the client to the server
15
15
  # }
16
- #
16
+ #
17
17
  # and then all delivered mail will use these settings unless otherwise specified.
18
- #
18
+ #
19
19
  class Base
20
20
  ##
21
21
  # Returns the available mail fields when composing a message
22
- #
22
+ #
23
23
  def self.mail_fields
24
24
  [:to, :cc, :bcc, :reply_to, :from, :subject, :content_type, :charset, :via, :attachments]
25
25
  end
26
26
 
27
+ @@views_path = []
28
+ cattr_accessor :smtp_settings
29
+ cattr_accessor :views_path
27
30
  attr_accessor :mail_attributes
28
31
 
29
32
  def initialize(mail_name=nil) #:nodoc:
@@ -33,14 +36,14 @@ module Padrino
33
36
 
34
37
  ##
35
38
  # Defines a method allowing mail attributes to be set into a hash for use when delivering
36
- #
39
+ #
37
40
  self.mail_fields.each do |field|
38
41
  define_method(field) { |value| @mail_attributes[field] = value }
39
42
  end
40
43
 
41
44
  ##
42
45
  # Assigns the body key to the mail attributes either with the rendered body from a template or the given string value
43
- #
46
+ #
44
47
  def body(body_value)
45
48
  template = template_path
46
49
  raise "Template for '#{@mail_name}' could not be located in views path!" unless template
@@ -50,7 +53,7 @@ module Padrino
50
53
 
51
54
  ##
52
55
  # Returns the path to the email template searched for using glob pattern
53
- #
56
+ #
54
57
  def template_path
55
58
  self.views_path.each do |path|
56
59
  template = Dir[File.join(path, self.class.name.underscore.split("/").last, "#{@mail_name}.*")].first
@@ -58,18 +61,14 @@ module Padrino
58
61
  end
59
62
  end
60
63
 
61
- @@views_path = []
62
- cattr_accessor :smtp_settings
63
- cattr_accessor :views_path
64
-
65
64
  ##
66
65
  # Delivers the specified message for mail_name to the intended recipients
67
66
  # mail_name corresponds to the name of a defined method within the mailer class
68
- #
67
+ #
69
68
  # ==== Examples
70
- #
69
+ #
71
70
  # SampleMailer.deliver(:birthday_message)
72
- #
71
+ #
73
72
  def self.deliver(mail_name, *args)
74
73
  mail_object = self.new(mail_name)
75
74
  mail_object.method(mail_name).call(*args)
@@ -78,7 +77,7 @@ module Padrino
78
77
 
79
78
  ##
80
79
  # Returns true if a mail exists with the name being delivered
81
- #
80
+ #
82
81
  def self.respond_to?(method_sym, include_private = false)
83
82
  method_sym.to_s =~ /deliver_(.*)/ ? self.method_defined?($1) : super(method_sym, include_private)
84
83
  end
@@ -86,10 +85,10 @@ module Padrino
86
85
  ##
87
86
  # Handles method missing for a mailer class. Delivers a message based on the method
88
87
  # being called i.e #deliver_birthday_message(22) invokes #birthday_message(22) to setup mail object
89
- #
88
+ #
90
89
  def self.method_missing(method_sym, *arguments, &block)
91
90
  method_sym.to_s =~ /deliver_(.*)/ ? self.deliver($1, *arguments) : super(method_sym, *arguments, &block)
92
91
  end
93
92
  end # Base
94
93
  end # Mailer
95
- end # Padrino
94
+ end # Padrino
@@ -107,4 +107,4 @@ module Padrino
107
107
  end
108
108
  end # Delivery
109
109
  end # Mailer
110
- end # Padrino
110
+ end # Padrino
@@ -3,20 +3,20 @@ module Padrino
3
3
  ##
4
4
  # This represents a particular mail object which will need to be sent
5
5
  # A mail_object requires the mail attributes and the delivery_settings
6
- #
6
+ #
7
7
  class MailObject
8
8
  ##
9
9
  # Initialize a new MailObject
10
- #
10
+ #
11
11
  # ==== Examples
12
- #
12
+ #
13
13
  # Padrino::Mailer::MailObject.new(
14
14
  # :subject => "Hey this is my subject",
15
- # :to => "info@padrinorb.org",
16
- # :from => "foo@bar.com",
15
+ # :to => "info@padrinorb.org",
16
+ # :from => "foo@bar.com",
17
17
  # :body => "This is my body"
18
18
  # ).deliver
19
- #
19
+ #
20
20
  def initialize(mail_attributes={}, smtp_settings={})
21
21
  @mail_attributes = mail_attributes.dup
22
22
  @smtp_settings = smtp_settings.dup if smtp_settings.present?
@@ -24,11 +24,11 @@ module Padrino
24
24
 
25
25
  ##
26
26
  # Constructs the delivery attributes for the message and then sends the mail
27
- #
27
+ #
28
28
  # ==== Examples
29
- #
29
+ #
30
30
  # @mail_object.deliver
31
- #
31
+ #
32
32
  def deliver
33
33
  @mail_attributes.reverse_merge!(:via => self.delivery_method.to_sym)
34
34
  @mail_attributes.reverse_merge!(:smtp => @smtp_settings) if using_smtp?
@@ -38,28 +38,28 @@ module Padrino
38
38
  protected
39
39
  ##
40
40
  # Returns the delivery method to use for this mail object
41
- #
41
+ #
42
42
  # ==== Examples
43
- #
43
+ #
44
44
  # @mo.delivery_method => :smtp || :sendmail
45
- #
45
+ #
46
46
  def delivery_method
47
47
  @mail_attributes[:via] || (@smtp_settings.present? ? :smtp : :sendmail)
48
48
  end
49
49
 
50
50
  ##
51
51
  # Returns true if the mail object is going to be delivered using smtp
52
- #
52
+ #
53
53
  def using_smtp?
54
54
  delivery_method.to_s =~ /smtp/
55
55
  end
56
56
 
57
57
  ##
58
58
  # Performs the actual email sending
59
- #
59
+ #
60
60
  def send_mail(delivery_attributes)
61
61
  Delivery.mail(delivery_attributes) && true
62
62
  end
63
63
  end # MailObject
64
64
  end # Mailer
65
- end # Padrino
65
+ end # Padrino
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-mailer}
8
- s.version = "0.9.6"
8
+ s.version = "0.9.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
12
- s.date = %q{2010-03-15}
12
+ s.date = %q{2010-03-22}
13
13
  s.description = %q{Mailer system for padrino allowing easy delivery of application emails}
14
14
  s.email = %q{padrinorb@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -48,7 +48,7 @@ Gem::Specification.new do |s|
48
48
  s.specification_version = 3
49
49
 
50
50
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
- s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.6"])
51
+ s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.7"])
52
52
  s.add_runtime_dependency(%q<tilt>, [">= 0.6"])
53
53
  s.add_runtime_dependency(%q<tmail>, [">= 1.2"])
54
54
  s.add_development_dependency(%q<shoulda>, [">= 2.10.3"])
@@ -57,7 +57,7 @@ Gem::Specification.new do |s|
57
57
  s.add_development_dependency(%q<rack-test>, [">= 0.5.0"])
58
58
  s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
59
59
  else
60
- s.add_dependency(%q<padrino-core>, ["= 0.9.6"])
60
+ s.add_dependency(%q<padrino-core>, ["= 0.9.7"])
61
61
  s.add_dependency(%q<tilt>, [">= 0.6"])
62
62
  s.add_dependency(%q<tmail>, [">= 1.2"])
63
63
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
@@ -67,7 +67,7 @@ Gem::Specification.new do |s|
67
67
  s.add_dependency(%q<webrat>, [">= 0.5.1"])
68
68
  end
69
69
  else
70
- s.add_dependency(%q<padrino-core>, ["= 0.9.6"])
70
+ s.add_dependency(%q<padrino-core>, ["= 0.9.7"])
71
71
  s.add_dependency(%q<tilt>, [">= 0.6"])
72
72
  s.add_dependency(%q<tmail>, [">= 1.2"])
73
73
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
@@ -17,7 +17,7 @@ class MailerDemo < Sinatra::Base
17
17
  register Padrino::Mailer
18
18
 
19
19
  class SampleMailer < Padrino::Mailer::Base
20
-
20
+
21
21
  def birthday_message(name, age)
22
22
  subject "Happy Birthday!"
23
23
  to 'john@fake.com'
@@ -1,2 +1,2 @@
1
- Happy Birthday <%= name %>!
1
+ Happy Birthday <%= name %>!
2
2
  You are turning <%= age %>
data/test/helper.rb CHANGED
@@ -6,9 +6,9 @@ require 'rack/test'
6
6
  require 'webrat'
7
7
 
8
8
  # We try to load the vendored padrino-core if exist
9
- %w(core).each do |gem|
10
- if File.exist?(File.dirname(__FILE__) + "/../../padrino-#{gem}/lib")
11
- $:.unshift File.dirname(__FILE__) + "/../../padrino-#{gem}/lib"
9
+ %w(core).each do |lib|
10
+ if File.exist?(File.dirname(__FILE__) + "/../../padrino-#{lib}/lib")
11
+ $:.unshift File.dirname(__FILE__) + "/../../padrino-#{lib}/lib"
12
12
  end
13
13
  end
14
14
 
@@ -53,7 +53,7 @@ class TestMailerBase < Test::Unit::TestCase
53
53
 
54
54
  should "perform the email delivery for smtp" do
55
55
  DemoMailer.smtp_settings = { :host => 'smtp.arcadic.com' }
56
- Delivery.expects(:mail).with(:from => 'test@default.com', :to => 'test@test.com',
56
+ Delivery.expects(:mail).with(:from => 'test@default.com', :to => 'test@test.com',
57
57
  :body => "SMTP Hello world!", :via => :smtp, :smtp => { :host => 'smtp.arcadic.com' })
58
58
  DemoMailer.deliver(:sample_mail_smtp)
59
59
  end
@@ -7,14 +7,14 @@ class TestPadrinoMailer < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  context 'for mail delivery in sample application' do
10
- setup {
11
- Padrino::Mailer::Base::views_path = MailerDemo.views
12
- MailerDemo::SampleMailer.smtp_settings = MailerDemo.smtp_settings
10
+ setup {
11
+ Padrino::Mailer::Base::views_path << MailerDemo.views
12
+ MailerDemo::SampleMailer.smtp_settings = MailerDemo.smtp_settings
13
13
  }
14
14
 
15
15
  should 'be able to deliver plain text emails' do
16
16
  assert_email_sent(:to => 'john@fake.com', :from => 'noreply@birthday.com', :via => :smtp,
17
- :subject => "Happy Birthday!", :body => "Happy Birthday Joey! \nYou are turning 21")
17
+ :subject => "Happy Birthday!", :body => "Happy Birthday Joey!\nYou are turning 21")
18
18
  visit '/deliver/plain', :post
19
19
  assert_equal 'mail delivered', last_response.body
20
20
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 6
9
- version: 0.9.6
8
+ - 7
9
+ version: 0.9.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Padrino Team
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-03-15 00:00:00 -07:00
20
+ date: 2010-03-22 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -30,8 +30,8 @@ dependencies:
30
30
  segments:
31
31
  - 0
32
32
  - 9
33
- - 6
34
- version: 0.9.6
33
+ - 7
34
+ version: 0.9.7
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency