premailer-rails 1.10.2 → 1.11.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
  SHA256:
3
- metadata.gz: 483c734faf06020e78195069fb6db136527c24b2d725320aec5aa66e608a013f
4
- data.tar.gz: 6c34682ffa25c13678928467a465f1a9a1e367fd70e783067a2d3c3c3b6c81f2
3
+ metadata.gz: 13055f85c556422022c71564c81f5816ecffd482e4514c1481212fab2c942eb7
4
+ data.tar.gz: 8b9093f66f195ac826382329877be7c9b863650c5bcb0c057bae0cc073b8978d
5
5
  SHA512:
6
- metadata.gz: f26c083fc1f290c83779645ba7347fb54b497aeff4e1d96055457ec9e399b36ae9035773dbe9ef38a9a2e60a7f684ac9ae682332f498215e4f863cdea48d82c4
7
- data.tar.gz: d4c906d184d1e3e3c1925324193a2c535365e11345bb460a4094a423f26d2be66f0efe6b8182bdd73068902d9162cfa26c7de65e1fb6ae4d1e4a989960ecd00d
6
+ metadata.gz: a861465e80d026c7e221b09f0c395be4d4fb26fa3662a233de5ba8295c41f0861b79958f873830fa4bd6333bd21798298155f8cadf1cf7861f08f5348ee3f901
7
+ data.tar.gz: f4cd1b29b3b1a4ee43fe83971b35b6a43896298ab3c1fec8d4fc91e2fc0d1290b353bba0096e2ae45376e394f6ad00142cf3dda7447a72259c7639c01fbd4231
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.4.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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.11.1
4
+
5
+ - Check if `Rails.application` is defined (@pabloh, #250)
6
+
7
+ ## v1.11.0
8
+
9
+ - Remove `force_encoding!`
10
+
11
+ ## v1.10.3
12
+
13
+ - Remove upper version constraint for actionmailer
14
+
3
15
  ## v1.10.2
4
16
 
5
17
  - Explicitly check for assets_manifest (@derekwheel, #214)
data/README.md CHANGED
@@ -179,7 +179,7 @@ premailer-rails is released under the MIT license. See the [license file].
179
179
  [actionmailer]: https://github.com/rails/rails/tree/master/actionmailer
180
180
  [nokogiri]: https://github.com/sparklemotion/nokogiri
181
181
 
182
- [premailer documentation]: http://rubydoc.info/gems/premailer/1.7.3/Premailer:initialize
182
+ [premailer documentation]: https://www.rubydoc.info/gems/premailer/Premailer:initialize
183
183
 
184
184
  [fphilipe twitter]: https://twitter.com/fphilipe
185
185
  [license file]: LICENSE
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.10.2
1
+ 1.11.1
@@ -39,13 +39,13 @@ class Premailer
39
39
  end
40
40
 
41
41
  def cache_enabled?
42
- defined?(::Rails) && ::Rails.env.production?
42
+ defined?(::Rails.env) && ::Rails.env.production?
43
43
  end
44
44
 
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.}
@@ -25,6 +25,7 @@ class Premailer
25
25
 
26
26
  def asset_pipeline_present?
27
27
  defined?(::Rails) &&
28
+ ::Rails.respond_to?(:application) &&
28
29
  ::Rails.application &&
29
30
  ::Rails.application.respond_to?(:assets_manifest) &&
30
31
  ::Rails.application.assets_manifest
@@ -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
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.require_paths = ["lib"]
23
23
 
24
24
  s.add_dependency 'premailer', '~> 1.7', '>= 1.7.9'
25
- s.add_dependency 'actionmailer', '>= 3', '< 6'
25
+ s.add_dependency 'actionmailer', '>= 3'
26
26
 
27
27
  s.add_development_dependency 'rspec', '~> 3.3'
28
28
  s.add_development_dependency 'nokogiri'
@@ -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.2
4
+ version: 1.11.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: 2018-03-15 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: premailer
@@ -37,9 +37,6 @@ dependencies:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '3'
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: '6'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,9 +44,6 @@ dependencies:
47
44
  - - ">="
48
45
  - !ruby/object:Gem::Version
49
46
  version: '3'
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: '6'
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: rspec
55
49
  requirement: !ruby/object:Gem::Requirement
@@ -158,6 +152,8 @@ files:
158
152
  - spec/rails_app/config/environments/test.rb
159
153
  - spec/rails_app/config/initializers/assets.rb
160
154
  - spec/rails_app/config/routes.rb
155
+ - spec/rails_app/log/.keep
156
+ - spec/rails_app/tmp/.keep
161
157
  - spec/spec_helper.rb
162
158
  - spec/support/fixtures/html.rb
163
159
  - spec/support/fixtures/message.rb
@@ -185,8 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
181
  - !ruby/object:Gem::Version
186
182
  version: '0'
187
183
  requirements: []
188
- rubyforge_project:
189
- rubygems_version: 2.7.3
184
+ rubygems_version: 3.1.2
190
185
  signing_key:
191
186
  specification_version: 4
192
187
  summary: Easily create styled HTML emails in Rails.
@@ -224,6 +219,8 @@ test_files:
224
219
  - spec/rails_app/config/environments/test.rb
225
220
  - spec/rails_app/config/initializers/assets.rb
226
221
  - spec/rails_app/config/routes.rb
222
+ - spec/rails_app/log/.keep
223
+ - spec/rails_app/tmp/.keep
227
224
  - spec/spec_helper.rb
228
225
  - spec/support/fixtures/html.rb
229
226
  - spec/support/fixtures/message.rb