Class: Roadie::AssetScanner Private
- Inherits:
-
Object
- Object
- Roadie::AssetScanner
- Defined in:
- lib/roadie/asset_scanner.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.
The asset scanner’s main usage is finding and/or extracting styles from a DOM tree. Referenced styles will be found using the provided asset provider.
Any style declaration tagged with data-roadie-ignore
will be ignored, except for having the attribute itself removed.
Instance Attribute Summary collapse
- #dom ⇒ Object readonly private
- #external_asset_provider ⇒ Object readonly private
- #normal_asset_provider ⇒ Object readonly private
Instance Method Summary collapse
-
#extract_css ⇒ Enumerable<Stylesheet>
private
Looks for all non-ignored stylesheets, removes their references from the DOM and then returns them.
-
#find_css ⇒ Enumerable<Stylesheet>
private
Looks for all non-ignored stylesheets and returns them.
-
#initialize(dom, normal_asset_provider, external_asset_provider) ⇒ AssetScanner
constructor
private
A new instance of AssetScanner.
Constructor Details
#initialize(dom, normal_asset_provider, external_asset_provider) ⇒ AssetScanner
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.
Returns a new instance of AssetScanner.
18 19 20 21 22 |
# File 'lib/roadie/asset_scanner.rb', line 18 def initialize(dom, normal_asset_provider, external_asset_provider) @dom = dom @normal_asset_provider = normal_asset_provider @external_asset_provider = external_asset_provider end |
Instance Attribute Details
#dom ⇒ Object (readonly)
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.
13 14 15 |
# File 'lib/roadie/asset_scanner.rb', line 13 def dom @dom end |
#external_asset_provider ⇒ Object (readonly)
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.
13 14 15 |
# File 'lib/roadie/asset_scanner.rb', line 13 def external_asset_provider @external_asset_provider end |
#normal_asset_provider ⇒ Object (readonly)
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.
13 14 15 |
# File 'lib/roadie/asset_scanner.rb', line 13 def normal_asset_provider @normal_asset_provider end |
Instance Method Details
#extract_css ⇒ Enumerable<Stylesheet>
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.
Looks for all non-ignored stylesheets, removes their references from the DOM and then returns them.
This will mutate the DOM tree.
The order of the array corresponds with the document order in the DOM.
45 46 47 48 49 50 51 |
# File 'lib/roadie/asset_scanner.rb', line 45 def extract_css @dom.css(STYLE_ELEMENT_QUERY).map { |element| stylesheet = read_stylesheet(element) element.remove if stylesheet stylesheet }.compact end |
#find_css ⇒ Enumerable<Stylesheet>
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.
Looks for all non-ignored stylesheets and returns them.
This method will not mutate the DOM and is safe to call multiple times.
The order of the array corresponds with the document order in the DOM.
32 33 34 |
# File 'lib/roadie/asset_scanner.rb', line 32 def find_css @dom.css(STYLE_ELEMENT_QUERY).map { |element| read_stylesheet(element) }.compact end |