Class: RuleEngine
- Inherits:
-
Object
- Object
- RuleEngine
- Defined in:
- lib/rule_engine.rb
Class Attribute Summary collapse
-
.rules ⇒ Object
Returns the value of attribute rules.
Class Method Summary collapse
Class Attribute Details
.rules ⇒ Object
Returns the value of attribute rules.
17 18 19 |
# File 'lib/rule_engine.rb', line 17 def rules @rules end |
Class Method Details
.analyzeDocument(code) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rule_engine.rb', line 33 def self.analyzeDocument(code) result=[] tokens = self.getTokens(code) @rules.each do |rule| begin if rule.configurations[0].value (result << rule.AnalyzeTokens(tokens)).flatten! end rescue $logger.error("Error in running rule #{rule.name}") end end return result end |
.getTokens(code) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rule_engine.rb', line 20 def self.getTokens(code) begin lexer = PuppetLint::Lexer.new tokens = lexer.tokenise(code) rescue => error $logger.error("Error in getting tokens from Puppet-Lint") $logger.error(error.backtrace) tokens = [] end return tokens end |