class ServiceWorker::Handlers::SprocketsHandler
Public Instance Methods
call(env)
click to toggle source
# File lib/serviceworker/handlers/sprockets_handler.rb, line 8 def call(env) path_info = env.fetch("serviceworker.asset_name") if config.compile sprockets_server.call(env.merge("PATH_INFO" => path_info)) else file_server.call(env.merge("PATH_INFO" => asset_path(path_info))) end end
Private Instance Methods
asset_path(path)
click to toggle source
# File lib/serviceworker/handlers/sprockets_handler.rb, line 32 def asset_path(path) if controller_helpers.respond_to?(:compute_asset_path) controller_helpers.compute_asset_path(path) else logical_asset_path(path) end end
config()
click to toggle source
# File lib/serviceworker/handlers/sprockets_handler.rb, line 28 def config ::Rails.configuration.assets end
controller_helpers()
click to toggle source
# File lib/serviceworker/handlers/sprockets_handler.rb, line 40 def controller_helpers ::ActionController::Base.helpers end
file_server()
click to toggle source
# File lib/serviceworker/handlers/sprockets_handler.rb, line 24 def file_server @file_server ||= ::Rack::File.new(::Rails.public_path) end
logical_asset_path(path)
click to toggle source
# File lib/serviceworker/handlers/sprockets_handler.rb, line 44 def logical_asset_path(path) asset_path = controller_helpers.asset_path(path) uri = URI.parse(asset_path) uri.host = nil uri.scheme = nil uri.to_s rescue URI::InvalidURIError asset_path end
sprockets_server()
click to toggle source
# File lib/serviceworker/handlers/sprockets_handler.rb, line 20 def sprockets_server ::Rails.application.assets end