<commit_before>module Dooby
  
  class List

    attr_reader :location
    
    include DatesHelper

    def initialize(location)
      @location = location
      @tasks = {}
      load!
    end
    
    def flush!
      @tasks = {}
      save!
    end
    
    def add(task = Task.new)
      yield task if block_given?
      task = handle_tomorrow_tag task     
      @tasks[task.id] = task
      save!
    end

    def delete!(task_id)
      if @tasks.delete task_id
        save!
      else
        false
      end
    end
    
    def bulk_delete!(terms)
      only_tags = terms.only_tags *SPECIAL_CHARS
      matches = []
      @tasks.each do |id, task|
        delete! id if only_tags.all? { |tag| task.todo.include? tag }
      end
    end

    def edit!(task_id)
      old_task = @tasks[task_id]
      t = Task.new
      if old_task
        yield t
      end
      delete! task_id
      add t
    end
    
    def tasks?
      !@tasks.empty?
    end
    
    def tasks
      @tasks.dup
    end
    
    def find (what_to_show=[])
      list = []

      if @tasks.empty?
        list = nil
      else
        case what_to_show
        when [] then<commit_msg>edit! and add methods now returns the task edited or added<commit_after>module Dooby
  
  class List

    attr_reader :location
    
    include DatesHelper

    def initialize(location)
      @location = location
      @tasks = {}
      load!
    end
    
    def flush!
      @tasks = {}
      save!
    end
    
    def add(task = Task.new)
      yield task if block_given?
      task = handle_tomorrow_tag task     
      @tasks[task.id] = task
      save!
      task
    end

    def delete!(task_id)
      if @tasks.delete task_id
        save!
      else
        false
      end
    end
    
    def bulk_delete!(terms)
      only_tags = terms.only_tags *SPECIAL_CHARS
      matches = []
      @tasks.each do |id, task|
        delete! id if only_tags.all? { |tag| task.todo.include? tag }
      end
    end

    def edit!(task_id)
      old_task = @tasks[task_id]
      if old_task
        t = Task.new
        yield t
        delete! task_id
        add t
      end
    end
    
    def tasks?
      !@tasks.empty?
    end
    
    def tasks
      @tasks.dup
    end
    
    def find (what_to_show=[])
      list = []

      if @tasks.empty?
        list = nil
      else
        case what_to_show
        when [] then
{'fraction_non_alphanumeric': 0.0772765246449457, 'fraction_numerical': 0.0, 'mean_word_length': 1.463991769547325, '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': '1601388', 'n_tokens_mistral': 785, 'n_tokens_neox': 770, 'n_words': 210}