<commit_before># Copyright 2009 <NAME> <<EMAIL>>
# Licensed as per the GPL version 3
require 'find'
require 'fileutils'
require 'pathname'

$agent = "Homebrew 0.1 (Ruby; Mac OS X 10.5 Leopard)"
$cellar = Pathname.new(__FILE__).dirname.parent.realpath

ENV['MACOSX_DEPLOYMENT_TARGET']='10.5'
ENV['CFLAGS']=ENV['CXXFLAGS']='-O3 -w'

def h1 title
  puts "\033[0;34m==>\033[0;0;1m #{title} \033[0;0m"
end


class Formula
  # if you reimplement, assign @name, @version, @url and @md5
  def initialize(url, md5)
    @name = File.basename $0, '.rb' #original script that the interpreter started
    @url = url
    @md5 = md5

    # pls improve this version extraction crap
    filename=File.basename url
    i=filename.index /[-_]\d/
    unless i.nil?
      /^((\d+[.-])*\d+)/.match filename[i+1,1000] #1000 because rubysucks
      @version = $1
    else
      # no divisor or a '.' divisor, eg. dmd.1.11.zip
      /^[a-zA-Z._-]*((\d+\.)*\d+)/.match filename
      @version = $1
    end
  end

  #yields a Pathname object for the installation prefix
  def brew
    raise "@name.nil?" if @name.nil?
    raise "@version.nil?" if @version.nil?
    raise "@name does not validate to our regexp" unless /^\w+$/ =~ @name

    prefix=$cellar+@name+@version
    raise "#{prefix} already exists!" if prefix.exist?

    h1 "Preparing build"

    appsupport = File.expand_path "~/Library/Application Support/Homebrew"
    FileUtils.mkpath appsupport unless File.exist? appsupport
    Dir.chdir appsupport do
      tgz=Pathname.new fetch()
      raise "MD5 mismatch" unless `md5 -q "#{tgz}"`.strip == @md5.downcase

      # we make an additional subdirectory so know exactly what we are
      # recursively deleting later
      # we use mktemp rather than appsupport/blah because some build scripts
      # can't handle being built in a directory with spaces in it :P
      tmp=nil
      begin
        tmp=`mktemp -dt #{@name}-#{@version}`.strip
        Dir.chdir tmp do
          Dir.chdir uncompress(tgz) do
            yield prefix
            #TODO copy changelog or CHANGES file to pkg root,
            #TODO maybe README, etc. to versioned root
          end
        end
      ensure
        FileUtils.rm_rf tmp
      end

      # stay in appsupport in case any odd files gets created etc.
      `#{$cellar}/homebrew/brew ln #{prefix}` if prefix.exist?
      
      puts "#{prefix}: "+`find #{prefix} -type f | wc -l`.strip+' files, '+`du -hd0 #{prefix} | cut -d"\t" -f1`.strip
    end
  end

  def version
    @version
  end
  def name
    @name
  end<commit_msg>Support caveats Return a string from the brew yield block<commit_after># Copyright 2009 <NAME> <<EMAIL>>
# Licensed as per the GPL version 3
require 'find'
require 'fileutils'
require 'pathname'

$agent = "Homebrew 0.1 (Ruby; Mac OS X 10.5 Leopard)"
$cellar = Pathname.new(__FILE__).dirname.parent.realpath

ENV['MACOSX_DEPLOYMENT_TARGET']='10.5'
ENV['CFLAGS']=ENV['CXXFLAGS']='-O3 -w'

def h1 title
  puts "\033[0;34m==>\033[0;0;1m #{title} \033[0;0m"
end


class Formula
  # if you reimplement, assign @name, @version, @url and @md5
  def initialize(url, md5)
    @name = File.basename $0, '.rb' #original script that the interpreter started
    @url = url
    @md5 = md5

    # pls improve this version extraction crap
    filename=File.basename url
    i=filename.index /[-_]\d/
    unless i.nil?
      /^((\d+[.-])*\d+)/.match filename[i+1,1000] #1000 because rubysucks
      @version = $1
    else
      # no divisor or a '.' divisor, eg. dmd.1.11.zip
      /^[a-zA-Z._-]*((\d+\.)*\d+)/.match filename
      @version = $1
    end
  end

  #yields a Pathname object for the installation prefix
  def brew
    raise "@name.nil?" if @name.nil?
    raise "@version.nil?" if @version.nil?
    raise "@name does not validate to our regexp" unless /^\w+$/ =~ @name

    prefix=$cellar+@name+@version
    raise "#{prefix} already exists!" if prefix.exist?

    h1 "Preparing build"

    appsupport = File.expand_path "~/Library/Application Support/Homebrew"
    FileUtils.mkpath appsupport unless File.exist? appsupport
    Dir.chdir appsupport do
      tgz=Pathname.new fetch()
      raise "MD5 mismatch" unless `md5 -q "#{tgz}"`.strip == @md5.downcase

      # we make an additional subdirectory so know exactly what we are
      # recursively deleting later
      # we use mktemp rather than appsupport/blah because some build scripts
      # can't handle being built in a directory with spaces in it :P
      tmp=nil
      begin
        tmp=`mktemp -dt #{@name}-#{@version}`.strip
        Dir.chdir tmp do
          Dir.chdir uncompress(tgz) do
            caveats = yield prefix
            if caveats
              h1 "Caveats"
              puts caveats
              h1 "Summary"
            end
            #TODO copy changelog or CHANGES file to pkg root,
            #TODO maybe README, etc. to versioned root
          end
        end
      ensure
        FileUtils.rm_rf tmp
      end

      # stay in appsupport in case any odd files gets created etc.
      `#{$cellar}/homebrew/brew ln #{prefix}` if prefix.exist?
      
      puts "#{prefix}: "+`find #{prefix} -type f | wc -l`.strip+' files, '+`du -hd0 #{prefix} | cut -d"\t" -f1`.strip
    end
  end

  def version
    @version
  end
  def name
    @name
  end
{'fraction_non_alphanumeric': 0.12561576354679804, 'fraction_numerical': 0.02197802197802198, 'mean_word_length': 2.550100874243443, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2196625', 'n_tokens_mistral': 1829, 'n_tokens_neox': 1722, 'n_words': 566}