premailer-rails 1.9.6 → 1.9.7

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: 921889a0d16fba418ad624860751a2859349477e
4
- data.tar.gz: 6766aae6456138af9b603c99b6792261081ed02c
3
+ metadata.gz: 34449fbe39f5a20061a3f6b389a95c4286b6a2cc
4
+ data.tar.gz: 551a7262f0926f02554a6bea9c47eb4446d04d82
5
5
  SHA512:
6
- metadata.gz: ee8d13c60df7937a75c413cc54263ba36b101f15cead9b8c3b1881f3e208b9cf16a6a1781d47492c2afa69360d79674a431e2273777d3d0abc322745637645c3
7
- data.tar.gz: 32aa76f207b989cf6799e01d2a8de70e1044a4d61b3d23d85f7adaba7b82d03343bd2d686b043b65f0bc9535905817d2ff250de00bae5d616313e9342d5ff6de
6
+ metadata.gz: 507c28b394a9ec1fdf24e6a51b45f0cad7ac6b7ad3012f7c5993db164eeb1f100d9a410a10d4d5876f68cf9e8f9a3a2febf8a5cad5cc116823abaa84714ba8e7
7
+ data.tar.gz: f3fb70d57c1acf9e196dadc98c53061ed45b2604c9a721e8eff194dd9e42b45243c5c07b4bcaa6b555ae97e5d163ba27c65cb6dcbfab61ed9b4f2168f813f853
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.9.7
4
+
5
+ - Use `Rails.root` in `FileSystemLoader` (@stanhu, #195)
6
+
3
7
  ## v1.9.6
4
8
 
5
9
  - Handle `relative_url_root` in when loading CSS from file system
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.6
1
+ 1.9.7
@@ -14,7 +14,15 @@ class Premailer
14
14
  if relative_url_root
15
15
  path = path.sub(/\A#{relative_url_root.chomp('/')}/, '')
16
16
  end
17
- "public#{path}"
17
+ asset_filename(path)
18
+ end
19
+
20
+ def asset_filename(filename)
21
+ if defined?(::Rails) && ::Rails.respond_to?(:root)
22
+ File.join(::Rails.root, 'public', filename)
23
+ else
24
+ File.join('public', filename)
25
+ end
18
26
  end
19
27
 
20
28
  def relative_url_root
@@ -4,6 +4,8 @@ describe Premailer::Rails::CSSLoaders::FileSystemLoader do
4
4
  before do
5
5
  allow(Rails.configuration)
6
6
  .to receive(:assets).and_return(double(prefix: '/assets'))
7
+ allow(Rails)
8
+ .to receive(:root).and_return(Pathname.new('/rails_root'))
7
9
  end
8
10
 
9
11
  describe '#file_name' do
@@ -17,19 +19,19 @@ describe Premailer::Rails::CSSLoaders::FileSystemLoader do
17
19
 
18
20
  context 'when relative_url_root is not set' do
19
21
  let(:asset) { '/assets/application.css' }
20
- it { is_expected.to eq('public/assets/application.css') }
22
+ it { is_expected.to eq(File.join(Rails.root, 'public/assets/application.css')) }
21
23
  end
22
24
 
23
25
  context 'when relative_url_root is set' do
24
26
  let(:relative_url_root) { '/foo' }
25
27
  let(:asset) { '/foo/assets/application.css' }
26
- it { is_expected.to eq('public/assets/application.css') }
28
+ it { is_expected.to eq(File.join(Rails.root, 'public/assets/application.css')) }
27
29
  end
28
30
 
29
31
  context 'when relative_url_root has a trailing slash' do
30
32
  let(:relative_url_root) { '/foo/' }
31
33
  let(:asset) { '/foo/assets/application.css' }
32
- it { is_expected.to eq('public/assets/application.css') }
34
+ it { is_expected.to eq(File.join(Rails.root, 'public/assets/application.css')) }
33
35
  end
34
36
  end
35
37
  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.6
4
+ version: 1.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipe Fatio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-22 00:00:00.000000000 Z
11
+ date: 2017-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: premailer