Class: GraphQL::Doctor::Reporters::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/doctor/reporters/github.rb

Constant Summary collapse

LEVELS =
{"error" => "error", "warning" => "warning", "info" => "notice"}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(io:) ⇒ Github

Returns a new instance of Github.



9
10
11
# File 'lib/graphql/doctor/reporters/github.rb', line 9

def initialize(io:, **)
  @io = io
end

Instance Method Details

#report(diagnostics) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/graphql/doctor/reporters/github.rb', line 13

def report(diagnostics)
  diagnostics.each do |diagnostic|
    location = diagnostic.location
    properties = "file=#{escape_property(location.path)},line=#{location.start_line}," \
                 "col=#{location.start_column + 1},title=#{diagnostic.code}"
    @io.puts "::#{LEVELS.fetch(diagnostic.severity)} #{properties}::#{escape_message(diagnostic.message)}"
  end
end