class Volt::SourceMapServer

Attributes

prefix[W]
sprockets[R]

Public Class Methods

new(sprockets) click to toggle source
# File lib/volt/server/rack/source_map_server.rb, line 3
def initialize(sprockets)
  @sprockets = sprockets
end

Public Instance Methods

call(env) click to toggle source
# File lib/volt/server/rack/source_map_server.rb, line 19
def call(env)
  path_info = env['PATH_INFO']

  if path_info =~ /\.js\.map$/
    path  = env['PATH_INFO'].gsub(/^\/|\.js\.map$/, '')
    asset = sprockets[path]
    return [404, {}, []] if asset.nil?

    return [200, { 'Content-Type' => 'text/json' }, [$OPAL_SOURCE_MAPS[asset.pathname].to_s]]
  else
    return [200, { 'Content-Type' => 'text/text' }, [File.read(sprockets.resolve(path_info))]]
  end
end
inspect() click to toggle source
# File lib/volt/server/rack/source_map_server.rb, line 15
def inspect
  "#<#{self.class}:#{object_id}>"
end
prefix() click to toggle source
# File lib/volt/server/rack/source_map_server.rb, line 11
def prefix
  @prefix ||= '/__opal_source_maps__'
end