<commit_before>require 'dinghy/constants'

module Plist
  def up
    halt

    puts starting_message
    system!("linking", "cp", plist_path.to_s, plist_install_path.to_s)
    system!("launching", "launchctl", "load", "-w", plist_install_path.to_s)
  end

  def halt
    if File.exist?(plist_install_path)
      puts stopping_message
      system!("stopping", "launchctl", "unload", "-w", plist_install_path.to_s)
      system!("removing", "rm", plist_install_path.to_s)
    end
  end

  def plist_install_path
    "#{HOME}/Library/LaunchAgents/#{plist_name}"
  end

  def plist_path
    DINGHY+plist_name
  end

  def system!(step, *args)
    system(*args.map(&:to_s)) || raise("Error with the #{name} daemon during #{step}")
  end

  def starting_message
    "Starting the #{name} daemon"
  end

  def stopping_message
    "Stopping the #{name} daemon"
  end<commit_msg>make sure the plist install dir exists<commit_after>require 'dinghy/constants'

module Plist
  def up
    halt

    puts starting_message
    system!("preparing", "mkdir", "-p", File.dirname(plist_install_path.to_s))
    system!("linking", "cp", plist_path.to_s, plist_install_path.to_s)
    system!("launching", "launchctl", "load", "-w", plist_install_path.to_s)
  end

  def halt
    if File.exist?(plist_install_path)
      puts stopping_message
      system!("stopping", "launchctl", "unload", "-w", plist_install_path.to_s)
      system!("removing", "rm", plist_install_path.to_s)
    end
  end

  def plist_install_path
    "#{HOME}/Library/LaunchAgents/#{plist_name}"
  end

  def plist_path
    DINGHY+plist_name
  end

  def system!(step, *args)
    system(*args.map(&:to_s)) || raise("Error with the #{name} daemon during #{step}")
  end

  def starting_message
    "Starting the #{name} daemon"
  end

  def stopping_message
    "Stopping the #{name} daemon"
  end
{'fraction_non_alphanumeric': 0.1314935064935065, 'fraction_numerical': 0.0, 'mean_word_length': 3.8915343915343916, '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': '2533860', 'n_tokens_mistral': 672, 'n_tokens_neox': 659, 'n_words': 147}