premailer-rails 1.9.0 → 1.9.1
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/example/bin/rails +4 -0
- data/lib/premailer/rails/css_helper.rb +1 -1
- data/lib/premailer/rails/hook.rb +3 -1
- data/spec/integration/css_helper_spec.rb +9 -0
- data/spec/integration/hook_spec.rb +11 -0
- data/spec/support/fixtures/html.rb +8 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a4e3c274d320126db1a2edecd52529cae72f3f7
|
4
|
+
data.tar.gz: d4a9a0fd22637f82da097b07cf8930827feb5161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc5726488711de669ba671ef6f048ae38b9c1cb44d1be95a8a9728d359d9adf6b1e66a74cfe05d894e8a9fe2b648b82a62317a08e6f5d11d43f5cd486715b87f
|
7
|
+
data.tar.gz: 58c425afba99b7996f89e7c9858df716670211beadae82b18e6866de8f141c766771ea9f2d3770d84ebc9b0f66bcb513efd97a614ac2fc53bbcc503c16072efb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -139,7 +139,7 @@ end
|
|
139
139
|
Note that the mere presence of this header causes premailer to be skipped, i.e.,
|
140
140
|
even setting `skip_premailer: false` will cause premailer to be skipped. The
|
141
141
|
reason for that is that the `skip_premailer` is a simple header and the value is
|
142
|
-
transformed into a string, causing `'false'` to become
|
142
|
+
transformed into a string, causing `'false'` to become truthy.
|
143
143
|
|
144
144
|
## Small Print
|
145
145
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.1
|
data/example/bin/rails
ADDED
data/lib/premailer/rails/hook.rb
CHANGED
@@ -68,15 +68,17 @@ class Premailer
|
|
68
68
|
def generate_html_part
|
69
69
|
# Make sure that the text part is generated first. Otherwise the text
|
70
70
|
# can end up containing CSS rules.
|
71
|
-
generate_text_part
|
71
|
+
generate_text_part if generate_text_part?
|
72
72
|
|
73
73
|
Mail::Part.new(
|
74
|
+
content_transfer_encoding: html_part.content_transfer_encoding,
|
74
75
|
content_type: "text/html; charset=#{html_part.charset}",
|
75
76
|
body: premailer.to_inline_css)
|
76
77
|
end
|
77
78
|
|
78
79
|
def generate_text_part
|
79
80
|
@text_part ||= Mail::Part.new(
|
81
|
+
content_transfer_encoding: html_part.content_transfer_encoding,
|
80
82
|
content_type: "text/plain; charset=#{html_part.charset}",
|
81
83
|
body: premailer.to_plain_text)
|
82
84
|
end
|
@@ -39,6 +39,15 @@ describe Premailer::Rails::CSSHelper do
|
|
39
39
|
expect(css_for_doc(doc)).to eq("content of base.css\ncontent of font.css")
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
context 'when HTML contains ignored links' do
|
44
|
+
let(:files) { ['ignore.css', 'data-premailer' => 'ignore'] }
|
45
|
+
|
46
|
+
it 'ignores links' do
|
47
|
+
expect(Premailer::Rails::CSSHelper).to_not receive(:css_for_url)
|
48
|
+
css_for_doc(doc)
|
49
|
+
end
|
50
|
+
end
|
42
51
|
end
|
43
52
|
|
44
53
|
describe '#css_for_url' do
|
@@ -43,6 +43,17 @@ describe Premailer::Rails::Hook do
|
|
43
43
|
expect(processed_message.parts).to match_array(expected_parts)
|
44
44
|
end
|
45
45
|
|
46
|
+
describe 'when the content-transfer-encoding is set' do
|
47
|
+
before { message.content_transfer_encoding = 'quoted-printable' }
|
48
|
+
|
49
|
+
it 'should maintain the value' do
|
50
|
+
expect(processed_message.parts.first.content_transfer_encoding).to \
|
51
|
+
eq 'quoted-printable'
|
52
|
+
expect(processed_message.parts.last.content_transfer_encoding).to \
|
53
|
+
eq 'quoted-printable'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
46
57
|
it 'generates a text part from the html' do
|
47
58
|
expect { run_hook(message) }.to change(message, :text_part)
|
48
59
|
end
|
@@ -18,17 +18,21 @@ module Fixtures
|
|
18
18
|
</html>
|
19
19
|
HTML
|
20
20
|
|
21
|
-
LINK =
|
22
|
-
<link rel='stylesheet' href='%s' />
|
23
|
-
LINK
|
21
|
+
LINK = "<link rel='stylesheet' %s />\n"
|
24
22
|
|
25
23
|
def with_css_links(*files)
|
24
|
+
opts = files.last.is_a?(Hash) ? files.pop : {}
|
26
25
|
links = []
|
27
26
|
files.each do |file|
|
28
|
-
|
27
|
+
attrs = { href: "http://example.com/#{file}" }.merge(opts)
|
28
|
+
links << LINK % hash_to_attributes(attrs)
|
29
29
|
end
|
30
30
|
|
31
31
|
TEMPLATE % links.join
|
32
32
|
end
|
33
|
+
|
34
|
+
def hash_to_attributes(attrs)
|
35
|
+
attrs.map { |attr, value| "#{attr}='#{value}'" }.join(' ')
|
36
|
+
end
|
33
37
|
end
|
34
38
|
end
|
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.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipe Fatio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: premailer
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- example/app/assets/stylesheets/email.css
|
135
135
|
- example/app/mailers/example_mailer.rb
|
136
136
|
- example/app/views/example_mailer/test_message.html.erb
|
137
|
+
- example/bin/rails
|
137
138
|
- example/config.ru
|
138
139
|
- example/config/application.rb
|
139
140
|
- example/config/boot.rb
|
@@ -198,6 +199,7 @@ test_files:
|
|
198
199
|
- example/app/assets/stylesheets/email.css
|
199
200
|
- example/app/mailers/example_mailer.rb
|
200
201
|
- example/app/views/example_mailer/test_message.html.erb
|
202
|
+
- example/bin/rails
|
201
203
|
- example/config.ru
|
202
204
|
- example/config/application.rb
|
203
205
|
- example/config/boot.rb
|