[NEW] Gestalts for silverlight + popular JS libs
[ohcount] / ruby / gestalt / rules / csharp_using_rule.rb
1 module Ohcount
2         module Gestalt
3
4                 # Triggers if a matching C# 'using' library include statement is present
5                 class CSharpUsingRule < FileRule
6
7                         def initialize(*args)
8                                 @regex = args.shift
9                                 super(args)
10                         end
11
12                         def process_source_file(source_file)
13                                 return false unless source_file.language_breakdown('csharp')
14
15         source_file.language_breakdown('csharp').code.scan(using_regexp).each do |match|
16           @count += 1 if match[0] =~ @regex
17         end
18                         end
19
20                         def using_regexp
21                                 @@using_regexp ||= /^\s*using\s+([a-zA-Z][\w\.\*\-]*)\s*;/
22                         end
23                 end
24         end
25 end