<commit_before>require 'formula'

def postgres_installed?
  `which pg_config`.length > 0
end

class Php53 < Formula
  homepage 'http://php.net'
  url 'http://www.php.net/get/php-5.3.15.tar.bz2/from/this/mirror'
  md5 '5cfcfd0fa4c4da7576f397073e7993cc'
  version '5.3.15'

  # So PHP extensions don't report missing symbols
  skip_clean ['bin', 'sbin']

  depends_on 'freetds' if ARGV.include? '--with-mssql'
  depends_on 'gettext'
  depends_on 'gmp' if ARGV.include? '--with-gmp'
  depends_on 'icu4c' if ARGV.include? '--with-intl'
  depends_on 'imap-uw' if ARGV.include? '--with-imap'
  depends_on 'jpeg'
  depends_on 'libevent' if ARGV.include? '--with-fpm'
  depends_on 'libxml2'
  depends_on 'mcrypt'
  depends_on 'openssl' if ARGV.include? '--with-homebrew-openssl'
  depends_on 'tidy' if ARGV.include? '--with-tidy'
  depends_on 'unixodbc' if ARGV.include? '--with-unixodbc'
  depends_on 'homebrew/dupes/zlib'

  # Sanity Checks
  mysql_opts = [ '--with-libmysql', '--with-mariadb', '--with-mysql' ]
  if ARGV.length - (ARGV - mysql_opts).length > 1
    raise "Cannot specify more than one MySQL variant to build against."
  end

  if ARGV.include? '--with-pgsql'
    depends_on 'postgresql' => :recommended unless postgres_installed?
  end

  if ARGV.include? '--with-cgi' and ARGV.include? '--with-fpm'
    raise "Cannot specify more than one executable to build."
  end

  if ARGV.include? '--with-cgi' or ARGV.include? '--with-fpm'
    ARGV << '--without-apache' unless ARGV.include? '--without-apache'
  end

  def options
   [
     ['--with-libmysql', 'Include (old-style) libmysql support'],
     ['--with-mariadb', 'Include MariaDB support'],
     ['--with-mysql', 'Include MySQL support'],
     ['--with-pgsql', 'Include PostgreSQL support'],
     ['--with-mssql', 'Include MSSQL-DB support'],
     ['--with-unixodbc', 'Include unixODBC support'],
     ['--with-cgi', 'Enable building of the CGI executable (implies --without-apache)'],
     ['--with-fpm', 'Enable building of the fpm SAPI executable (implies --without-apache)'],
     ['--without-apache', 'Build without shared Apache 2.0 Handler module'],
     ['--with-intl', 'Include internationalization support'],
     ['--with-imap', 'Include IMAP extension'],
     ['--with-gmp', 'Include GMP support'],
     ['--with-suhosin', 'Include Suhosin patch'],
     ['--with-tidy', 'Include Tidy support'],
     ['--without-pear', 'Build without PEAR'],
     ['--with-homebrew-openssl', 'Include OpenSSL support via Homebrew'],
   ]
  end

  def patches
    "http://download.suhosin.org/suhosin-patch-5.3.9-0.9.10.patch.gz" if ARGV.include? '--with-suhosin'
  end

  def config_path
    etc+"php/5.3"
  end

  def install
    # Not removing all pear.conf's from PHP path results in the PHP
    # configure not properly setting the pear binary to be installed
    config_pear = "#{config_path}/pear.conf"
    user_pear = "#{home_path}/pear.conf"
    if File.exists?(config_pear) || File.exists?(user_pear)
      opoo "Backing up all known pear.conf files"
      opoo <<-INFO
If you have a pre-existing pear install outside
         of homebrew-php, and you are using a non-standard
         pear.conf location, installation may fail.
INFO
      FileUtils.mv(config_pear, "#{config_pear}-backup") if File.exists? config_pear
      FileUtils.mv(user_pear, "#{user_pear}-backup") if File.exists? user_pear
    end

    begin
      _install
      FileUtils.rm_f("#{config_pear}-backup")<commit_msg>Added missing home_path method. Closes #225<commit_after>require 'formula'

def postgres_installed?
  `which pg_config`.length > 0
end

