<commit_before>require 'exceptions'
require 'formula'
require 'keg'
require 'tab'
require 'bottles'

class FormulaInstaller
  attr :f
  attr :tab
  attr :show_summary_heading, true
  attr :ignore_deps, true
  attr :install_bottle, true
  attr :show_header, true

  def initialize ff, tab=nil
    @f = ff
    @tab = tab
    @show_header = true
    @ignore_deps = ARGV.include? '--ignore-dependencies' || ARGV.interactive?
    @install_bottle = install_bottle? ff

    check_install_sanity
  end

  def check_install_sanity
    if f.installed?
      raise CannotInstallFormulaError, "#{f}-#{f.version} already installed"
    end

    # Building head-only without --HEAD is an error
    if not ARGV.build_head? and f.stable.nil?
      raise CannotInstallFormulaError, <<-EOS.undent
        #{f} is a head-only formula
        Install with `brew install --HEAD #{f.name}
      EOS
    end

    # Building stable-only with --HEAD is an error
    if ARGV.build_head? and f.head.nil?
      raise CannotInstallFormulaError, "No head is defined for #{f.name}"
    end

    f.recursive_deps.each do |dep|
      if dep.installed? and not dep.keg_only? and not dep.linked_keg.directory?<commit_msg>Refer to the real keg when dying because the keg exists<commit_after>require 'exceptions'
require 'formula'
require 'keg'
require 'tab'
require 'bottles'

class FormulaInstaller
  attr :f
  attr :tab
  attr :show_summary_heading, true
  attr :ignore_deps, true
  attr :install_bottle, true
  attr :show_header, true

  def initialize ff, tab=nil
    @f = ff
    @tab = tab
    @show_header = true
    @ignore_deps = ARGV.include? '--ignore-dependencies' || ARGV.interactive?
    @install_bottle = install_bottle? ff

    check_install_sanity
  end

  def check_install_sanity
    if f.installed?
      keg = Keg.new(f.installed_prefix)
      raise CannotInstallFormulaError, "#{f}-#{keg.version} already installed"
    end

    # Building head-only without --HEAD is an error
    if not ARGV.build_head? and f.stable.nil?
      raise CannotInstallFormulaError, <<-EOS.undent
        #{f} is a head-only formula
        Install with `brew install --HEAD #{f.name}
      EOS
    end

    # Building stable-only with --HEAD is an error
    if ARGV.build_head? and f.head.nil?
      raise CannotInstallFormulaError, "No head is defined for #{f.name}"
    end

    f.recursive_deps.each do |dep|
      if dep.installed? and not dep.keg_only? and not dep.linked_keg.directory?
{'fraction_non_alphanumeric': 0.09324104234527687, 'fraction_numerical': 0.0, 'mean_word_length': 3.12248322147651, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '232780', 'n_tokens_mistral': 852, 'n_tokens_neox': 812, 'n_words': 243}