premailer 1.7.1 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/Gemfile +3 -0
- data/LICENSE.rdoc +11 -0
- data/README.rdoc +20 -0
- data/bin/premailer +3 -95
- data/lib/premailer.rb +5 -3
- data/lib/premailer/adapter/hpricot.rb +21 -11
- data/lib/premailer/adapter/nokogiri.rb +18 -17
- data/lib/premailer/executor.rb +96 -0
- data/lib/premailer/html_to_plain_text.rb +26 -6
- data/lib/premailer/premailer.rb +62 -32
- data/local-premailer +9 -0
- data/premailer.gemspec +22 -0
- data/rakefile.rb +69 -0
- data/test/files/base.html +142 -0
- data/test/files/chars.html +6 -0
- data/test/files/contact_bg.png +0 -0
- data/test/files/dialect.png +0 -0
- data/test/files/dots_end.png +0 -0
- data/test/files/dots_h.gif +0 -0
- data/test/files/html4.html +12 -0
- data/test/files/import.css +13 -0
- data/test/files/inc/2009-placeholder.png +0 -0
- data/test/files/iso-8859-2.html +1 -0
- data/test/files/iso-8859-5.html +8 -0
- data/test/files/no_css.html +11 -0
- data/test/files/noimport.css +13 -0
- data/test/files/styles.css +106 -0
- data/test/files/xhtml.html +11 -0
- data/test/future_tests.rb +50 -0
- data/test/helper.rb +7 -0
- data/test/test_adapter.rb +29 -0
- data/test/test_html_to_plain_text.rb +149 -0
- data/test/test_links.rb +141 -0
- data/test/test_misc.rb +233 -0
- data/test/test_premailer.rb +257 -0
- data/test/test_warnings.rb +97 -0
- metadata +109 -13
@@ -0,0 +1,97 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__)) + '/helper'
|
3
|
+
|
4
|
+
class TestWarnings < Test::Unit::TestCase
|
5
|
+
include WEBrick
|
6
|
+
|
7
|
+
def test_element_warnings
|
8
|
+
html = <<END_HTML
|
9
|
+
<!DOCTYPE html>
|
10
|
+
<html>
|
11
|
+
<head><link rel="alternate" href="http://example.com/"></head>
|
12
|
+
<body>
|
13
|
+
<form method="post"> Test </form>
|
14
|
+
</body>
|
15
|
+
</html>
|
16
|
+
END_HTML
|
17
|
+
|
18
|
+
[:nokogiri, :hpricot].each do |adapter|
|
19
|
+
warnings = get_warnings(html, adapter)
|
20
|
+
assert_equal 2, warnings.length
|
21
|
+
assert warnings.any? { |w| w[:message] == 'form HTML element'}
|
22
|
+
assert warnings.any? { |w| w[:message] == 'link HTML element'}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_css_warnings
|
27
|
+
html = <<END_HTML
|
28
|
+
<!DOCTYPE html>
|
29
|
+
<html><body>
|
30
|
+
<div style="margin: 5px; height: 100px;">Test</div>
|
31
|
+
</body></html>
|
32
|
+
END_HTML
|
33
|
+
|
34
|
+
[:nokogiri, :hpricot].each do |adapter|
|
35
|
+
warnings = get_warnings(html, adapter)
|
36
|
+
assert_equal 2, warnings.length
|
37
|
+
assert warnings.any? { |w| w[:message] == 'height CSS property'}
|
38
|
+
assert warnings.any? { |w| w[:message] == 'margin CSS property'}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_css_aliased_warnings
|
43
|
+
html = <<END_HTML
|
44
|
+
<!DOCTYPE html>
|
45
|
+
<html><body>
|
46
|
+
<div style="margin-top: 5px;">Test</div>
|
47
|
+
</body></html>
|
48
|
+
END_HTML
|
49
|
+
|
50
|
+
[:nokogiri, :hpricot].each do |adapter|
|
51
|
+
warnings = get_warnings(html, adapter)
|
52
|
+
assert_equal 1, warnings.length
|
53
|
+
assert warnings.any? { |w| w[:message] == 'margin-top CSS property'}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_attribute_warnings
|
58
|
+
html = <<END_HTML
|
59
|
+
<!DOCTYPE html>
|
60
|
+
<html><body>
|
61
|
+
<img src="#" ismap>
|
62
|
+
</body></html>
|
63
|
+
END_HTML
|
64
|
+
|
65
|
+
[:nokogiri, :hpricot].each do |adapter|
|
66
|
+
warnings = get_warnings(html, adapter)
|
67
|
+
assert_equal 1, warnings.length
|
68
|
+
assert warnings.any? { |w| w[:message] == 'ismap HTML attribute'}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_warn_level
|
73
|
+
html = <<END_HTML
|
74
|
+
<!DOCTYPE html>
|
75
|
+
<html><body>
|
76
|
+
<div style="color: red; font-family: sans-serif;">Test</div>
|
77
|
+
</body></html>
|
78
|
+
END_HTML
|
79
|
+
|
80
|
+
[:nokogiri, :hpricot].each do |adapter|
|
81
|
+
warnings = get_warnings(html, adapter, Premailer::Warnings::SAFE)
|
82
|
+
assert_equal 2, warnings.length
|
83
|
+
end
|
84
|
+
|
85
|
+
[:nokogiri, :hpricot].each do |adapter|
|
86
|
+
warnings = get_warnings(html, adapter, Premailer::Warnings::POOR)
|
87
|
+
assert_equal 1, warnings.length
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
protected
|
92
|
+
def get_warnings(html, adapter = :nokogiri, warn_level = Premailer::Warnings::SAFE)
|
93
|
+
pm = Premailer.new(html, {:adpater => adapter, :with_html_string => true, :warn_level => warn_level})
|
94
|
+
pm.to_inline_css
|
95
|
+
pm.check_client_support
|
96
|
+
end
|
97
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: premailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 13
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 7
|
8
|
-
-
|
9
|
-
version: 1.7.
|
9
|
+
- 3
|
10
|
+
version: 1.7.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Alex Dunae
|
@@ -14,8 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
-
default_executable:
|
18
|
+
date: 2011-09-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: css_parser
|
@@ -25,6 +25,7 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 1
|
28
29
|
segments:
|
29
30
|
- 1
|
30
31
|
- 1
|
@@ -40,6 +41,7 @@ dependencies:
|
|
40
41
|
requirements:
|
41
42
|
- - ">="
|
42
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 63
|
43
45
|
segments:
|
44
46
|
- 4
|
45
47
|
- 0
|
@@ -55,6 +57,7 @@ dependencies:
|
|
55
57
|
requirements:
|
56
58
|
- - ">="
|
57
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 57
|
58
61
|
segments:
|
59
62
|
- 0
|
60
63
|
- 8
|
@@ -70,6 +73,7 @@ dependencies:
|
|
70
73
|
requirements:
|
71
74
|
- - ">="
|
72
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 15
|
73
77
|
segments:
|
74
78
|
- 1
|
75
79
|
- 4
|
@@ -77,6 +81,45 @@ dependencies:
|
|
77
81
|
version: 1.4.4
|
78
82
|
type: :development
|
79
83
|
version_requirements: *id004
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rake
|
86
|
+
prerelease: false
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 27
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
- 8
|
96
|
+
version: "0.8"
|
97
|
+
- - "!="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 59
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
- 9
|
103
|
+
- 0
|
104
|
+
version: 0.9.0
|
105
|
+
type: :development
|
106
|
+
version_requirements: *id005
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: rdoc
|
109
|
+
prerelease: false
|
110
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 27
|
116
|
+
segments:
|
117
|
+
- 2
|
118
|
+
- 4
|
119
|
+
- 2
|
120
|
+
version: 2.4.2
|
121
|
+
type: :development
|
122
|
+
version_requirements: *id006
|
80
123
|
description: Improve the rendering of HTML emails by making CSS inline, converting links and warning about unsupported code.
|
81
124
|
email: code@dunae.ca
|
82
125
|
executables:
|
@@ -86,17 +129,46 @@ extensions: []
|
|
86
129
|
extra_rdoc_files:
|
87
130
|
- README.rdoc
|
88
131
|
files:
|
89
|
-
-
|
132
|
+
- .gitignore
|
133
|
+
- Gemfile
|
134
|
+
- LICENSE.rdoc
|
135
|
+
- README.rdoc
|
90
136
|
- bin/premailer
|
137
|
+
- init.rb
|
91
138
|
- lib/premailer.rb
|
92
|
-
- lib/premailer/html_to_plain_text.rb
|
93
|
-
- lib/premailer/premailer.rb
|
94
139
|
- lib/premailer/adapter.rb
|
95
140
|
- lib/premailer/adapter/hpricot.rb
|
96
141
|
- lib/premailer/adapter/nokogiri.rb
|
142
|
+
- lib/premailer/executor.rb
|
143
|
+
- lib/premailer/html_to_plain_text.rb
|
144
|
+
- lib/premailer/premailer.rb
|
145
|
+
- local-premailer
|
97
146
|
- misc/client_support.yaml
|
98
|
-
-
|
99
|
-
|
147
|
+
- premailer.gemspec
|
148
|
+
- rakefile.rb
|
149
|
+
- test/files/base.html
|
150
|
+
- test/files/chars.html
|
151
|
+
- test/files/contact_bg.png
|
152
|
+
- test/files/dialect.png
|
153
|
+
- test/files/dots_end.png
|
154
|
+
- test/files/dots_h.gif
|
155
|
+
- test/files/html4.html
|
156
|
+
- test/files/import.css
|
157
|
+
- test/files/inc/2009-placeholder.png
|
158
|
+
- test/files/iso-8859-2.html
|
159
|
+
- test/files/iso-8859-5.html
|
160
|
+
- test/files/no_css.html
|
161
|
+
- test/files/noimport.css
|
162
|
+
- test/files/styles.css
|
163
|
+
- test/files/xhtml.html
|
164
|
+
- test/future_tests.rb
|
165
|
+
- test/helper.rb
|
166
|
+
- test/test_adapter.rb
|
167
|
+
- test/test_html_to_plain_text.rb
|
168
|
+
- test/test_links.rb
|
169
|
+
- test/test_misc.rb
|
170
|
+
- test/test_premailer.rb
|
171
|
+
- test/test_warnings.rb
|
100
172
|
homepage: http://premailer.dialect.ca/
|
101
173
|
licenses: []
|
102
174
|
|
@@ -114,6 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
186
|
requirements:
|
115
187
|
- - ">="
|
116
188
|
- !ruby/object:Gem::Version
|
189
|
+
hash: 3
|
117
190
|
segments:
|
118
191
|
- 0
|
119
192
|
version: "0"
|
@@ -122,15 +195,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
195
|
requirements:
|
123
196
|
- - ">="
|
124
197
|
- !ruby/object:Gem::Version
|
198
|
+
hash: 3
|
125
199
|
segments:
|
126
200
|
- 0
|
127
201
|
version: "0"
|
128
202
|
requirements: []
|
129
203
|
|
130
204
|
rubyforge_project:
|
131
|
-
rubygems_version: 1.
|
205
|
+
rubygems_version: 1.8.10
|
132
206
|
signing_key:
|
133
207
|
specification_version: 3
|
134
208
|
summary: Preflight for HTML e-mail.
|
135
|
-
test_files:
|
136
|
-
|
209
|
+
test_files:
|
210
|
+
- test/files/base.html
|
211
|
+
- test/files/chars.html
|
212
|
+
- test/files/contact_bg.png
|
213
|
+
- test/files/dialect.png
|
214
|
+
- test/files/dots_end.png
|
215
|
+
- test/files/dots_h.gif
|
216
|
+
- test/files/html4.html
|
217
|
+
- test/files/import.css
|
218
|
+
- test/files/inc/2009-placeholder.png
|
219
|
+
- test/files/iso-8859-2.html
|
220
|
+
- test/files/iso-8859-5.html
|
221
|
+
- test/files/no_css.html
|
222
|
+
- test/files/noimport.css
|
223
|
+
- test/files/styles.css
|
224
|
+
- test/files/xhtml.html
|
225
|
+
- test/future_tests.rb
|
226
|
+
- test/helper.rb
|
227
|
+
- test/test_adapter.rb
|
228
|
+
- test/test_html_to_plain_text.rb
|
229
|
+
- test/test_links.rb
|
230
|
+
- test/test_misc.rb
|
231
|
+
- test/test_premailer.rb
|
232
|
+
- test/test_warnings.rb
|