premailer-rails 1.7.0 → 1.8.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 +4 -4
- data/.travis.yml +3 -1
- data/CHANGELOG.md +6 -0
- data/README.md +5 -0
- data/VERSION +1 -1
- data/lib/premailer/rails.rb +8 -5
- data/lib/premailer/rails/railtie.rb +9 -0
- data/premailer-rails.gemspec +1 -1
- data/spec/integration/css_helper_spec.rb +12 -12
- data/spec/integration/hook_registration_spec.rb +1 -5
- data/spec/spec_helper.rb +0 -5
- data/spec/support/stubs/rails.rb +12 -0
- data/spec/unit/css_loaders/asset_pipeline_loader_spec.rb +3 -3
- data/spec/unit/customized_premailer_spec.rb +7 -7
- data/spec/unit/premailer_rails_spec.rb +10 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1acf912800a7228a1dcf6b89f5412ee87490f975
|
4
|
+
data.tar.gz: 2ab5e6bf63b3d7a0fa974b5495df7919eaeb9d10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: feef5aa13b18d39709bf2f9fd931eecff8876a11bf3500199f91c2ba06e15853d60787984425371b51ef4fbc60c555a7b8df38ab0e108e4c4766e4e624fba52b
|
7
|
+
data.tar.gz: dc7c3b13551d5445c58998154a342d79f2b4e0d56fd4b909d1264df3d0511e958d03bbd475f98a387c3c8bdec23fcead519c7a60ac150dff7955f78da46bb884
|
data/.travis.yml
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
language: ruby
|
2
|
+
before_install:
|
3
|
+
- gem install bundler
|
2
4
|
cache: bundler
|
3
5
|
script: "bundle exec rspec"
|
4
6
|
rvm:
|
@@ -7,7 +9,7 @@ rvm:
|
|
7
9
|
- 1.9.3
|
8
10
|
- ruby-head
|
9
11
|
- jruby-19mode
|
10
|
-
- rbx-2
|
12
|
+
- rbx-2
|
11
13
|
env:
|
12
14
|
- "ACTION_MAILER_VERSION=3.1.0"
|
13
15
|
- "ACTION_MAILER_VERSION=3.2.0"
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v1.8.0
|
4
|
+
|
5
|
+
- `ActionMailer` interceptors are registered after Rails initialization and no
|
6
|
+
longer when loading this gem. If you were using this gem outside Rails, you'll
|
7
|
+
need to call `Premailer::Rails.register_interceptors` manually.
|
8
|
+
|
3
9
|
## v1.7.0
|
4
10
|
|
5
11
|
- Register preview hook for the new previewing functionality introduced in
|
data/README.md
CHANGED
@@ -117,6 +117,11 @@ the config `:generate_text_part` to false.
|
|
117
117
|
Note that the options `:with_html_string` and `:css_string` are used internally
|
118
118
|
by premailer-rails and thus will be overridden.
|
119
119
|
|
120
|
+
If you're using this gem outside of Rails, you'll need to call
|
121
|
+
`Premailer::Rails.register_interceptors` manually in order for it to work. This
|
122
|
+
is done ideally in some kind of initializer, depending on the framework you're
|
123
|
+
using.
|
124
|
+
|
120
125
|
## Usage
|
121
126
|
|
122
127
|
premailer-rails processes all outgoing emails by default. If you wish to skip
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.8.0
|
data/lib/premailer/rails.rb
CHANGED
@@ -6,6 +6,7 @@ require 'premailer/rails/css_loaders'
|
|
6
6
|
require 'premailer/rails/css_helper'
|
7
7
|
require 'premailer/rails/customized_premailer'
|
8
8
|
require 'premailer/rails/hook'
|
9
|
+
require 'premailer/rails/railtie' if defined?(Rails)
|
9
10
|
|
10
11
|
class Premailer
|
11
12
|
module Rails
|
@@ -16,11 +17,13 @@ class Premailer
|
|
16
17
|
class << self
|
17
18
|
attr_accessor :config
|
18
19
|
end
|
19
|
-
end
|
20
|
-
end
|
21
20
|
|
22
|
-
|
21
|
+
def self.register_interceptors
|
22
|
+
ActionMailer::Base.register_interceptor(Premailer::Rails::Hook)
|
23
23
|
|
24
|
-
if ActionMailer::Base.respond_to?(:register_preview_interceptor)
|
25
|
-
|
24
|
+
if ActionMailer::Base.respond_to?(:register_preview_interceptor)
|
25
|
+
ActionMailer::Base.register_preview_interceptor(Premailer::Rails::Hook)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
26
29
|
end
|
data/premailer-rails.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency 'premailer', '~> 1.7', '>= 1.7.9'
|
24
24
|
s.add_dependency 'actionmailer', '>= 3', '< 5'
|
25
25
|
|
26
|
-
s.add_development_dependency 'rspec', '
|
26
|
+
s.add_development_dependency 'rspec', '~> 3.0.0'
|
27
27
|
s.add_development_dependency 'nokogiri'
|
28
28
|
s.add_development_dependency 'hpricot' unless RUBY_PLATFORM == 'java'
|
29
29
|
s.add_development_dependency 'coveralls' if RUBY_ENGINE == 'ruby'
|
@@ -26,7 +26,7 @@ describe Premailer::Rails::CSSHelper do
|
|
26
26
|
context 'when HTML contains linked CSS files' do
|
27
27
|
let(:files) { %w[ stylesheets/base.css stylesheets/font.css ] }
|
28
28
|
|
29
|
-
it '
|
29
|
+
it 'returns the content of both files concatenated' do
|
30
30
|
allow(Premailer::Rails::CSSHelper).to \
|
31
31
|
receive(:load_css)
|
32
32
|
.with('http://example.com/stylesheets/base.css')
|
@@ -43,7 +43,7 @@ describe Premailer::Rails::CSSHelper do
|
|
43
43
|
|
44
44
|
describe '#load_css' do
|
45
45
|
context 'when path is a url' do
|
46
|
-
it '
|
46
|
+
it 'loads the CSS at the local path' do
|
47
47
|
expect_file('public/stylesheets/base.css')
|
48
48
|
|
49
49
|
load_css('http://example.com/stylesheets/base.css?test')
|
@@ -51,14 +51,14 @@ describe Premailer::Rails::CSSHelper do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
context 'when path is a relative url' do
|
54
|
-
it '
|
54
|
+
it 'loads the CSS at the local path' do
|
55
55
|
expect_file('public/stylesheets/base.css')
|
56
56
|
load_css('/stylesheets/base.css?test')
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'when file is cached' do
|
61
|
-
it '
|
61
|
+
it 'returns the cached value' do
|
62
62
|
cache =
|
63
63
|
Premailer::Rails::CSSHelper.send(:instance_variable_get, '@cache')
|
64
64
|
cache['http://example.com/stylesheets/base.css'] = 'content of base.css'
|
@@ -69,7 +69,7 @@ describe Premailer::Rails::CSSHelper do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
context 'when in development mode' do
|
72
|
-
it '
|
72
|
+
it 'does not return cached values' do
|
73
73
|
cache =
|
74
74
|
Premailer::Rails::CSSHelper.send(:instance_variable_get, '@cache')
|
75
75
|
cache['http://example.com/stylesheets/base.css'] =
|
@@ -88,7 +88,7 @@ describe Premailer::Rails::CSSHelper do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
context 'and a precompiled file exists' do
|
91
|
-
it '
|
91
|
+
it 'returns that file' do
|
92
92
|
path = '/assets/email-digest.css'
|
93
93
|
content = 'read from file'
|
94
94
|
expect_file("public#{path}", content)
|
@@ -96,7 +96,7 @@ describe Premailer::Rails::CSSHelper do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
it '
|
99
|
+
it 'returns the content of the file compiled by Rails' do
|
100
100
|
expect(Rails.application.assets).to \
|
101
101
|
receive(:find_asset)
|
102
102
|
.with('base.css')
|
@@ -106,7 +106,7 @@ describe Premailer::Rails::CSSHelper do
|
|
106
106
|
eq('content of base.css')
|
107
107
|
end
|
108
108
|
|
109
|
-
it '
|
109
|
+
it 'returns same file when path contains file fingerprint' do
|
110
110
|
expect(Rails.application.assets).to \
|
111
111
|
receive(:find_asset)
|
112
112
|
.with('base.css')
|
@@ -136,19 +136,19 @@ describe Premailer::Rails::CSSHelper do
|
|
136
136
|
receive(:get).with(uri_satisfaction).and_return(response)
|
137
137
|
end
|
138
138
|
|
139
|
-
it '
|
139
|
+
it 'requests the file' do
|
140
140
|
expect(load_css(url)).to eq('content of base.css')
|
141
141
|
end
|
142
142
|
|
143
143
|
context 'when file url does not include the host' do
|
144
|
-
it '
|
144
|
+
it 'requests the file using the asset host as host' do
|
145
145
|
expect(load_css(path)).to eq('content of base.css')
|
146
146
|
end
|
147
147
|
|
148
148
|
context 'and the asset host uses protocol relative scheme' do
|
149
149
|
let(:asset_host) { '//assets.example.com' }
|
150
150
|
|
151
|
-
it '
|
151
|
+
it 'requests the file using http as the scheme' do
|
152
152
|
expect(load_css(path)).to eq('content of base.css')
|
153
153
|
end
|
154
154
|
end
|
@@ -157,7 +157,7 @@ describe Premailer::Rails::CSSHelper do
|
|
157
157
|
end
|
158
158
|
|
159
159
|
context 'when static stylesheets are used' do
|
160
|
-
it '
|
160
|
+
it 'returns the content of the static file' do
|
161
161
|
content = 'content of base.css'
|
162
162
|
expect_file('public/stylesheets/base.css', content)
|
163
163
|
loaded_content = load_css('http://example.com/stylesheets/base.css')
|
@@ -1,13 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'ActionMailer::Base.register_interceptor' do
|
4
|
-
it 'registers
|
4
|
+
it 'registers interceptors' do
|
5
5
|
expect(ActionMailer::Base).to \
|
6
6
|
receive(:register_interceptor).with(Premailer::Rails::Hook)
|
7
|
-
load 'premailer/rails.rb'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'registers preview interceptor' do
|
11
7
|
expect(ActionMailer::Base).to \
|
12
8
|
receive(:register_preview_interceptor).with(Premailer::Rails::Hook)
|
13
9
|
load 'premailer/rails.rb'
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/stubs/rails.rb
CHANGED
@@ -14,17 +14,17 @@ describe Premailer::Rails::CSSLoaders::AssetPipelineLoader do
|
|
14
14
|
|
15
15
|
context "when asset file path contains prefix" do
|
16
16
|
let(:asset) { '/assets/application.css' }
|
17
|
-
it {
|
17
|
+
it { is_expected.to eq('application.css') }
|
18
18
|
end
|
19
19
|
|
20
20
|
context "when asset file path contains fingerprint" do
|
21
21
|
let(:asset) { 'application-6776f581a4329e299531e1d52aa59832.css' }
|
22
|
-
it {
|
22
|
+
it { is_expected.to eq('application.css') }
|
23
23
|
end
|
24
24
|
|
25
25
|
context "when asset file page contains numbers, but not a fingerprint" do
|
26
26
|
let(:asset) { 'test/20130708152545-foo-bar.css' }
|
27
|
-
it {
|
27
|
+
it { is_expected.to eq("test/20130708152545-foo-bar.css") }
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -8,7 +8,7 @@ describe Premailer::Rails::CustomizedPremailer do
|
|
8
8
|
before { allow(Premailer::Adapter).to receive(:use).and_return(adapter) }
|
9
9
|
|
10
10
|
describe '#to_plain_text' do
|
11
|
-
it '
|
11
|
+
it 'includes the text from the HTML part' do
|
12
12
|
premailer =
|
13
13
|
Premailer::Rails::CustomizedPremailer
|
14
14
|
.new(Fixtures::Message::HTML_PART)
|
@@ -21,7 +21,7 @@ describe Premailer::Rails::CustomizedPremailer do
|
|
21
21
|
let(:regex) { %r{<p style=("|')color: ?red;?\1>} }
|
22
22
|
|
23
23
|
context 'when inline CSS block present' do
|
24
|
-
it '
|
24
|
+
it 'returns the HTML with the CSS inlined' do
|
25
25
|
allow(Premailer::Rails::CSSHelper).to \
|
26
26
|
receive(:css_for_doc).and_return('p { color: red; }')
|
27
27
|
html = Fixtures::Message::HTML_PART
|
@@ -31,7 +31,7 @@ describe Premailer::Rails::CustomizedPremailer do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'when CSS is loaded externally' do
|
34
|
-
it '
|
34
|
+
it 'returns the HTML with the CSS inlined' do
|
35
35
|
html = Fixtures::Message::HTML_PART_WITH_CSS
|
36
36
|
premailer = Premailer::Rails::CustomizedPremailer.new(html)
|
37
37
|
expect(premailer.to_inline_css).to match(regex)
|
@@ -39,7 +39,7 @@ describe Premailer::Rails::CustomizedPremailer do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
context 'when HTML contains unicode' do
|
42
|
-
it '
|
42
|
+
it 'does not mess those up' do
|
43
43
|
html = Fixtures::Message::HTML_PART_WITH_UNICODE
|
44
44
|
premailer = Premailer::Rails::CustomizedPremailer.new(html)
|
45
45
|
expect(premailer.to_inline_css).to \
|
@@ -51,18 +51,18 @@ describe Premailer::Rails::CustomizedPremailer do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe '.new' do
|
54
|
-
it '
|
54
|
+
it 'extracts the CSS' do
|
55
55
|
expect(Premailer::Rails::CSSHelper).to receive(:css_for_doc)
|
56
56
|
Premailer::Rails::CustomizedPremailer.new('some html')
|
57
57
|
end
|
58
58
|
|
59
|
-
it '
|
59
|
+
it 'passes on the configs' do
|
60
60
|
Premailer::Rails.config.merge!(foo: :bar)
|
61
61
|
premailer = Premailer::Rails::CustomizedPremailer.new('some html')
|
62
62
|
expect(premailer.instance_variable_get(:'@options')[:foo]).to eq(:bar)
|
63
63
|
end
|
64
64
|
|
65
|
-
it '
|
65
|
+
it 'does not allow to override with_html_string' do
|
66
66
|
Premailer::Rails.config.merge!(with_html_string: false)
|
67
67
|
premailer = Premailer::Rails::CustomizedPremailer.new('some html')
|
68
68
|
options = premailer.instance_variable_get(:'@options')
|
@@ -4,8 +4,16 @@ describe Premailer::Rails do
|
|
4
4
|
describe '#config' do
|
5
5
|
subject { Premailer::Rails.config }
|
6
6
|
context 'when set' do
|
7
|
-
|
8
|
-
|
7
|
+
around do |example|
|
8
|
+
begin
|
9
|
+
default_config = described_class.config
|
10
|
+
described_class.config = { foo: :bar }
|
11
|
+
example.run
|
12
|
+
ensure
|
13
|
+
described_class.config = default_config
|
14
|
+
end
|
15
|
+
end
|
16
|
+
it { is_expected.to eq(foo: :bar) }
|
9
17
|
end
|
10
18
|
end
|
11
19
|
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.
|
4
|
+
version: 1.8.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: 2014-
|
11
|
+
date: 2014-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: premailer
|
@@ -54,16 +54,16 @@ dependencies:
|
|
54
54
|
name: rspec
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - "
|
57
|
+
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 3.0.0
|
59
|
+
version: 3.0.0
|
60
60
|
type: :development
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - "
|
64
|
+
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 3.0.0
|
66
|
+
version: 3.0.0
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: nokogiri
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/premailer/rails/css_loaders/network_loader.rb
|
152
152
|
- lib/premailer/rails/customized_premailer.rb
|
153
153
|
- lib/premailer/rails/hook.rb
|
154
|
+
- lib/premailer/rails/railtie.rb
|
154
155
|
- lib/premailer/rails/version.rb
|
155
156
|
- premailer-rails.gemspec
|
156
157
|
- spec/integration/css_helper_spec.rb
|
@@ -183,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
184
|
version: '0'
|
184
185
|
requirements: []
|
185
186
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.2.
|
187
|
+
rubygems_version: 2.2.2
|
187
188
|
signing_key:
|
188
189
|
specification_version: 4
|
189
190
|
summary: Easily create styled HTML emails in Rails.
|
@@ -199,4 +200,3 @@ test_files:
|
|
199
200
|
- spec/unit/css_loaders/asset_pipeline_loader_spec.rb
|
200
201
|
- spec/unit/customized_premailer_spec.rb
|
201
202
|
- spec/unit/premailer_rails_spec.rb
|
202
|
-
has_rdoc:
|