padrino-mailer 0.10.7 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 72f22cdede10f09a210484af70efe5b4ee4cfc24
4
+ data.tar.gz: 344494c4fabc6232c4ddee140cb38432516bf053
5
+ SHA512:
6
+ metadata.gz: e850182419d09cd2bc2ba422c70d1a9b195c144d58c54845a5678b18f4a81984d240c7a5f4447b6ac55904e9485595f923be5865dd1e1063d8e46768565159e4
7
+ data.tar.gz: 83ccd2eaf3d56ecaf5992459d0356c482baa10abf21d72e766018bbbd98a31ac5c11392d232da494ae2c46787f6a3b144bf8cec53fa91c7d9f24e9faea1ad6fe
@@ -86,7 +86,7 @@ module Padrino
86
86
  def email(name, &block)
87
87
  raise "The email '#{name}' is already defined" if self.messages[name].present?
88
88
  self.messages[name] = Proc.new { |*attrs|
89
- message = Mail::Message.new(self.app)
89
+ message = app.settings._padrino_mailer::Message.new(self.app)
90
90
  message.defaults = self.defaults if self.defaults.any?
91
91
  message.delivery_method(*delivery_settings)
92
92
  message.instance_exec(*attrs, &block)
@@ -16,6 +16,9 @@ module Mail # @private
16
16
  settings.views = File.expand_path("./mailers")
17
17
  settings.reload_templates = true
18
18
  end
19
+
20
+ initialize_template_settings!
21
+
19
22
  # Run the original initialize
20
23
  initialize_without_app(*args, &block)
21
24
  end
@@ -52,13 +55,11 @@ module Mail # @private
52
55
  # text_part "Some text"
53
56
  # text_part { render('multipart/basic.text') }
54
57
  #
55
- def text_part(value=nil, &block)
56
- if block_given? || value
57
- @text_part = self.part(:content_type => "text/plain", :body => value, :part_block => block)
58
- add_multipart_alternate_header unless html_part.blank?
59
- else
60
- @text_part || find_first_mime_type("text/plain")
61
- end
58
+ def text_part(value = nil, &block)
59
+ add_resolved_part(:variable => :text_part,
60
+ :value => value,
61
+ :content_type => 'text/plain',
62
+ &block)
62
63
  end
63
64
 
64
65
  ##
@@ -70,12 +71,20 @@ module Mail # @private
70
71
  # html_part "Some <b>Html</b> text"
71
72
  # html_part { render('multipart/basic.html') }
72
73
  #
73
- def html_part(value=nil, &block)
74
+ def html_part(value = nil, &block)
75
+ add_resolved_part(:variable => :html_part,
76
+ :value => value,
77
+ :content_type => 'text/html',
78
+ &block)
79
+ end
80
+
81
+ def add_resolved_part(attributes = {}, &block)
82
+ variable, value, content_type = attributes.values_at(:variable, :value, :content_type)
74
83
  if block_given? || value
75
- @html_part = self.part(:content_type => "text/html", :body => value, :part_block => block)
76
- add_multipart_alternate_header unless text_part.blank?
84
+ instance_variable_set "@#{variable}", self.part(:content_type => content_type, :body => value, :part_block => block)
85
+ add_multipart_alternate_header unless self.send(variable).blank?
77
86
  else
78
- @html_part || find_first_mime_type("text/html")
87
+ instance_variable_get("@#{variable}") || find_first_mime_type(content_type)
79
88
  end
80
89
  end
81
90
 
@@ -240,5 +249,11 @@ module Mail # @private
240
249
  self.body = super(engine, data, options, locals, &block) if provides.empty?
241
250
  end
242
251
 
252
+ # register all special template configurations Padrino has to our fake settings object.
253
+ def initialize_template_settings!
254
+ Padrino::Rendering.engine_configurations.each do |name, value|
255
+ settings.class.instance_eval { define_method(name) { value } }
256
+ end
257
+ end
243
258
  end # Message
244
259
  end # Mail
@@ -136,9 +136,10 @@ module Padrino
136
136
  #
137
137
  # @api public
138
138
  def email(mail_attributes={}, &block)
139
- message = Mail::Message.new(self)
139
+ message = _padrino_mailer::Message.new(self)
140
140
  message.delivery_method(*delivery_settings)
141
141
  message.instance_eval(&block) if block_given?
142
+ mail_attributes.reverse_merge(mailer_defaults) if respond_to?(:mailer_defaults)
142
143
  mail_attributes.each_pair { |k, v| message.method(k).call(v) }
143
144
  message.deliver
144
145
  end
@@ -5,10 +5,6 @@ rescue LoadError
5
5
  require 'sinatra/tilt'
6
6
  end
7
7
  require 'padrino-core/support_lite' unless defined?(SupportLite)
8
- require 'mail'
9
-
10
- # Require respecting order of our dependencies
11
- FileSet.glob_require('padrino-mailer/**/*.rb', __FILE__)
12
8
 
13
9
  module Padrino
14
10
  ##
@@ -45,6 +41,15 @@ module Padrino
45
41
  #
46
42
  # @api public
47
43
  def registered(app)
44
+ require 'padrino-mailer/base'
45
+ require 'padrino-mailer/helpers'
46
+ require 'padrino-mailer/mime'
47
+ # This lazily loads the mail gem, due to its long require time.
48
+ app.set :_padrino_mailer, proc {
49
+ require 'mail'
50
+ require 'padrino-mailer/ext'
51
+ app._padrino_mailer = Mail
52
+ }
48
53
  app.helpers Padrino::Mailer::Helpers
49
54
  end
50
55
  alias :included :registered
@@ -23,5 +23,5 @@ Gem::Specification.new do |s|
23
23
  s.rdoc_options = ["--charset=UTF-8"]
24
24
 
25
25
  s.add_dependency("padrino-core", Padrino.version)
26
- s.add_dependency("mail", "~> 2.3.0")
26
+ s.add_dependency("mail", "~> 2.5.3")
27
27
  end
@@ -1 +1 @@
1
- This is a body of text from a template
1
+ This is a body of text from a template with interpolated <%= "<i>" %> and non-interpolated tags<br/>
data/test/test_email.rb CHANGED
@@ -68,7 +68,7 @@ describe "Email" do
68
68
  assert_equal ['padrino@me.com'], email.from
69
69
  assert_equal ['padrino@you.com'], email.to
70
70
  assert_equal 'Hello there Padrino', email.subject
71
- assert_equal 'This is a body of text from a template', email.body.to_s.chomp
71
+ assert_equal 'This is a body of text from a template with interpolated &lt;i&gt; and non-interpolated tags<br/>', email.body.to_s.chomp
72
72
  end
73
73
 
74
74
  should 'send emails with scoped mailer defaults' do
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.7
5
- prerelease:
4
+ version: 0.11.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Padrino Team
@@ -12,40 +11,36 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2012-06-20 00:00:00.000000000 Z
14
+ date: 2013-03-22 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: padrino-core
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
20
  - - '='
23
21
  - !ruby/object:Gem::Version
24
- version: 0.10.7
22
+ version: 0.11.0
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
27
  - - '='
31
28
  - !ruby/object:Gem::Version
32
- version: 0.10.7
29
+ version: 0.11.0
33
30
  - !ruby/object:Gem::Dependency
34
31
  name: mail
35
32
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
33
  requirements:
38
34
  - - ~>
39
35
  - !ruby/object:Gem::Version
40
- version: 2.3.0
36
+ version: 2.5.3
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
41
  - - ~>
47
42
  - !ruby/object:Gem::Version
48
- version: 2.3.0
43
+ version: 2.5.3
49
44
  description: Mailer system for padrino allowing easy delivery of application emails
50
45
  email: padrinorb@gmail.com
51
46
  executables: []
@@ -93,28 +88,27 @@ files:
93
88
  - test/test_part.rb
94
89
  homepage: http://www.padrinorb.com
95
90
  licenses: []
91
+ metadata: {}
96
92
  post_install_message:
97
93
  rdoc_options:
98
94
  - --charset=UTF-8
99
95
  require_paths:
100
96
  - lib
101
97
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
98
  requirements:
104
- - - ! '>='
99
+ - - '>='
105
100
  - !ruby/object:Gem::Version
106
101
  version: '0'
107
102
  required_rubygems_version: !ruby/object:Gem::Requirement
108
- none: false
109
103
  requirements:
110
- - - ! '>='
104
+ - - '>='
111
105
  - !ruby/object:Gem::Version
112
106
  version: 1.3.6
113
107
  requirements: []
114
108
  rubyforge_project: padrino-mailer
115
- rubygems_version: 1.8.21
109
+ rubygems_version: 2.0.3
116
110
  signing_key:
117
- specification_version: 3
111
+ specification_version: 4
118
112
  summary: Mailer system for padrino
119
113
  test_files:
120
114
  - test/fixtures/basic.erb