Class: RSpec::FlakeClassifier::Signature
- Inherits:
-
Object
- Object
- RSpec::FlakeClassifier::Signature
- Defined in:
- lib/rspec/flake/classifier/signature.rb,
sig/rspec/flake/classifier.rbs
Constant Summary collapse
- PLACEHOLDERS =
{ object_address: "0xADDR", tmp_path: "<TMP>", line: ":LINE", seed: "SEED", timestamp: "<TIME>", cwd: "<PWD>" }.freeze
Instance Attribute Summary collapse
-
#backtrace ⇒ Array[String]
readonly
Returns the value of attribute backtrace.
-
#digest ⇒ String
readonly
Returns the value of attribute digest.
-
#message ⇒ String
readonly
Returns the value of attribute message.
-
#normalized ⇒ String
readonly
Returns the value of attribute normalized.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message:, backtrace: []) ⇒ Signature
constructor
A new instance of Signature.
- #to_h ⇒ Hash[String, untyped]
Constructor Details
#initialize(message:, backtrace: []) ⇒ Signature
Returns a new instance of Signature.
26 27 28 29 30 31 |
# File 'lib/rspec/flake/classifier/signature.rb', line 26 def initialize(message:, backtrace: []) @message = .to_s @backtrace = Array(backtrace).map(&:to_s) @normalized = normalize([@message, *@backtrace].join("\n")) @digest = Digest::SHA256.hexdigest(@normalized) end |
Instance Attribute Details
#backtrace ⇒ Array[String] (readonly)
Returns the value of attribute backtrace.
17 18 19 |
# File 'lib/rspec/flake/classifier/signature.rb', line 17 def backtrace @backtrace end |
#digest ⇒ String (readonly)
Returns the value of attribute digest.
17 18 19 |
# File 'lib/rspec/flake/classifier/signature.rb', line 17 def digest @digest end |
#message ⇒ String (readonly)
Returns the value of attribute message.
17 18 19 |
# File 'lib/rspec/flake/classifier/signature.rb', line 17 def @message end |
#normalized ⇒ String (readonly)
Returns the value of attribute normalized.
17 18 19 |
# File 'lib/rspec/flake/classifier/signature.rb', line 17 def normalized @normalized end |
Class Method Details
.from_exception(exception) ⇒ Signature
19 20 21 22 23 24 |
# File 'lib/rspec/flake/classifier/signature.rb', line 19 def self.from_exception(exception) new( message: exception., backtrace: Array(exception.backtrace) ) end |
Instance Method Details
#to_h ⇒ Hash[String, untyped]
33 34 35 36 37 38 39 40 |
# File 'lib/rspec/flake/classifier/signature.rb', line 33 def to_h { "digest" => digest, "message" => , "normalized" => normalized, "backtrace" => backtrace } end |