Class: Skylight::Normalizers::RenderNormalizer Private

Inherits:
Normalizer show all
Includes:
Util::AllocationFree
Defined in:
lib/skylight/normalizers.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from Normalizer

#config

Instance Method Summary collapse

Methods included from Util::AllocationFree

#array_find

Methods inherited from Normalizer

#initialize, register

Constructor Details

This class inherits a constructor from Skylight::Normalizers::Normalizer

Instance Method Details

#normalize_render(category, payload, annotations) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
53
54
55
56
57
# File 'lib/skylight/normalizers.rb', line 50

def normalize_render(category, payload, annotations)
  if path = payload[:identifier]
    title = relative_path(path, annotations)
    path = nil if path == title
  end

  [ category, title, nil, annotations ]
end

#relative_path(path, annotations) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/skylight/normalizers.rb', line 59

def relative_path(path, annotations)
  return path if relative_path?(path)

  root = array_find(@paths) { |p| path.start_with?(p) }
  type = :project

  unless root
    root = array_find(Gem.path) { |p| path.start_with?(p) }
    type = :gem
  end

  if root
    start = root.size
    start += 1 if path.getbyte(start) == SEPARATOR_BYTE
    if type == :gem
      "$GEM_PATH/#{path[start, path.size]}"
    else
      path[start, path.size]
    end
  else
    "Absolute Path"
  end
end

#setupObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/skylight/normalizers.rb', line 46

def setup
  @paths = config['normalizers.render.view_paths'] || []
end