premailer-rails 1.9.0 → 1.9.1

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: 3a6895871c0ec4e4443e1a1d6bf22d9239756659
4
- data.tar.gz: 9143e6f08bc542eb428ac14433bf1b0fb7d5851b
3
+ metadata.gz: 1a4e3c274d320126db1a2edecd52529cae72f3f7
4
+ data.tar.gz: d4a9a0fd22637f82da097b07cf8930827feb5161
5
5
  SHA512:
6
- metadata.gz: 6a72305f6009dee21b9b29dbc06cd4619012606e7b10dc0949abdc45854763aebce9fb5f6c08b0ba50934cdc8cf5c2a03df01f1658f4efbae0c07065695ffbae
7
- data.tar.gz: ce3df301bb6e8a81d46c6ae51bf7d3bc8af5ba9360b60b51b43bb8f68d5f6c75100625e96fc941057f428a9ae1d051580d7f546bdf3e45d71ee8552d40b09aad
6
+ metadata.gz: dc5726488711de669ba671ef6f048ae38b9c1cb44d1be95a8a9728d359d9adf6b1e66a74cfe05d894e8a9fe2b648b82a62317a08e6f5d11d43f5cd486715b87f
7
+ data.tar.gz: 58c425afba99b7996f89e7c9858df716670211beadae82b18e6866de8f141c766771ea9f2d3770d84ebc9b0f66bcb513efd97a614ac2fc53bbcc503c16072efb
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.9.1
4
+
5
+ - Respect data-premailer="ignore" on link tags
6
+ - Ensure content-transfer-encoding is maintained
7
+
3
8
  ## v1.9.0
4
9
 
5
10
  - Improved CSS loading and caching.
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 truethy.
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.0
1
+ 1.9.1
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -26,7 +26,7 @@ class Premailer
26
26
  private
27
27
 
28
28
  def css_urls_in_doc(doc)
29
- doc.search('link[@rel="stylesheet"]').map do |link|
29
+ doc.search('link[@rel="stylesheet"]:not([@data-premailer="ignore"])').map do |link|
30
30
  link.remove
31
31
  link.attributes['href'].to_s
32
32
  end
@@ -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 if 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 = <<-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
- links << LINK % "http://example.com/#{file}"
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.0
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: 2015-12-30 00:00:00.000000000 Z
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