Skip to content

Commit

Permalink
Resolve #389: Add line numbers to recog_verify output
Browse files Browse the repository at this point in the history
  • Loading branch information
dabdine committed Dec 5, 2021
1 parent e4febeb commit 7f9a7f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions lib/recog/fingerprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class Fingerprint
# @return (see #parse_examples)
attr_reader :tests

# The line number of the XML entity in the source file for this
# fingerprint.
#
# @return [Integer] The line number of this entity.
attr_reader :line

# @param xml [Nokogiri::XML::Element]
# @param match_key [String] See Recog::DB
# @param protocol [String] Protocol such as ftp, mssql, http, etc.
Expand All @@ -37,6 +43,7 @@ def initialize(xml, match_key=nil, protocol=nil, filepath=nil)
@protocol = protocol
@name = parse_description(xml)
@regex = create_regexp(xml)
@line = xml.line
@params = {}
@tests = []

Expand Down
8 changes: 4 additions & 4 deletions lib/recog/verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ def verify
fp.verify_params do |status, message|
case status
when :warn
reporter.warning "WARN: #{message}"
reporter.warning "WARN (line #{fp.line}): #{message}"
when :fail
reporter.failure "FAIL: #{message}"
reporter.failure "FAIL (line #{fp.line}): #{message}"
when :success
reporter.success(message)
end
end
fp.verify_tests do |status, message|
case status
when :warn
reporter.warning "WARN: #{message}"
reporter.warning "WARN (line #{fp.line}): #{message}"
when :fail
reporter.failure "FAIL: #{message}"
reporter.failure "FAIL (line #{fp.line}): #{message}"
when :success
reporter.success(message)
end
Expand Down

0 comments on commit 7f9a7f8

Please sign in to comment.