Class: Skylight::Core::Normalizers::RenderNormalizer Private
- Inherits:
-
Normalizer
- Object
- Normalizer
- Skylight::Core::Normalizers::RenderNormalizer
- Includes:
- Util::AllocationFree
- Defined in:
- lib/skylight/core/normalizers/render.rb
Overview
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.
Base Normalizer for Rails rendering
Direct Known Subclasses
ActionView::RenderCollection, ActionView::RenderPartial, ActionView::RenderTemplate
Instance Attribute Summary
Attributes inherited from Normalizer
Instance Method Summary collapse
-
#normalize_render(category, payload) ⇒ Array
private
Generic normalizer for renders.
- #relative_path(path) ⇒ Object private
- #setup ⇒ Object private
Methods included from Util::AllocationFree
Methods inherited from Normalizer
#initialize, #normalize, #normalize_after, register
Constructor Details
This class inherits a constructor from Skylight::Core::Normalizers::Normalizer
Instance Method Details
#normalize_render(category, payload) ⇒ Array
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.
Generic normalizer for renders
24 25 26 27 28 29 30 |
# File 'lib/skylight/core/normalizers/render.rb', line 24 def normalize_render(category, payload) if (path = payload[:identifier]) title = relative_path(path) end [category, title, nil] end |
#relative_path(path) ⇒ 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/skylight/core/normalizers/render.rb', line 32 def relative_path(path) return path if relative_path?(path) if (root = array_find(@paths) { |p| path.start_with?(p) }) start = root.size start += 1 if path.getbyte(start) == SEPARATOR_BYTE path[start, path.size].sub( # Matches a Gem Version or 12-digit hex (sha) # that is preceeded by a `-` and followed by `/` # Also matches 'app/views/' if it exists %r{-(?:#{Gem::Version::VERSION_PATTERN}|[0-9a-f]{12})\/(?:app\/views\/)*}, ": ".freeze ) else "Absolute Path".freeze end end |
#setup ⇒ 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.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/skylight/core/normalizers/render.rb', line 7 def setup @paths = [] Gem.path.each do |path| @paths << "#{path}/bundler/gems".freeze @paths << "#{path}/gems".freeze @paths << path end @paths.concat(Array(config["normalizers.render.view_paths"])) end |