Class: Crawlscope::StructuredData::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/crawlscope/structured_data/reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(io:, report_path: nil) ⇒ Reporter

Returns a new instance of Reporter.



9
10
11
12
# File 'lib/crawlscope/structured_data/reporter.rb', line 9

def initialize(io:, report_path: nil)
  @io = io
  @report_path = report_path
end

Instance Method Details

#details(result, debug:, renderer:) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/crawlscope/structured_data/reporter.rb', line 25

def details(result, debug:, renderer:)
  @io.puts("JavaScript mode enabled (Ferrum)") if renderer == :browser
  @io.puts("Validating JSON-LD on #{result.entries.size} URL(s)")
  @io.puts("")

  result.entries.each do |entry|
    report_entry(entry, debug: debug)
  end

  @io.puts("STATUS: #{result.ok? ? "OK" : "FAILED"}")
end

#report(result) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/crawlscope/structured_data/reporter.rb', line 14

def report(result)
  report = Report.new(result)

  if report.all_valid?
    @io.puts("")
    @io.puts("All #{report.total} URLs passed validation.")
  else
    report_failures(report)
  end
end