Sha256: 6aa35e31154336af8ef3caa943bd6b856ea4eadcb6ee15049c5b205a384dd08b

Contents?: true

Size: 547 Bytes

Versions: 4

Compression:

Stored size: 547 Bytes

Contents

require 'erb'

module Overcommit::GitHook
  class ErbSyntax < HookSpecificCheck
    include HookRegistry
    file_type :erb
    ERB_CHECKER = 'bin/check-rails-erb'

    def skip?
      return 'Bundler is not installed' unless in_path? 'bundle'
      unless File.executable? ERB_CHECKER
        return "Can't find/execute #{ERB_CHECKER}"
      end
    end

    def run_check
      output = `bundle exec #{ERB_CHECKER} #{staged.map{ |file| file.path }.join(' ')}`
      return (output !~ /: compile error$/ ? :good : :bad), output
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
overcommit-0.2.3 lib/overcommit/plugins/pre_commit/erb_syntax.rb
overcommit-0.2.2 lib/overcommit/plugins/pre_commit/erb_syntax.rb
overcommit-0.2.1 lib/overcommit/plugins/pre_commit/erb_syntax.rb
overcommit-0.2.0 lib/overcommit/plugins/pre_commit/erb_syntax.rb