<commit_before>require 'eventmachine'
require 'parse-cron'
require "em/cron/version"

module EM
  class Cron
    # @param cron_string [String]
    # @yield [Time] the time the block was scheduled to be called by cron
    # @example
    #   EM.run do
    #     EM::Cron.schedule("* * * * *") do |time|
    #       puts "hello world at time: #{time}"
    #     end
    #   end
    def self.schedule(cron_string, &blk)
      cron_parser = CronParser.new(cron_string)
      next_time = cron_parser.next(Time.now)
      EM.add_timer(next_time - Time.now) do
        yield(next_time)
        schedule(cron_string, &blk)
      end
    end
  end
end<commit_msg>add ability to stop schedule with :stop<commit_after>require 'eventmachine'
require 'parse-cron'
require "em/cron/version"

module EM
  class Cron
    # @param cron_string [String]
    # @yield [Time] the time the block was scheduled to be called by cron
    # @example
    #   EM.run do
    #     EM::Cron.schedule("* * * * *") do |time|
    #       puts "hello world at time: #{time}"
    #     end
    #   end
    def self.schedule(cron_string, &blk)
      cron_parser = CronParser.new(cron_string)
      next_time = cron_parser.next(Time.now)
      EM.add_timer(next_time - Time.now) do
        result = yield(next_time)
        schedule(cron_string, &blk) unless result == :stop
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11070381231671554, 'fraction_numerical': 0.0, 'mean_word_length': 2.5454545454545454, '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': '2828179', 'n_tokens_mistral': 473, 'n_tokens_neox': 462, 'n_words': 123}