cdn_asset_gem 1.0.3 → 1.0.4

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: 6ac05e935a43370c17958c74bab58972c94b5b07
4
- data.tar.gz: 66d9aabad836db2baac423f7e24101ee71521b9f
3
+ metadata.gz: 1df30ad023c94cb34fe2da970a0a2fa0332f4f3c
4
+ data.tar.gz: 96f55810b672d27934e8dd3f35edfee14dece85f
5
5
  SHA512:
6
- metadata.gz: e3ad09e7fbc2d4f6d69473770e2bd29d18da2228d4db3a4f5b149bc87a5809f1734c0bb0ee4708c5030da060be96a862036b7e01e3343407275010f36b0889fc
7
- data.tar.gz: fd4a5225e01b1932403cb71a7343dd4d26e2625738599429748dfe1b9bfaff953df43c53024ca6200413bbea2cb8b8f089b7a375bf10b5ce02eb8cec37ca72ef
6
+ metadata.gz: fb5d9c1164476198a1b62f6f7d2c676a6f212825e2ab53a1f7b0e01cac3da5a03c71fdf510138e35e3ca5042398adfe253c1234e7d5cc59a679483ee5e76190a
7
+ data.tar.gz: fbc11c193891ef4726e65109742baca055451909721d452d425eea1573b74eab350b5cb6c0b594ed46c981f97e6321da4cd4ee993e92d0b591165141d2399f62
@@ -1,11 +1,13 @@
1
1
  module CdnAssetGem
2
2
  module View
3
3
  module Helpers
4
- def map_asset(root_path: '', asset_name:)
5
- if manifest_hash
6
- "#{ENV['CDN_URL']}/#{manifest_hash[asset_name]}"
4
+ def map_asset(root_path: '', asset_name:, file_type:)
5
+ file = "#{file_type}/#{asset_name}.min.#{file_type}"
6
+
7
+ if manifest_hash(root_path)[file]
8
+ "#{ENV['CDN_URL']}#{root_path}/assets/#{manifest_hash(root_path)[file]}"
7
9
  else
8
- "#{ENV['CDN_URL']}/#{asset_name}"
10
+ "#{ENV['CDN_URL']}#{root_path}/assets/#{file}"
9
11
  end
10
12
  end
11
13
 
@@ -13,15 +15,14 @@ module CdnAssetGem
13
15
 
14
16
  def manifest_hash(root_path)
15
17
  if root_path.blank? || root_path == '/'
16
- assets_path = 'assets/'
18
+ assets_path = '/assets'
17
19
  else
18
- assets_path = "#{root_path}/assets/"
20
+ assets_path = "#{root_path}/assets"
19
21
  end
20
22
 
21
23
  response = Rails.cache.fetch("cdn-asset-#{root_path}", expires_in: 5.minutes) do
22
- HTTP.get("#{ENV['CDN_URL']}#{assets_path}rev-manifest.json")
24
+ HTTP.get("#{ENV['CDN_URL']}#{assets_path}/rev-manifest.json")
23
25
  end
24
-
25
26
  JSON.parse(response) if response.code == 200
26
27
  end
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cdn_asset_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Baker