cdn_asset_gem 1.0.4 → 1.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1df30ad023c94cb34fe2da970a0a2fa0332f4f3c
4
- data.tar.gz: 96f55810b672d27934e8dd3f35edfee14dece85f
3
+ metadata.gz: 14c2591db7fdc3a6386d21abd13c5c97fcb6e26d
4
+ data.tar.gz: c3bfc7dcdd4c61e6d3acc26217d64a20661e08bc
5
5
  SHA512:
6
- metadata.gz: fb5d9c1164476198a1b62f6f7d2c676a6f212825e2ab53a1f7b0e01cac3da5a03c71fdf510138e35e3ca5042398adfe253c1234e7d5cc59a679483ee5e76190a
7
- data.tar.gz: fbc11c193891ef4726e65109742baca055451909721d452d425eea1573b74eab350b5cb6c0b594ed46c981f97e6321da4cd4ee993e92d0b591165141d2399f62
6
+ metadata.gz: ffdde89016e4527a21e4cd446a34003f0420b37bd48ed0d7ed204ac0997bbc7893d0e192d38d5f354e07cb8aa6e556332fefa3b0d61e228cba61cbb7b41e74fb
7
+ data.tar.gz: 315c6dd7790cb0d61aa18fa130f7d50c93145bc0e6fcc57df0661d2779bd9a976f10bfbd5ed842829026f88dfad7cc5c58fe33b8bb9ae038a6fcc325f73efa66
@@ -1,30 +1,28 @@
1
1
  module CdnAssetGem
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}"
2
+ def map_asset(root_path: '', asset_name:, file_type:)
3
+ file = "#{file_type}/#{asset_name}.min.#{file_type}"
6
4
 
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
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
13
11
 
14
- private
12
+ private
15
13
 
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
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
22
20
 
23
- response = Rails.cache.fetch("cdn-asset-#{root_path}", expires_in: 5.minutes) do
24
- HTTP.get("#{ENV['CDN_URL']}#{assets_path}/rev-manifest.json")
25
- end
26
- JSON.parse(response) if response.code == 200
27
- end
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'
28
26
  end
29
27
  end
30
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.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Baker