<commit_before>module Clockwork
  module Test
    class Manager < Clockwork::Manager
      attr_reader :total_ticks, :max_ticks, :end_time, :start_time

      def initialize(opts = {})
        super()
        @history = JobHistory.new

        @total_ticks = 0
        @max_ticks = opts[:max_ticks]
        @start_time = opts[:start_time]
        if opts[:end_time]
          @end_time = opts[:end_time]
        elsif @start_time
          @end_time = Time.current
        end
        config[:logger].level = Logger::ERROR
      end

      def run(opts = {})
        @max_ticks = opts[:max_ticks] if opts[:max_ticks]
        @start_time = opts[:start_time] if opts[:start_time]
        if opts[:end_time]
          @end_time = opts[:end_time]
        elsif @start_time
          @end_time = Time.current
        end
        @tick_speed = opts[:tick_speed]

        if start_time
          @time_altered = true
          Timecop.travel(start_time)
        end

        yield if block_given?

        tick_loop

        Timecop.return if @time_altered
      end

      def ran_job?(job)
        history.ran_job?(job)
      end

      def times_run(job)
        history.times_run(job)
      end

      def block_for(job)
        history.block_for(job)
      end

      private<commit_msg>Refactor Clockwork Manager options setting code<commit_after>module Clockwork
  module Test
    class Manager < Clockwork::Manager
      attr_reader :total_ticks, :max_ticks, :end_time, :start_time

      def initialize(opts = {})
        super()
        @history = JobHistory.new
        @total_ticks = 0
        set_opts(opts)

        config[:logger].level = Logger::ERROR
      end

      def run(opts = {})
        set_opts(opts)

        if start_time
          @time_altered = true
          Timecop.travel(start_time)
        end

        yield if block_given?

        tick_loop

        Timecop.return if @time_altered
      end

      def ran_job?(job)
        history.ran_job?(job)
      end

      def times_run(job)
        history.times_run(job)
      end

      def block_for(job)
        history.block_for(job)
      end

      private

      def set_opts(opts)
        @max_ticks = opts[:max_ticks] if opts[:max_ticks]
        @start_time = opts[:start_time] if opts[:start_time]
        if opts[:end_time]
          @end_time = opts[:end_time]
        elsif @start_time
          @end_time = Time.current
        end
        @tick_speed = opts[:tick_speed]
      end
{'fraction_non_alphanumeric': 0.08825910931174089, 'fraction_numerical': 0.0008097165991902834, 'mean_word_length': 1.92080378250591, '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': '4772241', 'n_tokens_mistral': 795, 'n_tokens_neox': 768, 'n_words': 162}