Class: Journeybook::ComponentValidator

Inherits:
Object
  • Object
show all
Defined in:
app/services/journeybook/component_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(parser: ComponentParser.new, registry: Journeybook.components) ⇒ ComponentValidator

Returns a new instance of ComponentValidator.



6
7
8
9
# File 'app/services/journeybook/component_validator.rb', line 6

def initialize(parser: ComponentParser.new, registry: Journeybook.components)
  @parser = parser
  @registry = registry
end

Instance Method Details

#errors_for(page) ⇒ Object



11
12
13
14
15
16
17
# File 'app/services/journeybook/component_validator.rb', line 11

def errors_for(page)
  components = @registry.for_site(page.site)

  @parser.parse(page.markdown).flat_map.with_index do |component, index|
    validate_component(component, index, components.registered(component.name))
  end
end