premailer 1.8.1 → 1.8.2

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
  SHA1:
3
- metadata.gz: 780d807660eab934f32306d9ca689dab41f37a09
4
- data.tar.gz: a250c50348de81e092ca35ac0092d09c952e0606
3
+ metadata.gz: 3f49a37803e79dad5aba97c68db82c73b167f172
4
+ data.tar.gz: 528bb4f127c4571d5aca3bf396386600050bb6e0
5
5
  SHA512:
6
- metadata.gz: b00c9baf702aff645325d6b10a71c98def9de70752b11e15f79f0d4218ae73a307a6ff826571148bafb335f477a4b3e909b97ec05ff6d6aa06c15325dd39e19d
7
- data.tar.gz: b7305f4db9b442bbd2944fe05fdfcb823b963888a1d75156465be8505d934c6f7748d4cd28976ee9829f3ed0493358d005d1080d4f41927f5a980f0be2dcc91c
6
+ metadata.gz: a60e8883cee7b95c700b14390eeab652ca9bd379d2307a15729156f29a3a78323015485fc7310de7f01794c6114a3709fd5d6bde01ca4f8ed6964f89f625375c
7
+ data.tar.gz: 441ee16ad13d367e9aa3acc2dde17cf894ef19b745ba0a0330d2a56525208210b93197bea03b36a6c0823fed3aa42de47bcfc77519bf43003c1b0cb95b56ae64
@@ -286,12 +286,17 @@ protected
286
286
  # but the local one is different (e.g. newer) than the live file, premailer will now choose the local file
287
287
 
288
288
  if tag.attributes['href'].to_s.include? @base_url.to_s and @html_file.kind_of?(String)
289
- link_uri = File.join(File.dirname(@html_file), tag.attributes['href'].to_s.sub!(@base_url.to_s, ''))
290
- end
291
-
292
- # if the file does not exist locally, try to grab the remote reference
293
- if link_uri.nil? or not File.exists?(link_uri)
294
- link_uri = Premailer.resolve_link(tag.attributes['href'].to_s, @html_file)
289
+ if @options[:with_html_string]
290
+ link_uri = tag.attributes['href'].to_s.sub(@base_url.to_s, '').sub(/\A\/*/, '')
291
+ else
292
+ link_uri = File.join(File.dirname(@html_file), tag.attributes['href'].to_s.sub!(@base_url.to_s, ''))
293
+ # if the file does not exist locally, try to grab the remote reference
294
+ unless File.exists?(link_uri)
295
+ link_uri = Premailer.resolve_link(tag.attributes['href'].to_s, @html_file)
296
+ end
297
+ end
298
+ else
299
+ link_uri = tag.attributes['href'].to_s
295
300
  end
296
301
 
297
302
  if Premailer.local_data?(link_uri)
@@ -1,4 +1,4 @@
1
1
  class Premailer
2
2
  # Premailer version.
3
- VERSION = '1.8.1'.freeze
3
+ VERSION = '1.8.2'.freeze
4
4
  end
@@ -172,7 +172,7 @@ END_HTML
172
172
 
173
173
  assert_equal "color: blue", premailer.processed_doc.at('a').attributes['style'].to_s,
174
174
  "#{adapter}: Failed to inline the default style"
175
- assert_match /@media \(min-width:500px\) \{.*?a {.*?color: red;.*?\}.*?\}/m, style_tag_contents,
175
+ assert_match /@media \(min-width:500px\) \{.*?a \{.*?color: red;.*?\}.*?\}/m, style_tag_contents,
176
176
  "#{adapter}: Failed to add media query with no type to style"
177
177
  assert_match /@media screen and \(orientation: portrait\) \{.*?a \{.*?color: green;.*?\}.*?\}/m, style_tag_contents,
178
178
  "#{adapter}: Failed to add media query with type to style"
@@ -258,6 +258,15 @@ END_HTML
258
258
  assert_equal expected_html, pm.to_inline_css
259
259
  end
260
260
 
261
+ # output_encoding option should return HTML Entities when set to US-ASCII
262
+ def test_output_encoding
263
+ html_special_characters = "©"
264
+ html_entities_characters = "©"
265
+ expected_html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html><body><p>" + html_entities_characters + "</p></body></html>\n"
266
+ pm = Premailer.new(html_special_characters, :output_encoding => "US-ASCII", :with_html_string => true, :adapter => :nokogiri, :input_encoding => "UTF-8");
267
+ assert_equal expected_html, pm.to_inline_css
268
+ end
269
+
261
270
  def test_meta_encoding_downcase
262
271
  meta_encoding = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
263
272
  expected_html = Regexp.new(Regexp.escape('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'), Regexp::IGNORECASE)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: premailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2014-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: css_parser