premailer-rails 1.5.1 → 1.6.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 +11 -1
- data/CHANGELOG.md +16 -0
- data/Gemfile +10 -0
- data/README.md +82 -40
- data/VERSION +1 -1
- data/lib/premailer/rails.rb +1 -2
- data/lib/premailer/rails/css_helper.rb +8 -20
- data/lib/premailer/rails/css_loaders.rb +4 -63
- data/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb +27 -0
- data/lib/premailer/rails/css_loaders/cache_loader.rb +19 -0
- data/lib/premailer/rails/css_loaders/file_system_loader.rb +15 -0
- data/lib/premailer/rails/css_loaders/network_loader.rb +32 -0
- data/lib/premailer/rails/hook.rb +12 -3
- data/premailer-rails.gemspec +4 -6
- data/spec/integration/css_helper_spec.rb +168 -0
- data/spec/{lib → integration}/hook_registration_spec.rb +2 -3
- data/spec/{lib → integration}/hook_spec.rb +26 -10
- data/spec/spec_helper.rb +17 -5
- data/spec/{fixtures → support/fixtures}/html.rb +0 -8
- data/spec/{fixtures → support/fixtures}/message.rb +0 -0
- data/spec/{stubs → support/stubs}/action_mailer.rb +0 -0
- data/spec/{stubs → support/stubs}/rails.rb +0 -26
- data/spec/unit/css_loaders/asset_pipeline_loader_spec.rb +30 -0
- data/spec/{lib → unit}/customized_premailer_spec.rb +12 -13
- data/spec/{lib/premailer_rails_3_spec.rb → unit/premailer_rails_spec.rb} +0 -0
- metadata +44 -56
- data/spec/lib/css_helper_spec.rb +0 -164
- data/spec/stubs/dummy.rb +0 -5
File without changes
|
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.6.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: 2013-11-
|
11
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: premailer
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.7'
|
20
|
+
- - '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.7.9
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,13 +27,19 @@ dependencies:
|
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.7'
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.7.9
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
34
|
+
name: actionmailer
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - '>='
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '3'
|
40
|
+
- - <
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '5'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,50 +47,25 @@ dependencies:
|
|
38
47
|
- - '>='
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '3'
|
41
|
-
-
|
42
|
-
name: rspec-core
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec-expectations
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
50
|
+
- - <
|
67
51
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
52
|
+
version: '5'
|
69
53
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
54
|
+
name: rspec
|
71
55
|
requirement: !ruby/object:Gem::Requirement
|
72
56
|
requirements:
|
73
57
|
- - '>='
|
74
58
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
59
|
+
version: 3.0.0.beta1
|
76
60
|
type: :development
|
77
61
|
prerelease: false
|
78
62
|
version_requirements: !ruby/object:Gem::Requirement
|
79
63
|
requirements:
|
80
64
|
- - '>='
|
81
65
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
66
|
+
version: 3.0.0.beta1
|
83
67
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
68
|
+
name: nokogiri
|
85
69
|
requirement: !ruby/object:Gem::Requirement
|
86
70
|
requirements:
|
87
71
|
- - '>='
|
@@ -95,7 +79,7 @@ dependencies:
|
|
95
79
|
- !ruby/object:Gem::Version
|
96
80
|
version: '0'
|
97
81
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
82
|
+
name: hpricot
|
99
83
|
requirement: !ruby/object:Gem::Requirement
|
100
84
|
requirements:
|
101
85
|
- - '>='
|
@@ -109,7 +93,7 @@ dependencies:
|
|
109
93
|
- !ruby/object:Gem::Version
|
110
94
|
version: '0'
|
111
95
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
96
|
+
name: coveralls
|
113
97
|
requirement: !ruby/object:Gem::Requirement
|
114
98
|
requirements:
|
115
99
|
- - '>='
|
@@ -146,22 +130,26 @@ files:
|
|
146
130
|
- lib/premailer/rails.rb
|
147
131
|
- lib/premailer/rails/css_helper.rb
|
148
132
|
- lib/premailer/rails/css_loaders.rb
|
133
|
+
- lib/premailer/rails/css_loaders/asset_pipeline_loader.rb
|
134
|
+
- lib/premailer/rails/css_loaders/cache_loader.rb
|
135
|
+
- lib/premailer/rails/css_loaders/file_system_loader.rb
|
136
|
+
- lib/premailer/rails/css_loaders/network_loader.rb
|
149
137
|
- lib/premailer/rails/customized_premailer.rb
|
150
138
|
- lib/premailer/rails/hook.rb
|
151
139
|
- lib/premailer/rails/nokogiri_fix.rb
|
152
140
|
- lib/premailer/rails/version.rb
|
153
141
|
- premailer-rails.gemspec
|
154
|
-
- spec/
|
155
|
-
- spec/
|
156
|
-
- spec/
|
157
|
-
- spec/lib/customized_premailer_spec.rb
|
158
|
-
- spec/lib/hook_registration_spec.rb
|
159
|
-
- spec/lib/hook_spec.rb
|
160
|
-
- spec/lib/premailer_rails_3_spec.rb
|
142
|
+
- spec/integration/css_helper_spec.rb
|
143
|
+
- spec/integration/hook_registration_spec.rb
|
144
|
+
- spec/integration/hook_spec.rb
|
161
145
|
- spec/spec_helper.rb
|
162
|
-
- spec/
|
163
|
-
- spec/
|
164
|
-
- spec/stubs/
|
146
|
+
- spec/support/fixtures/html.rb
|
147
|
+
- spec/support/fixtures/message.rb
|
148
|
+
- spec/support/stubs/action_mailer.rb
|
149
|
+
- spec/support/stubs/rails.rb
|
150
|
+
- spec/unit/css_loaders/asset_pipeline_loader_spec.rb
|
151
|
+
- spec/unit/customized_premailer_spec.rb
|
152
|
+
- spec/unit/premailer_rails_spec.rb
|
165
153
|
homepage: https://github.com/fphilipe/premailer-rails
|
166
154
|
licenses: []
|
167
155
|
metadata: {}
|
@@ -186,15 +174,15 @@ signing_key:
|
|
186
174
|
specification_version: 4
|
187
175
|
summary: Easily create styled HTML emails in Rails.
|
188
176
|
test_files:
|
189
|
-
- spec/
|
190
|
-
- spec/
|
191
|
-
- spec/
|
192
|
-
- spec/lib/customized_premailer_spec.rb
|
193
|
-
- spec/lib/hook_registration_spec.rb
|
194
|
-
- spec/lib/hook_spec.rb
|
195
|
-
- spec/lib/premailer_rails_3_spec.rb
|
177
|
+
- spec/integration/css_helper_spec.rb
|
178
|
+
- spec/integration/hook_registration_spec.rb
|
179
|
+
- spec/integration/hook_spec.rb
|
196
180
|
- spec/spec_helper.rb
|
197
|
-
- spec/
|
198
|
-
- spec/
|
199
|
-
- spec/stubs/
|
181
|
+
- spec/support/fixtures/html.rb
|
182
|
+
- spec/support/fixtures/message.rb
|
183
|
+
- spec/support/stubs/action_mailer.rb
|
184
|
+
- spec/support/stubs/rails.rb
|
185
|
+
- spec/unit/css_loaders/asset_pipeline_loader_spec.rb
|
186
|
+
- spec/unit/customized_premailer_spec.rb
|
187
|
+
- spec/unit/premailer_rails_spec.rb
|
200
188
|
has_rdoc:
|
data/spec/lib/css_helper_spec.rb
DELETED
@@ -1,164 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Premailer::Rails::CSSHelper do
|
4
|
-
# Reset the CSS cache
|
5
|
-
after { Premailer::Rails::CSSHelper.send(:instance_variable_set, '@cache', {}) }
|
6
|
-
|
7
|
-
def load_css(path)
|
8
|
-
Premailer::Rails::CSSHelper.send(:load_css, path)
|
9
|
-
end
|
10
|
-
|
11
|
-
def css_for_doc(doc)
|
12
|
-
Premailer::Rails::CSSHelper.css_for_doc(doc)
|
13
|
-
end
|
14
|
-
|
15
|
-
def expect_file(path, content=nil)
|
16
|
-
File.stubs(:exist?).with(path).returns(true)
|
17
|
-
File.expects(:read).with(path).returns(content)
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#css_for_doc' do
|
21
|
-
let(:html) { Fixtures::HTML.with_css_links(*files) }
|
22
|
-
let(:doc) { Nokogiri(html) }
|
23
|
-
|
24
|
-
context 'when HTML contains linked CSS files' do
|
25
|
-
let(:files) { %w[ stylesheets/base.css stylesheets/font.css ] }
|
26
|
-
|
27
|
-
it 'should return the content of both files concatenated' do
|
28
|
-
Premailer::Rails::CSSHelper
|
29
|
-
.expects(:load_css)
|
30
|
-
.with('http://example.com/stylesheets/base.css')
|
31
|
-
.returns('content of base.css')
|
32
|
-
Premailer::Rails::CSSHelper
|
33
|
-
.expects(:load_css)
|
34
|
-
.with('http://example.com/stylesheets/font.css')
|
35
|
-
.returns('content of font.css')
|
36
|
-
|
37
|
-
css_for_doc(doc).should == "content of base.css\ncontent of font.css"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#load_css' do
|
43
|
-
context 'when path is a url' do
|
44
|
-
it 'should load the CSS at the local path' do
|
45
|
-
expect_file('RAILS_ROOT/public/stylesheets/base.css')
|
46
|
-
|
47
|
-
load_css('http://example.com/stylesheets/base.css?test')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when path is a relative url' do
|
52
|
-
it 'should load the CSS at the local path' do
|
53
|
-
expect_file('RAILS_ROOT/public/stylesheets/base.css')
|
54
|
-
load_css('/stylesheets/base.css?test')
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'when file is cached' do
|
59
|
-
it 'should return the cached value' do
|
60
|
-
cache =
|
61
|
-
Premailer::Rails::CSSHelper.send(:instance_variable_get, '@cache')
|
62
|
-
cache['/stylesheets/base.css'] = 'content of base.css'
|
63
|
-
|
64
|
-
load_css('http://example.com/stylesheets/base.css')
|
65
|
-
.should == 'content of base.css'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when in development mode' do
|
70
|
-
it 'should not return cached values' do
|
71
|
-
cache =
|
72
|
-
Premailer::Rails::CSSHelper.send(:instance_variable_get, '@cache')
|
73
|
-
cache['/stylesheets/base.css'] = 'cached content of base.css'
|
74
|
-
content = 'new content of base.css'
|
75
|
-
expect_file('RAILS_ROOT/public/stylesheets/base.css', content)
|
76
|
-
Rails.env.stubs(:development?).returns(true)
|
77
|
-
|
78
|
-
load_css('http://example.com/stylesheets/base.css').should == content
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when Rails asset pipeline is used' do
|
83
|
-
before {
|
84
|
-
Rails.configuration.stubs(:assets).returns(
|
85
|
-
stub(
|
86
|
-
enabled: true,
|
87
|
-
prefix: '/assets'
|
88
|
-
)
|
89
|
-
)
|
90
|
-
}
|
91
|
-
|
92
|
-
context 'and a precompiled file exists' do
|
93
|
-
it 'should return that file' do
|
94
|
-
path = '/assets/email-digest.css'
|
95
|
-
content = 'read from file'
|
96
|
-
expect_file("RAILS_ROOT/public#{path}", content)
|
97
|
-
load_css(path).should == content
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'should return the content of the file compiled by Rails' do
|
102
|
-
Rails.application.assets
|
103
|
-
.expects(:find_asset)
|
104
|
-
.with('base.css')
|
105
|
-
.returns(mock(to_s: 'content of base.css'))
|
106
|
-
|
107
|
-
load_css('http://example.com/assets/base.css')
|
108
|
-
.should == 'content of base.css'
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'should return same file when path contains file fingerprint' do
|
112
|
-
Rails.application.assets
|
113
|
-
.expects(:find_asset)
|
114
|
-
.with('base.css')
|
115
|
-
.returns(mock(to_s: 'content of base.css'))
|
116
|
-
|
117
|
-
load_css(
|
118
|
-
'http://example.com/assets/base-089e35bd5d84297b8d31ad552e433275.css'
|
119
|
-
).should == 'content of base.css'
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'when asset can not be found' do
|
123
|
-
let(:response) { 'content of base.css' }
|
124
|
-
let(:path) { '/assets/base-089e35bd5d84297b8d31ad552e433275.css' }
|
125
|
-
let(:url) { "http://assets.example.com#{path}" }
|
126
|
-
let(:asset_host) { 'http://assets.example.com' }
|
127
|
-
|
128
|
-
before do
|
129
|
-
Rails.application.assets.stubs(:find_asset).returns(nil)
|
130
|
-
Rails.configuration.stubs(:action_controller).returns(
|
131
|
-
stub(asset_host: asset_host)
|
132
|
-
)
|
133
|
-
Net::HTTP.stubs(:get).with { |uri| uri.to_s == url }.returns(response)
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'should request the file' do
|
137
|
-
load_css(url).should == 'content of base.css'
|
138
|
-
end
|
139
|
-
|
140
|
-
context 'when file url does not include the host' do
|
141
|
-
it 'should request the file using the asset host as host' do
|
142
|
-
load_css(path).should == 'content of base.css'
|
143
|
-
end
|
144
|
-
|
145
|
-
context 'and the asset host uses protocol relative scheme' do
|
146
|
-
let(:asset_host) { '//assets.example.com' }
|
147
|
-
|
148
|
-
it 'should request the file using http as the scheme' do
|
149
|
-
load_css(path).should == 'content of base.css'
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context 'when static stylesheets are used' do
|
157
|
-
it 'should return the content of the static file' do
|
158
|
-
content = 'content of base.css'
|
159
|
-
expect_file('RAILS_ROOT/public/stylesheets/base.css', content)
|
160
|
-
load_css('http://example.com/stylesheets/base.css').should == content
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|