Module: Txray::Reporters

Defined in:
lib/txray/reporters.rb,
lib/txray/reporters/json.rb,
lib/txray/reporters/live.rb,
lib/txray/reporters/text.rb,
lib/txray/reporters/sarif.rb,
lib/txray/reporters/github.rb

Defined Under Namespace

Classes: Github, Json, Live, Sarif, Text

Constant Summary collapse

FORMATS =
{ "text" => Text, "json" => Json, "sarif" => Sarif, "github" => Github }.freeze

Class Method Summary collapse

Class Method Details

.build(format, io: $stdout) ⇒ Object



17
18
19
20
# File 'lib/txray/reporters.rb', line 17

def self.build(format, io: $stdout)
  klass = FORMATS[format.to_s] or raise Error, "unknown format #{format}, expected one of #{FORMATS.keys.join(", ")}"
  klass.new(io: io)
end

.color?(io) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/txray/reporters.rb', line 11

def self.color?(io)
  ENV["NO_COLOR"].to_s.empty? && io.respond_to?(:tty?) && io.tty?
end