<commit_before>
#
# Testing ruote
#
# Fri Dec  4 17:15:10 JST 2009
#

require File.join(File.dirname(__FILE__), 'base.rb')


class Ruote::Worker

  public :process
end

class Ruote::Engine

  def peek_msg
    @msgs = @context.storage.get_msgs if ( ! @msgs) || @msgs.size < 1
    @msgs.shift
  end

  def do_process (msg)
    @context.worker.process(msg)
  end

  def step (count)
    return if count == 0
    loop do
      m = next_msg
      next unless m
      do_process(m)
      break
    end
    step(count - 1)
  end

  def next_msg
    loop do
      if m = peek_msg
        return m
      end
    end
  end

  def gather_msgs
    (1..77).to_a.inject({}) { |h, i|
      #(i % 10).times { Thread.pass }
      sleep 0.001
      sleep 0.050 # couch :-(
      m = peek_msg
      h[m['_id']] = m if m
      h
    }.values.sort { |a, b|
      a['put_at'] <=> b['put_at']<commit_msg>a bit more patient for ruote-couch<commit_after>
#
# Testing ruote
#
# Fri Dec  4 17:15:10 JST 2009
#

require File.join(File.dirname(__FILE__), 'base.rb')


class Ruote::Worker

  public :process
end

class Ruote::Engine

  def peek_msg
    @msgs = @context.storage.get_msgs if ( ! @msgs) || @msgs.size < 1
    @msgs.shift
  end

  def do_process (msg)
    @context.worker.process(msg)
  end

  def step (count)
    return if count == 0
    loop do
      m = next_msg
      next unless m
      do_process(m)
      break
    end
    step(count - 1)
  end

  def next_msg
    loop do
      if m = peek_msg
        return m
      end
    end
  end

  def gather_msgs
    (1..77).to_a.inject({}) { |h, i|
      #(i % 10).times { Thread.pass }
      sleep 0.001
      sleep 0.025 # couch :-(
      m = peek_msg
      h[m['_id']] = m if m
      h
    }.values.sort { |a, b|
      a['put_at'] <=> b['put_at']
{'fraction_non_alphanumeric': 0.12731351654514864, 'fraction_numerical': 0.03028603477285474, 'mean_word_length': 1.978297161936561, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '7202064', 'n_tokens_mistral': 750, 'n_tokens_neox': 683, 'n_words': 186}