<commit_before>

class TaskVault

  class DynamicTask < BaseTask
    attr_reader :name

    def initialize name
      self.name = name
    end

    def name= n
      @name = n.to_s
    end

    def generate_tasks
      raise "This method is abstract and should have been overwritten"
    end

    def serialize
      BBLib.to_hash(self).hash_path_set('class' => self.class.to_s)
    end

  end

end


require_relative 'dynamic_tasks/dynamic_scripts'<commit_msg>Refactoring DynamicTask to work and run as a standard task.<commit_after>

class TaskVault

  class DynamicTask < Task
    attr_reader :interval
    
    def interval= it
      @interval = BBLib::keep_between(it, 0, nil)
    end
    
    protected
    
      def generate_tasks *args
        raise "This method is abstract and should have been redefined."
      end
      
      def start_tasks *tasks
        tasks.each{ |task| @parent.queue task }
      end
    
      def custom_defaults
        self.interval = 10
        self.name = SecureRandom.hex(10)
        self.repeat = true
      end
      
      def build_proc
        proc{ |*args|
          loop do
            start = Time.now
            generate_tasks
            sleep(BBLib::keep_between(@interval - (Time.now - start), 0, nil))
          end
        }
      end

  end

end


require_relative 'dynamic_tasks/dynamic_scripts'
{'fraction_non_alphanumeric': 0.06489675516224189, 'fraction_numerical': 0.004424778761061947, 'mean_word_length': 2.002212389380531, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '5545777', 'n_tokens_mistral': 419, 'n_tokens_neox': 399, 'n_words': 118}