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)
24 return unless source_file.language_breakdown(language)
25 @count += source_file.language_breakdown(language).code.scan(regexp).size
28 source_file.language_breakdowns.each do |lb|
29 @count += lb.code.to_s.scan(regexp).size
36 Regexp.new("(" + keywords.join("|") + ")")