cdn_asset_gem 1.0.5 → 1.0.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: 14c2591db7fdc3a6386d21abd13c5c97fcb6e26d
4
- data.tar.gz: c3bfc7dcdd4c61e6d3acc26217d64a20661e08bc
3
+ metadata.gz: b4b299a4a5813c055d79c561c28ae9859527a571
4
+ data.tar.gz: 05e3455d86fda6e5a335538e0b25efdc2041d6dc
5
5
  SHA512:
6
- metadata.gz: ffdde89016e4527a21e4cd446a34003f0420b37bd48ed0d7ed204ac0997bbc7893d0e192d38d5f354e07cb8aa6e556332fefa3b0d61e228cba61cbb7b41e74fb
7
- data.tar.gz: 315c6dd7790cb0d61aa18fa130f7d50c93145bc0e6fcc57df0661d2779bd9a976f10bfbd5ed842829026f88dfad7cc5c58fe33b8bb9ae038a6fcc325f73efa66
6
+ metadata.gz: af8e893c820b32b51791478d6fc7a2ed5d041a9b9a9f3921dc8a6760d87d2101305a1e119a443ffb591ac5248bb2d34437be34ae7e415cb8b27872c279d64f37
7
+ data.tar.gz: 340857a2b6bf807f208a17884b4019861f6b16c03140af181d4671e18cc5b582bd8b5785cd257f3725a8c1d4f287020cbcda2ca31f8f6dac5739aeec97b42603
@@ -1,28 +1,32 @@
1
1
  module CdnAssetGem
2
- def map_asset(root_path: '', asset_name:, file_type:)
3
- file = "#{file_type}/#{asset_name}.min.#{file_type}"
2
+ module View
3
+ module Helpers
4
+ def map_asset(root_path: '', asset_name:, file_type:)
5
+ file = "#{file_type}/#{asset_name}.min.#{file_type}"
4
6
 
5
- if manifest_hash(root_path)[file]
6
- "#{ENV['CDN_URL']}#{root_path}/assets/#{manifest_hash(root_path)[file]}"
7
- else
8
- "#{ENV['CDN_URL']}#{root_path}/assets/#{file}"
9
- end
10
- end
7
+ if manifest_hash(root_path)[file]
8
+ "#{ENV['CDN_URL']}#{root_path}/assets/#{manifest_hash(root_path)[file]}"
9
+ else
10
+ "#{ENV['CDN_URL']}#{root_path}/assets/#{file}"
11
+ end
12
+ end
11
13
 
12
- private
14
+ private
13
15
 
14
- def manifest_hash(root_path)
15
- if root_path.blank? || root_path == '/'
16
- assets_path = '/assets'
17
- else
18
- assets_path = "#{root_path}/assets"
19
- end
16
+ def manifest_hash(root_path)
17
+ if root_path.blank? || root_path == '/'
18
+ assets_path = '/assets'
19
+ else
20
+ assets_path = "#{root_path}/assets"
21
+ end
20
22
 
21
- Rails.cache.fetch("cdn-asset-#{root_path}", expires_in: 5.minutes) do
22
- uri = URI("#{ENV['CDN_URL']}#{assets_path}/rev-manifest.json")
23
- response = Net::HTTP.get(uri)
24
- response_code = Net::HTTP.get_response(uri).code
25
- JSON.parse(response) if response_code == '200'
23
+ Rails.cache.fetch("cdn-asset-#{root_path}", expires_in: 5.minutes) do
24
+ uri = URI("#{ENV['CDN_URL']}#{assets_path}/rev-manifest.json")
25
+ response = Net::HTTP.get(uri)
26
+ response_code = Net::HTTP.get_response(uri).code
27
+ JSON.parse(response) if response_code == '200'
28
+ end
29
+ end
26
30
  end
27
31
  end
28
32
  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.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Baker