<commit_before>require 'formula_support'
require 'formula_lock'
require 'formula_pin'
require 'hardware'
require 'bottles'
require 'compilers'
require 'build_environment'
require 'build_options'
require 'formulary'
require 'software_spec'
require 'install_renamed'
require 'pkg_version'

class Formula
  include FileUtils
  include Utils::Inreplace
  extend Enumerable

  attr_reader :name, :path, :homepage, :build
  attr_reader :stable, :devel, :head, :active_spec
  attr_reader :pkg_version, :revision

  # The current working directory during builds and tests.
  # Will only be non-nil inside #stage and #test.
  attr_reader :buildpath, :testpath

  attr_accessor :local_bottle_path

  def initialize(name, path, spec)
    @name = name
    @path = path
    @homepage = self.class.homepage
    @revision = self.class.revision || 0

    set_spec :stable
    set_spec :devel
    set_spec :head

    @active_spec = determine_active_spec(spec)
    validate_attributes :url, :name, :version
    @build = determine_build_options
    @pkg_version = PkgVersion.new(version, revision)

    @pin = FormulaPin.new(self)
  end

  def set_spec(name)
    spec = self.class.send(name)
    if spec.url
      spec.owner = self
      instance_variable_set("@#{name}", spec)
    end
  end

  def determine_active_spec(requested)
    spec = send(requested) || stable || devel || head
    spec or raise FormulaSpecificationError, "formulae require at least a URL"
  end

  def validate_attributes(*attrs)
    attrs.each do |attr|
      if (value = send(attr).to_s).empty? || value =~ /\s/
        raise FormulaValidationError.new(attr, value)
      end
    end
  end

  def determine_build_options
    build = active_spec.build
    options.each { |opt, desc| build.add(opt, desc) }
    build
  end

  def bottle
    Bottle.new(self, active_spec.bottle_specification) if active_spec.bottled?
  end

  def url;      active_spec.url;     end
  def version;  active_spec.version; end
  def mirrors;  active_spec.mirrors; end

  def resource(name)
    active_spec.resource(name)
  end

  def resources
    active_spec.resources.values
  end

  def deps
    active_spec.deps
  end

  def requirements
    active_spec.requirements
  end

  def cached_download
    active_spec.cached_download
  end

  def clear_cache
    active_spec.clear_cache
  end

  def patchlist
    active_spec.patches
  end<commit_msg>Stop exposing mirrors array<commit_after>require 'formula_support'
require 'formula_lock'
require 'formula_pin'
require 'hardware'
require 'bottles'
require 'compilers'
require 'build_environment'
require 'build_options'
require 'formulary'
require 'software_spec'
require 'install_renamed'
require 'pkg_version'

class Formula
  include FileUtils
  include Utils::Inreplace
  extend Enumerable

  attr_reader :name, :path, :homepage, :build
  attr_reader :stable, :devel, :head, :active_spec
  attr_reader :pkg_version, :revision

  # The current working directory during builds and tests.
  # Will only be non-nil inside #stage and #test.
  attr_reader :buildpath, :testpath

  attr_accessor :local_bottle_path

  def initialize(name, path, spec)
    @name = name
    @path = path
    @homepage = self.class.homepage
    @revision = self.class.revision || 0

    set_spec :stable
    set_spec :devel
    set_spec :head

    @active_spec = determine_active_spec(spec)
    validate_attributes :url, :name, :version
    @build = determine_build_options
    @pkg_version = PkgVersion.new(version, revision)

    @pin = FormulaPin.new(self)
  end

  def set_spec(name)
    spec = self.class.send(name)
    if spec.url
      spec.owner = self
      instance_variable_set("@#{name}", spec)
    end
  end

  def determine_active_spec(requested)
    spec = send(requested) || stable || devel || head
    spec or raise FormulaSpecificationError, "formulae require at least a URL"
  end

  def validate_attributes(*attrs)
    attrs.each do |attr|
      if (value = send(attr).to_s).empty? || value =~ /\s/
        raise FormulaValidationError.new(attr, value)
      end
    end
  end

  def determine_build_options
    build = active_spec.build
    options.each { |opt, desc| build.add(opt, desc) }
    build
  end

  def bottle
    Bottle.new(self, active_spec.bottle_specification) if active_spec.bottled?
  end

  def url;      active_spec.url;     end
  def version;  active_spec.version; end

  def resource(name)
    active_spec.resource(name)
  end

  def resources
    active_spec.resources.values
  end

  def deps
    active_spec.deps
  end

  def requirements
    active_spec.requirements
  end

  def cached_download
    active_spec.cached_download
  end

  def clear_cache
    active_spec.clear_cache
  end

  def patchlist
    active_spec.patches
  end
{'fraction_non_alphanumeric': 0.08289390423961189, 'fraction_numerical': 0.0004218519299725796, 'mean_word_length': 3.5421455938697317, 'pattern_counts': {'":': 0, '<': 3, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '91717', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1515, 'n_words': 404}