Class: Syntaxer::RepoChecker

Inherits:
Checker
  • Object
show all
Defined in:
lib/syntaxer/checker.rb

Overview

Check status of files in repository

Instance Attribute Summary

Attributes inherited from Checker

#reader, #syntaxer

Instance Method Summary collapse

Methods inherited from Checker

process

Constructor Details

#initialize(syntaxer) ⇒ RepoChecker

Returns a new instance of RepoChecker.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/syntaxer/checker.rb', line 61

def initialize syntaxer
  @syntaxer = syntaxer
  count_of_files = 0
  @rule_files = {}
  @deferred_process = []
  syntaxer.reader.rules.each do |rule|
    @rule_files[rule.name] = {}
    @rule_files[rule.name][:rule] = rule
    @rule_files[rule.name][:files] = []
    rule.extensions.each do |ext|
      files.each do |file|
        if File.extname(file).gsub(/\./,'') == ext || \
          (!rule.specific_files.nil? && !@rule_files[rule.name][:files].include?(file) && rule.specific_files.include?(file))
          
          @rule_files[rule.name][:files].push(file)
          count_of_files += 1 if !rule.deferred # skip these files
        end
      end
    end
  end
  
  super syntaxer, count_of_files 
end

Instance Method Details

#processObject

Check syntax in repository directory

See Also:



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/syntaxer/checker.rb', line 89

def process
  @rule_files.each do |rule_name, rule|
    if rule[:rule].deferred
      @deferred_process << rule
    else
      rule[:files].each do |file|
        full_path = File.join(@syntaxer.root_path,file)
        check(rule[:rule], full_path)
      end
    end
  end

  @deferred_process.each do |rule|
    rule[:rule].exec_rule.run(@syntaxer.root_path, rule[:files])
  end

  self
end