premailer-rails 1.10.3 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36e83f5f50cf99a5c7c520cc40f135b08e1957f23bd471ab3dfd987549fcca25
4
- data.tar.gz: 002da6d81c92ab09bf2af64c6dd7a87c6a0babf6fd70bc2b59361730499bf3e5
3
+ metadata.gz: 6190c1ff4075799a5bb8860f3f1052ea5312aada5a99aa5a8acad78eee3be40f
4
+ data.tar.gz: d45d0c59d8849cb5b76f265e8a281b632698bef153a8a266a55b3064a7e0dbbe
5
5
  SHA512:
6
- metadata.gz: 2a44732ed01c2cb9ae7662e8dedaffd3d1989d32f627d7182683c6a6878c12e563cbe370008a4770f3e0643715c458ea981a5dd1a303387f4ddec825da7e80ad
7
- data.tar.gz: 23e017fb41932ee883165623cc0afe3f74d9c49a27c5070bd879dfbf174faca160cc76bc3fae350f083be4b89380760016a3c5de8fcfcb1887e4033a855035e3
6
+ metadata.gz: e17ac0c63b5a86baf6316a8e3f595147e5989880e349b904a3f70bce50e6818da0a94f571dd1dba5828ae5692ff1070fedc35bdbda8f88a8440eff72962eabe3
7
+ data.tar.gz: 9f0ac9954868ff7ec22e7d44e3226257f00188bd58ab3ae91b6619e9a6f43bf1f28c9f3f1c40e0602b73b3fd1146c09b27826318326eda853557a15d0d2439bb
data/.gitignore CHANGED
@@ -2,7 +2,7 @@
2
2
  doc/
3
3
  Gemfile.lock
4
4
  coverage/
