<commit_before>require 'exogenesis/support/abstract_package_manager'

# Manages Homebrew - the premier package manager for Mac OS
class Homebrew < AbstractPackageManager
  # Expects an array of packages to install, a package can either be:
  # * A String: Then it will just install the package with this name
  # * An Object with a single key value pair. The key is the name of the package, the value is an array of options passed to it
  def initialize(brews)
    @brews = brews
  end

  def update
    puts "Updating Homebrew..."
    `brew update`
    puts "Upgrading the following apps: #{`brew outdated`}"
    `brew upgrade`
  end

  def install
    @brews.each do |brew|
      if brew.class == String
        install_package brew
      else
        name = brew.keys.first
        options = brew[name]
        install_package name, options
      end
    end
  end

  private

  def install_package(name, options = [])
    print "Installing #{name}... "
    status = `brew install #{name} #{options.join}`

    raise "No formula for #{name}" if status.include? "No available formula"

    if status.include? "already installed"
      puts "Already Installed!"
    else
      puts "Installed!"
    end
  end
end<commit_msg>Homebrew is now using Executor<commit_after>require 'exogenesis/support/abstract_package_manager'
require 'exogenesis/support/executor'

# Manages Homebrew - the premier package manager for Mac OS
class Homebrew < AbstractPackageManager
  # Expects an array of packages to install, a package can either be:
  # * A String: Then it will just install the package with this name
  # * An Object with a single key value pair. The key is the name of the package, the value is an array of options passed to it
  def initialize(brews)
    @brews = brews
    @executor = Executor.instance
  end

  def update
    @executor.start_section "Homebrew"
    @executor.execute "Updating Homebrew", "brew update"
    @executor.info "Outdated brews", outdated
    @executor.execute "Upgrading brews", "brew upgrade"
  end

  def install
    @executor.start_section "Homebrew"
    @brews.each do |brew|
      if brew.class == String
        install_package brew
      else
        name = brew.keys.first
        options = brew[name]
        install_package name, options
      end
    end
  end

  private

  def outdated
    `brew outdated`.split("\n").join(", ")
  end

  def install_package(name, options = [])
    @executor.execute "Installing #{name}", "brew install #{name} #{options.join}" do |output|
      raise TaskSkipped.new("Already installed") if output.include? "already installed"
    end
  end
end
{'fraction_non_alphanumeric': 0.08317436093094238, 'fraction_numerical': 0.0, 'mean_word_length': 3.0777604976671853, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7628690', 'n_tokens_mistral': 761, 'n_tokens_neox': 745, 'n_words': 288}