<commit_before>require 'open-uri'
require 'vendor/multi_json'

class AbstractDownloadStrategy
  def initialize name, package
    @url = package.url
    specs = package.specs
    @spec, @ref = specs.dup.shift unless specs.empty?
  end

  def expand_safe_system_args args
    args = args.dup
    args.each_with_index do |arg, ii|
      if arg.is_a? Hash
        unless ARGV.verbose?
          args[ii] = arg[:quiet_flag]
        else
          args.delete_at ii
        end
        return args
      end
    end
    # 2 as default because commands are eg. svn up, git pull
    args.insert(2, '-q') unless ARGV.verbose?
    args
  end

  def quiet_safe_system *args
    safe_system(*expand_safe_system_args(args))
  end
end

class CurlDownloadStrategy < AbstractDownloadStrategy
  attr_accessor :local_bottle_path

  def initialize name, package
    super<commit_msg>Add required methods to AbstractDownloadStrategy<commit_after>require 'open-uri'
require 'vendor/multi_json'

class AbstractDownloadStrategy
  def initialize name, package
    @url = package.url
    specs = package.specs
    @spec, @ref = specs.dup.shift unless specs.empty?
  end

  def expand_safe_system_args args
    args = args.dup
    args.each_with_index do |arg, ii|
      if arg.is_a? Hash
        unless ARGV.verbose?
          args[ii] = arg[:quiet_flag]
        else
          args.delete_at ii
        end
        return args
      end
    end
    # 2 as default because commands are eg. svn up, git pull
    args.insert(2, '-q') unless ARGV.verbose?
    args
  end

  def quiet_safe_system *args
    safe_system(*expand_safe_system_args(args))
  end

  # All download strategies are expected to implement these methods
  def fetch; end
  def stage; end
  def cached_location; end
end

class CurlDownloadStrategy < AbstractDownloadStrategy
  attr_accessor :local_bottle_path

  def initialize name, package
    super
{'fraction_non_alphanumeric': 0.06656101426307448, 'fraction_numerical': 0.0021130480718436345, 'mean_word_length': 2.8732106339468304, 'pattern_counts': {'":': 0, '<': 5, '<?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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7470401', 'n_tokens_mistral': 594, 'n_tokens_neox': 574, 'n_words': 175}