Module: CloudFront
- Defined in:
- lib/cloud_front.rb,
lib/cloud_front/railtie.rb,
lib/cloud_front/version.rb,
lib/cloud_front/hashed_request_interpreter.rb
Defined Under Namespace
Classes: HashedRequestInterpreter, Railtie
Constant Summary
collapse
- VERSION =
'0.0.2'
Class Method Summary
collapse
Class Method Details
.asset_host(source, request) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/cloud_front.rb', line 8
def self.asset_host(source, request)
if source =~ %r{^//}
''
else
"#{request.protocol}#{domain}"
end
end
|
.asset_path(asset_path) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/cloud_front.rb', line 16
def self.asset_path(asset_path)
absolute_path = File.join(ActionController::Base.config.assets_dir, asset_path)
if asset_path.to_s !~ %r{^//} && (File.exist?(absolute_path) || asset_path.to_s =~ /_packaged\.(?:css|js)$/)
relative_path = Pathname.new(asset_path)
"/%s%s/%s%s" % [ENV['COMMIT_HASH'], relative_path.dirname, relative_path.basename(relative_path.extname), relative_path.extname.to_s]
else
asset_path
end
end
|