premailer-rails 1.9.5 → 1.9.6

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: 1d3d9d793a427df886ea2b99af60ce466db67bd2
4
- data.tar.gz: 3849875af6ec63a8194008c94ab543a0b8fbd920
3
+ metadata.gz: 921889a0d16fba418ad624860751a2859349477e
4
+ data.tar.gz: 6766aae6456138af9b603c99b6792261081ed02c
5
5
  SHA512:
6
- metadata.gz: e99f797aaa7f53584f5b8b63b5a20358be04e70a6c3677774abaf04814ceb1574393b7532dad24e36c5accc2ab86bed46aac6efc7967534afb1a5d9880be1dfe
7
- data.tar.gz: 17df1bf7a56bba9ed2474f85012b78d810b924b28efe756827ae66494a5948065dbb4f1aeae8dfc94744d2a830e18fd7f82ade8a90ec63f60a41481623c4e64d
6
+ metadata.gz: ee8d13c60df7937a75c413cc54263ba36b101f15cead9b8c3b1881f3e208b9cf16a6a1781d47492c2afa69360d79674a431e2273777d3d0abc322745637645c3
7
+ data.tar.gz: 32aa76f207b989cf6799e01d2a8de70e1044a4d61b3d23d85f7adaba7b82d03343bd2d686b043b65f0bc9535905817d2ff250de00bae5d616313e9342d5ff6de
data/.travis.yml CHANGED
@@ -3,20 +3,13 @@ language: ruby
3
3
  cache: bundler
4
4
  script: bundle exec rspec
5
5
  rvm:
6
- - 2.3.0
7
- - ruby-head
8
- - jruby
9
- - rbx-2
6
+ - 2.4.1
10
7
  env:
11
- global:
12
- - JRUBY_OPTS="--2.0"
13
8
  matrix:
14
9
  - ACTION_MAILER_VERSION=4
15
- - ACTION_MAILER_VERSION=5.beta
10
+ - ACTION_MAILER_VERSION=5
16
11
  - ACTION_MAILER_VERSION=master
17
12
  matrix:
18
13
  fast_finish: true
19
14
  allow_failures:
20
15
  - env: ACTION_MAILER_VERSION=master
21
- - env: ACTION_MAILER_VERSION=5.beta
22
- - rvm: ruby-head
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.9.6
4
+
5
+ - Handle `relative_url_root` in when loading CSS from file system
6
+
3
7
  ## v1.9.5
4
8
 
5
9
  - Mention license in gemspec
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- action_mailer_version = ENV.fetch('ACTION_MAILER_VERSION', '4')
5
+ action_mailer_version = ENV.fetch('ACTION_MAILER_VERSION', '5')
6
6
 
7
7
  if action_mailer_version == 'master'
8
8
  git 'git://github.com/rails/rails.git' do
data/README.md CHANGED
@@ -87,7 +87,8 @@ gem 'hpricot'
87
87
 
88
88
  If both gems are loaded for some reason, premailer chooses hpricot.
89
89
 
90
- That's it!
90
+ You can also explicitly configure the apapter as documented
91
+ [here](https://github.com/premailer/premailer#adapters).
91
92
 
92
93
  ## Configuration
93
94
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.5
1
+ 1.9.6
@@ -5,9 +5,23 @@ class Premailer
5
5
  extend self
6
6
 
7
7
  def load(url)
8
+ file = file_name(url)
9
+ File.read(file) if File.file?(file)
10
+ end
11
+
12
+ def file_name(url)
8
13
  path = URI(url).path
9
- file_path = "public#{path}"
10
- File.read(file_path) if File.file?(file_path)
14
+ if relative_url_root
15
+ path = path.sub(/\A#{relative_url_root.chomp('/')}/, '')
16
+ end
17
+ "public#{path}"
18
+ end
19
+
20
+ def relative_url_root
21
+ defined?(::Rails) &&
22
+ ::Rails.respond_to?(:configuration) &&
23
+ ::Rails.configuration.respond_to?(:relative_url_root) &&
24
+ ::Rails.configuration.relative_url_root
11
25
  end
12
26
  end
13
27
  end
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,10 @@ if RUBY_ENGINE == 'ruby'
11
11
  end
12
12
  end
13
13
 
14
+ # Temporary fix for missing require. See
15
+ # https://github.com/rails/rails/pull/28835
16
+ require 'active_support/rescuable'
17
+
14
18
  require 'premailer/rails'
15
19
 
16
20
  require 'support/stubs/action_mailer'
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Premailer::Rails::CSSLoaders::FileSystemLoader do
4
+ before do
5
+ allow(Rails.configuration)
6
+ .to receive(:assets).and_return(double(prefix: '/assets'))
7
+ end
8
+
9
+ describe '#file_name' do
10
+ subject { described_class.file_name(asset) }
11
+ let(:relative_url_root) { nil }
12
+
13
+ before do
14
+ config = double(relative_url_root: relative_url_root)
15
+ allow(Rails).to receive(:configuration).and_return(config)
16
+ end
17
+
18
+ context 'when relative_url_root is not set' do
19
+ let(:asset) { '/assets/application.css' }
20
+ it { is_expected.to eq('public/assets/application.css') }
21
+ end
22
+
23
+ context 'when relative_url_root is set' do
24
+ let(:relative_url_root) { '/foo' }
25
+ let(:asset) { '/foo/assets/application.css' }
26
+ it { is_expected.to eq('public/assets/application.css') }
27
+ end
28
+
29
+ context 'when relative_url_root has a trailing slash' do
30
+ let(:relative_url_root) { '/foo/' }
31
+ let(:asset) { '/foo/assets/application.css' }
32
+ it { is_expected.to eq('public/assets/application.css') }
33
+ end
34
+ end
35
+ 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.9.5
4
+ version: 1.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipe Fatio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-07 00:00:00.000000000 Z
11
+ date: 2017-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: premailer
@@ -166,6 +166,7 @@ files:
166
166
  - spec/support/stubs/action_mailer.rb
167
167
  - spec/support/stubs/rails.rb
168
168
  - spec/unit/css_loaders/asset_pipeline_loader_spec.rb
169
+ - spec/unit/css_loaders/file_system_loader_spec.rb
169
170
  - spec/unit/css_loaders/network_loader_spec.rb
170
171
  - spec/unit/customized_premailer_spec.rb
171
172
  - spec/unit/premailer_rails_spec.rb
@@ -189,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
190
  version: '0'
190
191
  requirements: []
191
192
  rubyforge_project:
192
- rubygems_version: 2.5.2
193
+ rubygems_version: 2.6.11
193
194
  signing_key:
194
195
  specification_version: 4
195
196
  summary: Easily create styled HTML emails in Rails.
@@ -220,7 +221,7 @@ test_files:
220
221
  - spec/support/stubs/action_mailer.rb
221
222
  - spec/support/stubs/rails.rb
222
223
  - spec/unit/css_loaders/asset_pipeline_loader_spec.rb
224
+ - spec/unit/css_loaders/file_system_loader_spec.rb
223
225
  - spec/unit/css_loaders/network_loader_spec.rb
224
226
  - spec/unit/customized_premailer_spec.rb
225
227
  - spec/unit/premailer_rails_spec.rb
226
- has_rdoc: