Class: Bunto::Assets::Liquid::Tag::ProxiedAsset
- Inherits:
-
Object
- Object
- Bunto::Assets::Liquid::Tag::ProxiedAsset
- Extended by:
- Forwardable
- Defined in:
- lib/bunto/assets/liquid/tag/proxied_asset.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#asset ⇒ Object
readonly
Returns the value of attribute asset.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
-
#cached? ⇒ Boolean
——————————————————————.
-
#digest ⇒ Object
——————————————————————.
-
#digest_path ⇒ Object
——————————————————————.
-
#filename ⇒ Object
——————————————————————.
-
#initialize(asset, args, env, tag) ⇒ ProxiedAsset
constructor
——————————————————————.
-
#logical_path ⇒ Object
—————————————————————— We always digest a proxied asset so it’s uniq based on what proxies you give us, it would be ignorant to treat it otherwise, we also make sure they are URL safe by digesting the args.
-
#source ⇒ Object
——————————————————————.
-
#write_to(name) ⇒ Object
——————————————————————.
Constructor Details
#initialize(asset, args, env, tag) ⇒ ProxiedAsset
26 27 28 29 30 31 32 33 34 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 26 def initialize(asset, args, env, tag) @env = env @asset = asset @args = args @tag = tag cache_file proxy_file end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
14 15 16 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 14 def args @args end |
#asset ⇒ Object (readonly)
Returns the value of attribute asset.
14 15 16 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 14 def asset @asset end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
14 15 16 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 14 def env @env end |
Instance Method Details
#cached? ⇒ Boolean
38 39 40 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 38 def cached? @_cached end |
#digest ⇒ Object
65 66 67 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 65 def digest Digest::SHA2.hexdigest(args.proxies.to_s) end |
#digest_path ⇒ Object
81 82 83 84 85 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 81 def digest_path name = asset.logical_path ext = File.extname(name) "#{name.chomp(ext)}-#{digest}#{ext}" end |
#filename ⇒ Object
59 60 61 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 59 def filename env.in_cache_dir(digest_path) end |
#logical_path ⇒ Object
We always digest a proxied asset so it’s uniq based on what proxies you give us, it would be ignorant to treat it otherwise, we also make sure they are URL safe by digesting the args.
75 76 77 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 75 def logical_path digest_path end |
#source ⇒ Object
53 54 55 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 53 def source File.binread(filename) end |
#write_to(name) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/bunto/assets/liquid/tag/proxied_asset.rb', line 44 def write_to(name) FileUtils.mkdir_p File.dirname(name) Sprockets::PathUtils.atomic_write(name) do |f| f.write source end end |