class Php53 < Formula
  homepage 'http://php.net'
  url 'http://www.php.net/get/php-5.3.15.tar.bz2/from/this/mirror'
  md5 '5cfcfd0fa4c4da7576f397073e7993cc'
  version '5.3.15'

  # So PHP extensions don't report missing symbols
  skip_clean ['bin', 'sbin']

  depends_on 'freetds' if ARGV.include? '--with-mssql'
  depends_on 'gettext'
  depends_on 'gmp' if ARGV.include? '--with-gmp'
  depends_on 'icu4c' if ARGV.include? '--with-intl'
  depends_on 'imap-uw' if ARGV.include? '--with-imap'
  depends_on 'jpeg'
  depends_on 'libevent' if ARGV.include? '--with-fpm'
  depends_on 'libxml2'
  depends_on 'mcrypt'
  depends_on 'openssl' if ARGV.include? '--with-homebrew-openssl'
  depends_on 'tidy' if ARGV.include? '--with-tidy'
  depends_on 'unixodbc' if ARGV.include? '--with-unixodbc'
  depends_on 'homebrew/dupes/zlib'

  # Sanity Checks
  mysql_opts = [ '--with-libmysql', '--with-mariadb', '--with-mysql' ]
  if ARGV.length - (ARGV - mysql_opts).length > 1
    raise "Cannot specify more than one MySQL variant to build against."
  end

  if ARGV.include? '--with-pgsql'
    depends_on 'postgresql' => :recommended unless postgres_installed?
  end

  if ARGV.include? '--with-cgi' and ARGV.include? '--with-fpm'
    raise "Cannot specify more than one executable to build."
  end

  if ARGV.include? '--with-cgi' or ARGV.include? '--with-fpm'
    ARGV << '--without-apache' unless ARGV.include? '--without-apache'
  end

  def options
   [
     ['--with-libmysql', 'Include (old-style) libmysql support'],
     ['--with-mariadb', 'Include MariaDB support'],
     ['--with-mysql', 'Include MySQL support'],
     ['--with-pgsql', 'Include PostgreSQL support'],
     ['--with-mssql', 'Include MSSQL-DB support'],
     ['--with-unixodbc', 'Include unixODBC support'],
     ['--with-cgi', 'Enable building of the CGI executable (implies --without-apache)'],
     ['--with-fpm', 'Enable building of the fpm SAPI executable (implies --without-apache)'],
     ['--without-apache', 'Build without shared Apache 2.0 Handler module'],
     ['--with-intl', 'Include internationalization support'],
     ['--with-imap', 'Include IMAP extension'],
     ['--with-gmp', 'Include GMP support'],
     ['--with-suhosin', 'Include Suhosin patch'],
     ['--with-tidy', 'Include Tidy support'],
     ['--without-pear', 'Build without PEAR'],
     ['--with-homebrew-openssl', 'Include OpenSSL support via Homebrew'],
   ]
  end

  def patches
    "http://download.suhosin.org/suhosin-patch-5.3.9-0.9.10.patch.gz" if ARGV.include? '--with-suhosin'
  end

  def config_path
    etc+"php/5.3"
  end

  def home_path
    File.expand_path("~")
  end

  def install
    # Not removing all pear.conf's from PHP path results in the PHP
    # configure not properly setting the pear binary to be installed
    config_pear = "#{config_path}/pear.conf"
    user_pear = "#{home_path}/pear.conf"
    if File.exists?(config_pear) || File.exists?(user_pear)
      opoo "Backing up all known pear.conf files"
      opoo <<-INFO
If you have a pre-existing pear install outside
         of homebrew-php, and you are using a non-standard
         pear.conf location, installation may fail.
INFO
      FileUtils.mv(config_pear, "#{config_pear}-backup") if File.exists? config_pear
      FileUtils.mv(user_pear, "#{user_pear}-backup") if File.exists? user_pear
    end

    begin
      _install
      FileUtils.rm_f("#{config_pear}-backup")
{'fraction_non_alphanumeric': 0.15063598685150778, 'fraction_numerical': 0.013291410604544805, 'mean_word_length': 3.2906192519926427, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7342996', 'n_tokens_mistral': 2577, 'n_tokens_neox': 2481, 'n_words': 632}