<commit_before># frozen_string_literal: true

# Class corresponding to the `url` stanza.
#
# @api private
class URL
  ATTRIBUTES = [
    :using,
    :tag, :branch, :revisions, :revision,
    :trust_cert, :cookies, :referer, :user_agent,
    :data
  ].freeze
  private_constant :ATTRIBUTES

  attr_reader :uri, :specs, *ATTRIBUTES

  extend Forwardable
  def_delegators :uri, :path, :scheme, :to_s

  def initialize(uri, **options)
    @uri        = URI(uri)
    @user_agent = :default

    ATTRIBUTES.each do |attribute|
      next unless options.key?(attribute)

      instance_variable_set("@#{attribute}", options[attribute])
    end

    @specs = options
  end
end<commit_msg>Fix type-checking for `URL`.<commit_after># typed: strict
# frozen_string_literal: true

require "utils/sorbet"

# Class corresponding to the `url` stanza.
#
# @api private
class URL
  extend T::Sig

  attr_reader :uri, :specs,
              :using,
              :tag, :branch, :revisions, :revision,
              :trust_cert, :cookies, :referer, :user_agent,
              :data

  extend Forwardable
  def_delegators :uri, :path, :scheme, :to_s

  sig do
    params(
      uri:        T.any(URI::Generic, String),
      using:      T.nilable(Symbol),
      tag:        T.nilable(String),
      branch:     T.nilable(String),
      revisions:  T.nilable(T::Array[String]),
      revision:   T.nilable(String),
      trust_cert: T.nilable(T::Boolean),
      cookies:    T.nilable(T::Hash[String, String]),
      referer:    T.nilable(T.any(URI::Generic, String)),
      user_agent: T.nilable(T.any(Symbol, String)),
      data:       T.nilable(T::Hash[String, String]),
    ).returns(T.untyped)
  end
  def initialize(
    uri,
    using: nil,
    tag: nil,
    branch: nil,
    revisions: nil,
    revision: nil,
    trust_cert: nil,
    cookies: nil,
    referer: nil,
    user_agent: nil,
    data: nil
  )
    @uri = URI(uri)

    specs = {}
    specs[:using]      = @using      = using
    specs[:tag]        = @tag        = tag
    specs[:branch]     = @branch     = branch
    specs[:revisions]  = @revisions  = revisions
    specs[:revision]   = @revision   = revision
    specs[:trust_cert] = @trust_cert = trust_cert
    specs[:cookies]    = @cookies    = cookies
    specs[:referer]    = @referer    = referer
    specs[:user_agent] = @user_agent = user_agent || :default
    specs[:data]       = @data       = data

    @specs = specs.compact
  end
end
{'fraction_non_alphanumeric': 0.13000817661488143, 'fraction_numerical': 0.0, 'mean_word_length': 2.5827232796486093, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6511453', 'n_tokens_mistral': 863, 'n_tokens_neox': 846, 'n_words': 192}