Module: Bridgetown::Builders::DSL::Inspectors::XML
- Defined in:
- lib/bridgetown-builder/dsl/inspectors.rb
Overview
XML inspector type
Class Method Summary collapse
-
.call(resource, inspectors) ⇒ String
Process the resource with the available inspectors and return the output XML.
-
.can_run?(resource, inspectors) ⇒ Boolean
Are there any inspectors available which match the resource extension?.
-
.resource_ext(resource) ⇒ Object
Strip the resource’s initial extension dot.
Class Method Details
.call(resource, inspectors) ⇒ String
Process the resource with the available inspectors and return the output XML
62 63 64 65 66 67 68 69 70 |
# File 'lib/bridgetown-builder/dsl/inspectors.rb', line 62 def self.call(resource, inspectors) doc = Nokogiri::XML(resource.output) inspectors[resource_ext(resource)].each do |block| block.call(doc, resource) end doc.to_xml end |
.can_run?(resource, inspectors) ⇒ Boolean
Are there any inspectors available which match the resource extension?
53 54 55 56 57 |
# File 'lib/bridgetown-builder/dsl/inspectors.rb', line 53 def self.can_run?(resource, inspectors) inspectors && inspectors[resource_ext(resource)] && !resource.data.bypass_inspectors end |
.resource_ext(resource) ⇒ Object
Strip the resource’s initial extension dot. ‘.rss` => `rss`
48 49 50 |
# File 'lib/bridgetown-builder/dsl/inspectors.rb', line 48 def self.resource_ext(resource) resource.output_ext&.delete_prefix(".") end |