Sha256: be80b5f7bd0bc5f6ade78b4579096edffab5711036eeaee8f6df4c91a7ca3221

Contents?: true

Size: 698 Bytes

Versions: 5

Compression:

Stored size: 698 Bytes

Contents

#!/usr/bin/env ruby

<% Array(lookup('gem_path')).each do |p| -%>
$LOAD_PATH.unshift '<%= p %>'
<% end -%>

require 'git_hook-pre_receive'
require 'pac'
require 'uri'

class PacFileSyntaxChecker
  def check(files)
    files.each do |f|
      begin
        pac = PAC.source f.content
        pac.find('http://www.example.com')
      rescue => e
        $stderr.puts "Maybe I found a syntax error in file \"#{f.name}\". Please check files locally again, e.g with a pac file tester, fix the error and send update via git. The original error was: #{e.message}"
        exit 1
      end
    end
  end
end

parser = Git::PreReceiveHookParser.new($stdin.read)
PacFileSyntaxChecker.new.check(parser.files)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
local_pac-0.3.0 files/git-hook.erb
local_pac-0.2.3 files/git-hook.erb
local_pac-0.2.2 files/git-hook.erb
local_pac-0.2.1 files/git-hook.erb
local_pac-0.2.0 files/git-hook.erb