class InfluxReporter::Normalizers::ActionView::RenderNormalizer

Public Instance Methods

normalize_render(payload, kind) click to toggle source
# File lib/influx_reporter/normalizers/action_view.rb, line 7
def normalize_render(payload, kind)
  signature = path_for(payload[:identifier])

  [signature, kind, nil]
end

Private Instance Methods

path_for(identifier) click to toggle source
# File lib/influx_reporter/normalizers/action_view.rb, line 15
def path_for(identifier)
  return 'Unknown template' unless path = identifier
  return path unless path.start_with?('/')

  path && relative_path(path)
end
relative_path(path) click to toggle source
# File lib/influx_reporter/normalizers/action_view.rb, line 22
def relative_path(path)
  root = config.view_paths.find { |vp| path.start_with? vp }
  type = :app

  unless root
    root = Gem.path.find { |gp| path.start_with? gp }
    type = :gem
  end

  return 'Absolute path' unless root

  start = root.length
  start += 1 if path[root.length] == '/'

  if type == :gem
    "$GEM_PATH/#{path[start, path.length]}"
  else
    path[start, path.length]
  end
end