3 # Will trigger if the given keywords are found in the specified language.
7 # c_keywords '__MSDOS__', 'MSDOS', :min => 2
8 # # this will trigger if the words "__MSDOS__" or "MSDOS" is found at
9 # # least twice in 'C' source code
11 class KeywordRule < FileRule
12 attr_reader :keywords, :language
14 def initialize(language, *args)
15 options = args.pop if args.last.is_a?(Hash)
22 def process_source_file(source_file)
23 return unless source_file.language_breakdown(language)
25 code = source_file.language_breakdown(language).code
26 @count += code.scan(regexp).size
31 Regexp.new("(" + keywords.join("|") + ")")