premailer-rails-revived 1.12.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 +7 -0
- data/.coveralls.yml +1 -0
- data/.github/workflows/build.yml +43 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +165 -0
- data/Gemfile +28 -0
- data/LICENSE +14 -0
- data/README.md +180 -0
- data/Rakefile +7 -0
- data/VERSION +1 -0
- data/example/.gitignore +16 -0
- data/example/Gemfile +10 -0
- data/example/README.md +10 -0
- data/example/Rakefile +6 -0
- data/example/app/assets/stylesheets/email.css +32 -0
- data/example/app/mailers/example_mailer.rb +7 -0
- data/example/app/views/example_mailer/test_message.html.erb +18 -0
- data/example/bin/rails +4 -0
- data/example/config/application.rb +12 -0
- data/example/config/boot.rb +3 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +9 -0
- data/example/config/environments/production.rb +9 -0
- data/example/config/initializers/assets.rb +2 -0
- data/example/config/routes.rb +3 -0
- data/example/config/secrets.yml +2 -0
- data/example/config.ru +4 -0
- data/example/test/mailers/previews/example_mailer_preview.rb +5 -0
- data/lib/premailer/rails/css_helper.rb +70 -0
- data/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb +36 -0
- data/lib/premailer/rails/css_loaders/file_system_loader.rb +37 -0
- data/lib/premailer/rails/css_loaders/network_loader.rb +39 -0
- data/lib/premailer/rails/css_loaders/propshaft_loader.rb +33 -0
- data/lib/premailer/rails/css_loaders.rb +6 -0
- data/lib/premailer/rails/customized_premailer.rb +20 -0
- data/lib/premailer/rails/hook.rb +140 -0
- data/lib/premailer/rails/railtie.rb +9 -0
- data/lib/premailer/rails/version.rb +7 -0
- data/lib/premailer/rails.rb +31 -0
- data/premailer-rails.gemspec +32 -0
- data/spec/integration/css_helper_spec.rb +192 -0
- data/spec/integration/delivery_spec.rb +13 -0
- data/spec/integration/hook_spec.rb +163 -0
- data/spec/rails_app/app/assets/config/manifest.js +3 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +3 -0
- data/spec/rails_app/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_app/app/mailers/welcome_mailer.rb +6 -0
- data/spec/rails_app/app/views/layouts/mailer.html.erb +11 -0
- data/spec/rails_app/app/views/welcome_mailer/welcome_email.html.erb +1 -0
- data/spec/rails_app/config/application.rb +16 -0
- data/spec/rails_app/config/boot.rb +5 -0
- data/spec/rails_app/config/environment.rb +2 -0
- data/spec/rails_app/config/environments/test.rb +10 -0
- data/spec/rails_app/config/routes.rb +3 -0
- data/spec/rails_app/config.ru +5 -0
- data/spec/rails_app/log/.keep +0 -0
- data/spec/rails_app/tmp/.keep +0 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/fixtures/html.rb +38 -0
- data/spec/support/fixtures/message.rb +182 -0
- data/spec/unit/css_loaders/asset_pipeline_loader_spec.rb +57 -0
- data/spec/unit/css_loaders/file_system_loader_spec.rb +37 -0
- data/spec/unit/css_loaders/network_loader_spec.rb +58 -0
- data/spec/unit/css_loaders/propshaft_loader_spec.rb +57 -0
- data/spec/unit/customized_premailer_spec.rb +64 -0
- data/spec/unit/premailer_rails_spec.rb +19 -0
- metadata +233 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if ENV["ASSETS_GEM"] == "propshaft"
|
4
|
+
describe Premailer::Rails::CSSLoaders::PropshaftLoader do
|
5
|
+
before do
|
6
|
+
allow(Rails.application)
|
7
|
+
.to receive(:assets).and_return(double(prefix: '/assets'))
|
8
|
+
allow(Rails.configuration).to receive(:relative_url_root).and_return(nil)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".file_name" do
|
12
|
+
subject do
|
13
|
+
described_class.file_name(asset)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when asset file path contains prefix" do
|
17
|
+
let(:asset) { '/assets/application.css' }
|
18
|
+
it { is_expected.to eq('application.css') }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when asset file path contains prefix and relative_url_root is set" do
|
22
|
+
before do
|
23
|
+
allow(Rails.configuration)
|
24
|
+
.to receive(:relative_url_root).and_return('/foo')
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:asset) { '/foo/assets/application.css' }
|
28
|
+
it { is_expected.to eq('application.css') }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when asset file path contains prefix and relative_url_root is set to root" do
|
32
|
+
before do
|
33
|
+
allow(Rails.configuration)
|
34
|
+
.to receive(:relative_url_root).and_return('/')
|
35
|
+
end
|
36
|
+
|
37
|
+
let(:asset) { '/assets/application.css' }
|
38
|
+
it { is_expected.to eq('application.css') }
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when asset file path contains 40 chars fingerprint" do
|
42
|
+
let(:asset) { 'application-6776f581a4329e299531e1d52aa5983284cde312.css' }
|
43
|
+
it { is_expected.to eq('application.css') }
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when asset file path contains 64 chars fingerprint" do
|
47
|
+
let(:asset) { 'application-02275ccb3fd0c11615bbfb11c99ea123ca2287e75045fe7b72cefafb880dad2b.css' }
|
48
|
+
it { is_expected.to eq('application-02275ccb3fd0c11615bbfb11c99ea123ca2287e75045fe7b72cefafb880dad2b.css') }
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when asset file page contains numbers, but not a fingerprint" do
|
52
|
+
let(:asset) { 'test/20130708152545-foo-bar.css' }
|
53
|
+
it { is_expected.to eq("test/20130708152545-foo-bar.css") }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Premailer::Rails::CustomizedPremailer do
|
4
|
+
describe '#to_plain_text' do
|
5
|
+
it 'includes the text from the HTML part' do
|
6
|
+
premailer =
|
7
|
+
Premailer::Rails::CustomizedPremailer
|
8
|
+
.new(Fixtures::Message::HTML_PART)
|
9
|
+
expect(premailer.to_plain_text.gsub(/\s/, ' ').strip).to \
|
10
|
+
eq(Fixtures::Message::TEXT_PART.gsub(/\s/, ' ').strip)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#to_inline_css' do
|
15
|
+
let(:regex) { %r{<p style=("|')color: ?red;?\1>} }
|
16
|
+
|
17
|
+
context 'when inline CSS block present' do
|
18
|
+
it 'returns the HTML with the CSS inlined' do
|
19
|
+
allow(Premailer::Rails::CSSHelper).to \
|
20
|
+
receive(:css_for_doc).and_return('p { color: red; }')
|
21
|
+
html = Fixtures::Message::HTML_PART
|
22
|
+
premailer = Premailer::Rails::CustomizedPremailer.new(html)
|
23
|
+
expect(premailer.to_inline_css).to match(regex)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when CSS is loaded externally' do
|
28
|
+
it 'returns the HTML with the CSS inlined' do
|
29
|
+
html = Fixtures::Message::HTML_PART_WITH_CSS
|
30
|
+
premailer = Premailer::Rails::CustomizedPremailer.new(html)
|
31
|
+
expect(premailer.to_inline_css).to match(regex)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when HTML contains unicode' do
|
36
|
+
it 'does not mess those up' do
|
37
|
+
html = Fixtures::Message::HTML_PART_WITH_UNICODE
|
38
|
+
premailer = Premailer::Rails::CustomizedPremailer.new(html)
|
39
|
+
expect(premailer.to_inline_css).to \
|
40
|
+
include(Fixtures::Message::UNICODE_STRING)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '.new' do
|
46
|
+
it 'extracts the CSS' do
|
47
|
+
expect(Premailer::Rails::CSSHelper).to receive(:css_for_doc)
|
48
|
+
Premailer::Rails::CustomizedPremailer.new('some html')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'passes on the configs' do
|
52
|
+
Premailer::Rails.config.merge!(foo: :bar)
|
53
|
+
premailer = Premailer::Rails::CustomizedPremailer.new('some html')
|
54
|
+
expect(premailer.instance_variable_get(:'@options')[:foo]).to eq(:bar)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'does not allow to override with_html_string' do
|
58
|
+
Premailer::Rails.config.merge!(with_html_string: false)
|
59
|
+
premailer = Premailer::Rails::CustomizedPremailer.new('some html')
|
60
|
+
options = premailer.instance_variable_get(:'@options')
|
61
|
+
expect(options[:with_html_string]).to eq(true)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Premailer::Rails do
|
4
|
+
describe '#config' do
|
5
|
+
subject { Premailer::Rails.config }
|
6
|
+
context 'when set' do
|
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) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,233 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: premailer-rails-revived
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.12.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adrien Siami
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: premailer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.7.9
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.7'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.7.9
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: actionmailer
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.3'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: nokogiri
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: coveralls
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
description: |-
|
90
|
+
This gem brings you the power of the premailer gem to Rails
|
91
|
+
without any configuration needs. Create HTML emails,
|
92
|
+
include a CSS file as you do in a normal HTML document and
|
93
|
+
premailer will inline the included CSS. Forked and revived from the work of fphilipe.
|
94
|
+
email:
|
95
|
+
- adrien@siami.fr
|
96
|
+
executables: []
|
97
|
+
extensions: []
|
98
|
+
extra_rdoc_files: []
|
99
|
+
files:
|
100
|
+
- ".coveralls.yml"
|
101
|
+
- ".github/workflows/build.yml"
|
102
|
+
- ".gitignore"
|
103
|
+
- ".rspec"
|
104
|
+
- CHANGELOG.md
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- VERSION
|
110
|
+
- example/.gitignore
|
111
|
+
- example/Gemfile
|
112
|
+
- example/README.md
|
113
|
+
- example/Rakefile
|
114
|
+
- example/app/assets/stylesheets/email.css
|
115
|
+
- example/app/mailers/example_mailer.rb
|
116
|
+
- example/app/views/example_mailer/test_message.html.erb
|
117
|
+
- example/bin/rails
|
118
|
+
- example/config.ru
|
119
|
+
- example/config/application.rb
|
120
|
+
- example/config/boot.rb
|
121
|
+
- example/config/environment.rb
|
122
|
+
- example/config/environments/development.rb
|
123
|
+
- example/config/environments/production.rb
|
124
|
+
- example/config/initializers/assets.rb
|
125
|
+
- example/config/routes.rb
|
126
|
+
- example/config/secrets.yml
|
127
|
+
- example/test/mailers/previews/example_mailer_preview.rb
|
128
|
+
- lib/premailer/rails.rb
|
129
|
+
- lib/premailer/rails/css_helper.rb
|
130
|
+
- lib/premailer/rails/css_loaders.rb
|
131
|
+
- lib/premailer/rails/css_loaders/asset_pipeline_loader.rb
|
132
|
+
- lib/premailer/rails/css_loaders/file_system_loader.rb
|
133
|
+
- lib/premailer/rails/css_loaders/network_loader.rb
|
134
|
+
- lib/premailer/rails/css_loaders/propshaft_loader.rb
|
135
|
+
- lib/premailer/rails/customized_premailer.rb
|
136
|
+
- lib/premailer/rails/hook.rb
|
137
|
+
- lib/premailer/rails/railtie.rb
|
138
|
+
- lib/premailer/rails/version.rb
|
139
|
+
- premailer-rails.gemspec
|
140
|
+
- spec/integration/css_helper_spec.rb
|
141
|
+
- spec/integration/delivery_spec.rb
|
142
|
+
- spec/integration/hook_spec.rb
|
143
|
+
- spec/rails_app/app/assets/config/manifest.js
|
144
|
+
- spec/rails_app/app/assets/stylesheets/application.css
|
145
|
+
- spec/rails_app/app/mailers/application_mailer.rb
|
146
|
+
- spec/rails_app/app/mailers/welcome_mailer.rb
|
147
|
+
- spec/rails_app/app/views/layouts/mailer.html.erb
|
148
|
+
- spec/rails_app/app/views/welcome_mailer/welcome_email.html.erb
|
149
|
+
- spec/rails_app/config.ru
|
150
|
+
- spec/rails_app/config/application.rb
|
151
|
+
- spec/rails_app/config/boot.rb
|
152
|
+
- spec/rails_app/config/environment.rb
|
153
|
+
- spec/rails_app/config/environments/test.rb
|
154
|
+
- spec/rails_app/config/routes.rb
|
155
|
+
- spec/rails_app/log/.keep
|
156
|
+
- spec/rails_app/tmp/.keep
|
157
|
+
- spec/spec_helper.rb
|
158
|
+
- spec/support/fixtures/html.rb
|
159
|
+
- spec/support/fixtures/message.rb
|
160
|
+
- spec/unit/css_loaders/asset_pipeline_loader_spec.rb
|
161
|
+
- spec/unit/css_loaders/file_system_loader_spec.rb
|
162
|
+
- spec/unit/css_loaders/network_loader_spec.rb
|
163
|
+
- spec/unit/css_loaders/propshaft_loader_spec.rb
|
164
|
+
- spec/unit/customized_premailer_spec.rb
|
165
|
+
- spec/unit/premailer_rails_spec.rb
|
166
|
+
homepage: https://github.com/Intrepidd/premailer-rails
|
167
|
+
licenses:
|
168
|
+
- MIT
|
169
|
+
metadata:
|
170
|
+
changelog_uri: https://github.com/Intrepidd/premailer-rails/blob/v1.12.0/CHANGELOG.md
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
185
|
+
requirements: []
|
186
|
+
rubygems_version: 3.2.32
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: 'Forked and revived: Easily create styled HTML emails in Rails.'
|
190
|
+
test_files:
|
191
|
+
- example/Gemfile
|
192
|
+
- example/README.md
|
193
|
+
- example/Rakefile
|
194
|
+
- example/app/assets/stylesheets/email.css
|
195
|
+
- example/app/mailers/example_mailer.rb
|
196
|
+
- example/app/views/example_mailer/test_message.html.erb
|
197
|
+
- example/bin/rails
|
198
|
+
- example/config.ru
|
199
|
+
- example/config/application.rb
|
200
|
+
- example/config/boot.rb
|
201
|
+
- example/config/environment.rb
|
202
|
+
- example/config/environments/development.rb
|
203
|
+
- example/config/environments/production.rb
|
204
|
+
- example/config/initializers/assets.rb
|
205
|
+
- example/config/routes.rb
|
206
|
+
- example/config/secrets.yml
|
207
|
+
- example/test/mailers/previews/example_mailer_preview.rb
|
208
|
+
- spec/integration/css_helper_spec.rb
|
209
|
+
- spec/integration/delivery_spec.rb
|
210
|
+
- spec/integration/hook_spec.rb
|
211
|
+
- spec/rails_app/app/assets/config/manifest.js
|
212
|
+
- spec/rails_app/app/assets/stylesheets/application.css
|
213
|
+
- spec/rails_app/app/mailers/application_mailer.rb
|
214
|
+
- spec/rails_app/app/mailers/welcome_mailer.rb
|
215
|
+
- spec/rails_app/app/views/layouts/mailer.html.erb
|
216
|
+
- spec/rails_app/app/views/welcome_mailer/welcome_email.html.erb
|
217
|
+
- spec/rails_app/config.ru
|
218
|
+
- spec/rails_app/config/application.rb
|
219
|
+
- spec/rails_app/config/boot.rb
|
220
|
+
- spec/rails_app/config/environment.rb
|
221
|
+
- spec/rails_app/config/environments/test.rb
|
222
|
+
- spec/rails_app/config/routes.rb
|
223
|
+
- spec/rails_app/log/.keep
|
224
|
+
- spec/rails_app/tmp/.keep
|
225
|
+
- spec/spec_helper.rb
|
226
|
+
- spec/support/fixtures/html.rb
|
227
|
+
- spec/support/fixtures/message.rb
|
228
|
+
- spec/unit/css_loaders/asset_pipeline_loader_spec.rb
|
229
|
+
- spec/unit/css_loaders/file_system_loader_spec.rb
|
230
|
+
- spec/unit/css_loaders/network_loader_spec.rb
|
231
|
+
- spec/unit/css_loaders/propshaft_loader_spec.rb
|
232
|
+
- spec/unit/customized_premailer_spec.rb
|
233
|
+
- spec/unit/premailer_rails_spec.rb
|