Class Ohcount::Gestalt::CHeaderRule
In: lib/gestalt/rules/c_header_rule.rb
Parent: FileRule

Triggers if a c or cpp header is present

Methods

new   regexp   trigger_file?  

Attributes

headers  [R] 

Public Class methods

[Source]

# File lib/gestalt/rules/c_header_rule.rb, line 7
                        def initialize(*args)
                                options = args.pop if args.last.is_a?(Hash)
                                @headers = args
                                super(options)
                        end

Public Instance methods

[Source]

# File lib/gestalt/rules/c_header_rule.rb, line 19
                        def regexp
                                @regexp ||= begin
                                        header_term = "(" + headers.join("|") + ")"
                                        Regexp.new("include\s+['<\"]#{ header_term }[\">']", Regexp::IGNORECASE)
                                end
                        end

[Source]

# File lib/gestalt/rules/c_header_rule.rb, line 13
                        def trigger_file?(source_file)
                                return false unless ['c','cpp'].include?(source_file.polyglot)
                                regexp.match(source_file.language_breakdown('c').code) ||
                                        regexp.match(source_file.language_breakdown('cpp').code)
                        end

[Validate]