class Pedant::CheckParseTestCode
Public Class Methods
provides()
click to toggle source
Calls superclass method
Pedant::Check::provides
# File lib/pedant/checks/parse_test_code.rb, line 33 def self.provides super + [:trees] end
requires()
click to toggle source
Calls superclass method
Pedant::Check::requires
# File lib/pedant/checks/parse_test_code.rb, line 29 def self.requires super + [:codes, :main, :test_mode] end
Public Instance Methods
import(path)
click to toggle source
# File lib/pedant/checks/parse_test_code.rb, line 38 def import(path) # Since there are potentially several ways to write the path leading to # a file, we'll use the basename as the key for hashes. This will # prevent parsing the same file multiple times. file = path.basename # Mark a placeholder key in the KB for this file. This will prevent us # from trying to parse a library more than once if there is a failure. @kb[:trees][file] = :pending tree = Nasl::Parser.new.parse(@kb[:codes][file], path) @kb[:trees][file] = tree report(:info, "Parsed contents of #{path}.") end
run()
click to toggle source
# File lib/pedant/checks/parse_test_code.rb, line 37 def run def import(path) # Since there are potentially several ways to write the path leading to # a file, we'll use the basename as the key for hashes. This will # prevent parsing the same file multiple times. file = path.basename # Mark a placeholder key in the KB for this file. This will prevent us # from trying to parse a library more than once if there is a failure. @kb[:trees][file] = :pending tree = Nasl::Parser.new.parse(@kb[:codes][file], path) @kb[:trees][file] = tree report(:info, "Parsed contents of #{path}.") end # This check will pass by default. pass # Initialize the keys written by this check. @kb[:trees] = {} # Load up the main file. import(@kb[:main]) end