5
- spec/rails_app/tmp/
6
- spec/rails_app/log/
5
+ spec/rails_app/log/*
6
+ spec/rails_app/tmp/*
7
7
  .ruby-version
8
8
  /.bundle
data/.travis.yml CHANGED
@@ -3,11 +3,12 @@ language: ruby
3
3
  cache: bundler
4
4
  script: bundle exec rspec
5
5
  rvm:
6
- - 2.6.1
6
+ - 2.6.5
7
+ - 2.7.0
7
8
  env:
8
9
  matrix:
9
- - ACTION_MAILER_VERSION=4
10
10
  - ACTION_MAILER_VERSION=5
11
+ - ACTION_MAILER_VERSION=6
11
12
  - ACTION_MAILER_VERSION=master
12
13
  matrix:
13
14
  fast_finish: true
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.11.0
4
+
5
+ - Remove `force_encoding!`
6
+
3
7
  ## v1.10.3
4
8
 
5
9
  - Remove upper version constraint for actionmailer
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.10.3
1
+ 1.11.0
@@ -45,7 +45,7 @@ class Premailer
45
45
  def load_css(url)
46
46
  Premailer::Rails.config.fetch(:strategies).each do |strategy|
47
47
  css = find_strategy(strategy).load(url)
48
- return css.force_encoding('UTF-8') if css
48
+ return css if css
49
49
  end
50
50
 
51
51
  raise FileNotFound, %{File with URL "#{url}" could not be loaded by any strategy.}
@@ -73,10 +73,8 @@ class Premailer
73
73
  part = html_part
74
74
  html = premailer.to_inline_css
75
75
  Mail::Part.new do
76
- content_transfer_encoding part.content_transfer_encoding
77
- content_type "text/html; charset=#{part.charset}"
76
+ content_type "text/html; charset=#{html.encoding}"
78
77
  body html
79
- body_encoding part.body.encoding
80
78
  end
81
79
  end
82
80
 
@@ -85,10 +83,8 @@ class Premailer
85
83
  part = html_part
86
84
  text = premailer.to_plain_text
87
85
  Mail::Part.new do
88
- content_transfer_encoding part.content_transfer_encoding
89
- content_type "text/plain; charset=#{part.charset}"
86
+ content_type "text/plain; charset=#{text.encoding}"
90
87
  body text
91
- body_encoding part.body.encoding
92
88
  end
93
89
  end
94
90
  end
@@ -6,7 +6,7 @@ describe Premailer::Rails::Hook do
6
6
  end
7
7
 
8
8
  def body_content(message)
9
- Nokogiri::HTML(message.html_string).at('body').content
9
+ Nokogiri::HTML(message.html_string).at('body').content.gsub("\r\n", "\n")
10
10
  end
11
11
 
12
12
  class Mail::Message
@@ -47,18 +47,31 @@ describe Premailer::Rails::Hook do
47
47
  expect(processed_message.parts).to match_array(expected_parts)
48
48
  end
49
49
 
50
- describe 'when the content-transfer-encoding is set' do
51
- before { message.content_transfer_encoding = 'quoted-printable' }
50
+ it 'does not screw up the text by maintaining the original body encoding' do
51
+ raw_msg = Fixtures::Message.latin_message
52
+ processed_msg = Fixtures::Message.latin_message
53
+ run_hook(processed_msg)
54
+ expect(body_content(processed_msg)).to eq(body_content(raw_msg))
52
55
 
53
- it 'should maintain the value' do
54
- expect(processed_message.parts.first.content_transfer_encoding).to \
55
- eq 'quoted-printable'
56
- expect(processed_message.parts.last.content_transfer_encoding).to \
57
- eq 'quoted-printable'
58
- end
56
+ raw_msg = Fixtures::Message.non_latin_message
57
+ processed_msg = Fixtures::Message.non_latin_message
58
+ run_hook(processed_msg)
59
+ expect(body_content(processed_msg)).to eq(body_content(raw_msg))
60
+
61
+ raw_msg = Fixtures::Message.greek_message
62
+ processed_msg = Fixtures::Message.greek_message
63
+ run_hook(processed_msg)
64
+ expect(body_content(processed_msg)).to eq(body_content(raw_msg))
65
+
66
+ raw_msg = Fixtures::Message.dash_message
67
+ processed_msg = Fixtures::Message.dash_message
68
+ run_hook(processed_msg)
69
+ expect(body_content(processed_msg)).to eq(body_content(raw_msg))
59
70
  end
60
71
 
61
- it 'does not screw up the text by maintaining the original body encoding' do
72
+ it 'supports US-ASCII output' do
73
+ Premailer::Rails.config.merge!(output_encoding: 'US-ASCII')
74
+
62
75
  raw_msg = Fixtures::Message.latin_message
63
76
  processed_msg = Fixtures::Message.latin_message
64
77
  run_hook(processed_msg)
@@ -68,6 +81,18 @@ describe Premailer::Rails::Hook do
68
81
  processed_msg = Fixtures::Message.non_latin_message
69
82
  run_hook(processed_msg)
70
83
  expect(body_content(processed_msg)).to eq(body_content(raw_msg))
84
+
85
+ raw_msg = Fixtures::Message.greek_message
86
+ processed_msg = Fixtures::Message.greek_message
87
+ run_hook(processed_msg)
88
+ expect(body_content(processed_msg)).to eq(body_content(raw_msg))
89
+
90
+ raw_msg = Fixtures::Message.dash_message
91
+ processed_msg = Fixtures::Message.dash_message
92
+ run_hook(processed_msg)
93
+ expect(body_content(processed_msg)).to eq(body_content(raw_msg))
94
+ ensure
95
+ Premailer::Rails.config.delete(:output_encoding)
71
96
  end
72
97
 
73
98
  it 'generates a text part from the html' do
@@ -35,6 +35,30 @@ module Fixtures
35
35
  </html>
36
36
  HTML
37
37
 
38
+ HTML_PART_IN_GREEK = <<-HTML.encode(Encoding::ISO_8859_7)
39
+ <html>
40
+ <head>
41
+ </head>
42
+ <body>
43
+ <p>
44
+ Αα Ββ Γγ Δδ Εε Ζζ Ηη Θθ Ιι Κκ Λλ Μμ Νν Ξξ Οο Ππ Ρρ Σσ Ττ Υυ Φφ Χχ Ψψ Ωω
45
+ </p>
46
+ </body>
47
+ </html>
48
+ HTML
49
+
50
+ HTML_PART_WITH_DASHES = <<-HTML
51
+ <html>
52
+ <head>
53
+ </head>
54
+ <body>
55
+ <p>
56
+ Hello there—yes you! What's up with – pardon the interrupion – dashes? I can also do &ndash; and &mdash;.
57
+ </p>
58
+ </body>
59
+ </html>
60
+ HTML
61
+
38
62
  HTML_PART_WITH_CSS = <<-HTML
39
63
  <html>
40
64
  <head>
@@ -130,6 +154,22 @@ nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
130
154
  end
131
155
  end
132
156
 
157
+ def greek_message
158
+ base_message.tap do |message|
159
+ message.body = HTML_PART_IN_GREEK
160
+ message.content_type 'text/html; charset=ISO-8859-7'
161
+ message.ready_to_send!
162
+ end
163
+ end
164
+
165
+ def dash_message
166
+ base_message.tap do |message|
167
+ message.body = HTML_PART_WITH_DASHES
168
+ message.content_type 'text/html; charset=UTF-8'
169
+ message.ready_to_send!
170
+ end
171
+ end
172
+
133
173
  private
134
174
 
135
175
  def base_message
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: premailer-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.3
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipe Fatio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-17 00:00:00.000000000 Z
11
+ date: 2020-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: premailer
@@ -152,6 +152,8 @@ files:
152
152
  - spec/rails_app/config/environments/test.rb
153
153
  - spec/rails_app/config/initializers/assets.rb
154
154
  - spec/rails_app/config/routes.rb
155
+ - spec/rails_app/log/.keep
156
+ - spec/rails_app/tmp/.keep
155
157
  - spec/spec_helper.rb
156
158
  - spec/support/fixtures/html.rb
157
159
  - spec/support/fixtures/message.rb
@@ -179,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
181
  - !ruby/object:Gem::Version
180
182
  version: '0'
181
183
  requirements: []
182
- rubygems_version: 3.0.3
184
+ rubygems_version: 3.1.2
183
185
  signing_key:
184
186
  specification_version: 4
185
187
  summary: Easily create styled HTML emails in Rails.
@@ -217,6 +219,8 @@ test_files:
217
219
  - spec/rails_app/config/environments/test.rb
218
220
  - spec/rails_app/config/initializers/assets.rb
219
221
  - spec/rails_app/config/routes.rb
222
+ - spec/rails_app/log/.keep
223
+ - spec/rails_app/tmp/.keep
220
224
  - spec/spec_helper.rb
221
225
  - spec/support/fixtures/html.rb
222
226
  - spec/support/fixtures/message.rb