premailer-rails 1.8.1 → 1.8.2
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/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/premailer/rails/css_loaders/network_loader.rb +14 -14
- data/spec/unit/css_loaders/network_loader_spec.rb +53 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ef9ec48ca64d88fcd427db297397c18a20f6711
|
4
|
+
data.tar.gz: f6c87f62f912f57f0d5f302138abd6160a65d99d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2493ad95cdc85442f350a4d613ce66a996b114ac2054dd0c2a145f9ce54c844371dbbb053e4011e3a4a95a4a2986e98037d2d6fe00a8879bfec2f0edf952bd
|
7
|
+
data.tar.gz: 946de795ff75887899fb882ed7b74d0497b5e78af394f118c4369f8c779aede8626f08def7bfd5675b645f925b882f596d04269f40719c1c50a80b8d653ab14e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.8.
|
1
|
+
1.8.2
|
@@ -12,29 +12,29 @@ class Premailer
|
|
12
12
|
def uri_for_url(url)
|
13
13
|
uri = URI(url)
|
14
14
|
|
15
|
-
if
|
16
|
-
|
17
|
-
|
15
|
+
if uri.host.present?
|
16
|
+
return uri if uri.scheme.present?
|
17
|
+
URI("http://#{uri.to_s}")
|
18
|
+
elsif asset_host_present?
|
19
|
+
scheme, host = asset_host.split(%r{:?//})
|
20
|
+
scheme, host = host, scheme if host.nil?
|
18
21
|
scheme = 'http' if scheme.blank?
|
19
|
-
|
20
|
-
|
22
|
+
path = url
|
23
|
+
URI(File.join("#{scheme}://#{host}", path))
|
21
24
|
end
|
22
|
-
|
23
|
-
uri if valid_uri?(uri)
|
24
25
|
end
|
25
26
|
|
26
27
|
def valid_uri?(uri)
|
27
28
|
uri.host.present? && uri.scheme.present?
|
28
29
|
end
|
29
30
|
|
30
|
-
def
|
31
|
-
|
31
|
+
def asset_host_present?
|
32
|
+
::Rails.configuration.action_controller.asset_host.present?
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
host
|
37
|
-
end
|
35
|
+
def asset_host
|
36
|
+
config = ::Rails.configuration.action_controller.asset_host
|
37
|
+
config.respond_to?(:call) ? config.call : config
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Premailer::Rails::CSSLoaders::NetworkLoader do
|
4
|
+
describe '#uri_for_url' do
|
5
|
+
subject { described_class.uri_for_url(url) }
|
6
|
+
let(:asset_host) { nil }
|
7
|
+
|
8
|
+
before do
|
9
|
+
action_controller = double(asset_host: asset_host)
|
10
|
+
config = double(action_controller: action_controller)
|
11
|
+
allow(Rails).to receive(:configuration).and_return(config)
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'with a valid URL' do
|
15
|
+
let(:url) { 'http://example.com/test.css' }
|
16
|
+
it { is_expected.to eq(URI(url)) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with a protocol relative URL' do
|
20
|
+
let(:url) { '//example.com/test.css' }
|
21
|
+
it { is_expected.to eq(URI("http://#{url}")) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'with a file path' do
|
25
|
+
let(:url) { '/assets/foo.css' }
|
26
|
+
|
27
|
+
context 'and a domain as asset host' do
|
28
|
+
let(:asset_host) { 'example.com' }
|
29
|
+
it { is_expected.to eq(URI("http://example.com#{url}")) }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'and a URL as asset host' do
|
33
|
+
let(:asset_host) { 'https://example.com' }
|
34
|
+
it { is_expected.to eq(URI("https://example.com/assets/foo.css")) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'and a protocol relative URL as asset host' do
|
38
|
+
let(:asset_host) { '//example.com' }
|
39
|
+
it { is_expected.to eq(URI("http://example.com/assets/foo.css")) }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'and a proc as asset host' do
|
43
|
+
let(:asset_host) { ->{ 'example.com' } }
|
44
|
+
it { is_expected.to eq(URI("http://example.com/assets/foo.css")) }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'without an asset host' do
|
48
|
+
let(:asset_host) { nil }
|
49
|
+
it { is_expected.not_to be }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
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.8.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipe Fatio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: premailer
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- spec/support/stubs/action_mailer.rb
|
164
164
|
- spec/support/stubs/rails.rb
|
165
165
|
- spec/unit/css_loaders/asset_pipeline_loader_spec.rb
|
166
|
+
- spec/unit/css_loaders/network_loader_spec.rb
|
166
167
|
- spec/unit/customized_premailer_spec.rb
|
167
168
|
- spec/unit/premailer_rails_spec.rb
|
168
169
|
homepage: https://github.com/fphilipe/premailer-rails
|
@@ -198,5 +199,6 @@ test_files:
|
|
198
199
|
- spec/support/stubs/action_mailer.rb
|
199
200
|
- spec/support/stubs/rails.rb
|
200
201
|
- spec/unit/css_loaders/asset_pipeline_loader_spec.rb
|
202
|
+
- spec/unit/css_loaders/network_loader_spec.rb
|
201
203
|
- spec/unit/customized_premailer_spec.rb
|
202
204
|
- spec/unit/premailer_rails_spec.rb
|