pakyow-mailer 0.8.rc4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5df68b378e4c3ecf54adc20ecd05c2423433a57a
4
- data.tar.gz: 6ae1b8b641df7759a17f64c636339b1a815cdfdc
3
+ metadata.gz: 5176cd98fcad18048eaeb52eeeeb3cff53dce1bd
4
+ data.tar.gz: af5629e8b9768e94752e1cdcf1b846d1b060b506
5
5
  SHA512:
6
- metadata.gz: bc4e31ecf0811b0b4cd3f1e2df00aa0b2cce29a1f11d40e487dbfc48bf575b960d5dbe6caac3a231fcc20990bafcc86e3396cd0f8e5b9743021277bfd0192b70
7
- data.tar.gz: 831d39ad9a6831c889d3d433e022a990fb7ae3c9df70af92df3bf11dcc0be0c7f3fad370be28069c2900b3188d1b708895ca365c7893f392cab45d8ea6c5c59c
6
+ metadata.gz: 4e4db00b1ec12894a8495f2c18f7b24b061010822d0bf1aa78e681505147d48ccfbcac77723ebf82bd03c7443effb338b7bf2abcaf37ae48ad07210fa2359109
7
+ data.tar.gz: 04e7f61535e189de36d546c8a360c1475041babb85494dbb8cf4ef1a83ec17f34b505c4e30057b6cf5eb4cd31e865373ee557978fbed84d3511f3c4f00e3fd37
@@ -1,3 +1,7 @@
1
+ = 0.8.0 / 2014-03-02
2
+
3
+ * Major rewrite, including premailer support
4
+
1
5
  = 0.7.2 / 2012-02-29
2
6
 
3
7
  * Set HTML part of email rather than body
@@ -4,14 +4,14 @@ module Pakyow
4
4
  Config::Base.register_config(:mailer, self)
5
5
 
6
6
  class << self
7
- attr_accessor :default_sender, :default_content_type, :delivery_method, :delivery_options
7
+ attr_accessor :default_sender, :default_content_type, :delivery_method, :delivery_options, :encoding
8
8
 
9
9
  def default_sender
10
10
  @default_sender || "Pakyow"
11
11
  end
12
12
 
13
13
  def default_content_type
14
- @default_content_type || 'text/html; charset=UTF-8'
14
+ @default_content_type || 'text/html; charset=' + encoding
15
15
  end
16
16
 
17
17
  def delivery_method
@@ -21,6 +21,10 @@ module Pakyow
21
21
  def delivery_options
22
22
  @delivery_options || {:enable_starttls_auto => false}
23
23
  end
24
+
25
+ def encoding
26
+ @encoding || 'UTF-8'
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -1,6 +1,6 @@
1
1
  module Pakyow
2
2
  class Mailer
3
- attr_accessor :view, :message
3
+ attr_accessor :view, :message, :processed
4
4
 
5
5
  def initialize(view_path, view_store)
6
6
  @view = view_store.view(view_path)
@@ -12,18 +12,47 @@ module Pakyow
12
12
  end
13
13
 
14
14
  def deliver_to(recipient, subject = nil)
15
- html_content = self.view.to_html
15
+ html = content(:html)
16
+ text = content(:text)
17
+
16
18
  @message.html_part do
17
- content_type 'text/html; charset=UTF-8'
18
- body html_content
19
+ content_type 'text/html; charset=' + Config::Base.mailer.encoding
20
+ body html
21
+ end
22
+
23
+ @message.text_part do
24
+ body text
19
25
  end
20
26
 
21
27
  @message.subject = subject if subject
22
28
 
23
29
  Array(recipient).each {|r| deliver(r)}
24
30
  end
25
-
31
+
32
+ def content(type = :html)
33
+ return process[type]
34
+ end
35
+
26
36
  protected
37
+
38
+ def process
39
+ unless @processed
40
+ @premailer = Premailer.new(view.to_html, with_html_string: true, input_encoding: Config::Base.mailer.encoding)
41
+
42
+ @premailer.warnings.each do |w|
43
+ Pakyow.logger.warn "#{w[:message]} (#{w[:level]}) may not render properly in #{w[:clients]}"
44
+ end
45
+
46
+ @processed_content = {
47
+ html: @premailer.to_inline_css,
48
+ text: @premailer.to_plain_text,
49
+ }
50
+
51
+ @processed = true
52
+ end
53
+
54
+ return @processed_content
55
+ end
27
56
 
28
57
  def deliver(recipient)
29
58
  @message.to = recipient
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
3
3
 
4
4
  # Gems
5
5
  require 'mail'
6
+ require 'premailer'
6
7
 
7
8
  # Base
8
9
  require 'mailer/mailer'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pakyow-mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.rc4
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-26 00:00:00.000000000 Z
12
+ date: 2014-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pakyow-core
@@ -17,54 +17,68 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.8.rc4
20
+ version: 0.8.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 0.8.rc4
27
+ version: 0.8.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: pakyow-presenter
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 0.8.rc4
34
+ version: 0.8.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 0.8.rc4
41
+ version: 0.8.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: mail
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '2.5'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '2.5'
56
+ - !ruby/object:Gem::Dependency
57
+ name: premailer
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.8'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.8'
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: minitest
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
- - - ~>
74
+ - - "~>"
61
75
  - !ruby/object:Gem::Version
62
76
  version: '5.0'
63
77
  type: :development
64
78
  prerelease: false
65
79
  version_requirements: !ruby/object:Gem::Requirement
66
80
  requirements:
67
- - - ~>
81
+ - - "~>"
68
82
  - !ruby/object:Gem::Version
69
83
  version: '5.0'
70
84
  description: A library for delivering Pakyow views as mail.
@@ -74,8 +88,8 @@ extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
90
  - pakyow-mailer/CHANGES
77
- - pakyow-mailer/README
78
91
  - pakyow-mailer/MIT-LICENSE
92
+ - pakyow-mailer/README
79
93
  - pakyow-mailer/lib/mailer/config/mailer.rb
80
94
  - pakyow-mailer/lib/mailer/helpers.rb
81
95
  - pakyow-mailer/lib/mailer/mailer.rb
@@ -90,17 +104,17 @@ require_paths:
90
104
  - pakyow-mailer/lib
91
105
  required_ruby_version: !ruby/object:Gem::Requirement
92
106
  requirements:
93
- - - '>='
107
+ - - ">="
94
108
  - !ruby/object:Gem::Version
95
109
  version: 1.9.3
96
110
  required_rubygems_version: !ruby/object:Gem::Requirement
97
111
  requirements:
98
- - - '>'
112
+ - - ">="
99
113
  - !ruby/object:Gem::Version
100
- version: 1.3.1
114
+ version: '0'
101
115
  requirements: []
102
116
  rubyforge_project: pakyow-mailer
103
- rubygems_version: 2.0.0
117
+ rubygems_version: 2.2.0
104
118
  signing_key:
105
119
  specification_version: 4
106
120
  summary: A library for delivering Pakyow views as mail.