<commit_before>require 'date'

class Editor
  attr_accessor :clock, :month, :days_picked

  def initialize(clock)
    @clock = clock
    @month = clock.month
  end

  def run
    fill_month
    loop do
      print_month
      input = prompt
      exit if %w(q quit exit).include? input
      break if input == 'x'
      clock.edit_brf if input == 'e'
      if days_picked?
        begin
          days_picked.each do |d|
            day = month.days[d - 1]
            blocks = input.strip.split(/\s+/).map { |block_str|
              Block.new block_str, day }
            day.add *blocks
          end
          reset!
        rescue
          next
        end
      else
        @days_picked = input.split(/,|\s+/).map!(&:to_i) unless input.empty?
      end
    end
  ensure
    month.cleanup!
    system 'clear'
  end

  private

  def config
    clock.config
  end

  def fill_month<commit_msg>Ctrl-c should exit like q without an ugly stack trace<commit_after>require 'date'

class Editor
  attr_accessor :clock, :month, :days_picked

  def initialize(clock)
    @clock = clock
    @month = clock.month
  end

  def run
    fill_month
    loop do
      print_month
      input = prompt
      exit if %w(q quit exit).include? input
      break if input == 'x'
      clock.edit_brf if input == 'e'
      if days_picked?
        begin
          days_picked.each do |d|
            day = month.days[d - 1]
            blocks = input.strip.split(/\s+/).map { |block_str|
              Block.new block_str, day }
            day.add *blocks
          end
          reset!
        rescue
          next
        end
      else
        @days_picked = input.split(/,|\s+/).map!(&:to_i) unless input.empty?
      end
    end
  rescue Interrupt, SystemExit
    exit
  ensure
    month.cleanup!
    system 'clear'
  end

  private

  def config
    clock.config
  end

  def fill_month
{'fraction_non_alphanumeric': 0.09052183173588925, 'fraction_numerical': 0.0010649627263045794, 'mean_word_length': 1.6958393113342898, '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': '1247211', 'n_tokens_mistral': 609, 'n_tokens_neox': 594, 'n_words': 168}