Class: GitHook::Hooks::RubySyntaxCheck
- Inherits:
-
GitHook::Hook
- Object
- GitHook::Hook
- GitHook::Hooks::RubySyntaxCheck
- Defined in:
- lib/git_hook/hooks/ruby_syntax_check.rb
Defined Under Namespace
Classes: Parser
Instance Method Summary collapse
Methods inherited from GitHook::Hook
class_name, #error, gem_name, #git, #info, #initialize, #options, resolve, #timing, #warn
Constructor Details
This class inherits a constructor from GitHook::Hook
Instance Method Details
#invoke ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/git_hook/hooks/ruby_syntax_check.rb', line 5 def invoke result = true extensions = [:extensions] || ['rb'] git.status.changed.merge(git.status.added).each_pair do | file, obj | if file =~ /\.(#{extensions.join('|')})$/ parser = Parser.new(open(file){|f| f.read}, file) parser.parse() parser.errors.each do | err | error(err) end parser.warns.each do | warning | warn(warning) end result = result && parser.errors.empty? end end return result end |