module Minisplit

Constants

VERSION

Public Class Methods

run?(runnable) click to toggle source
# File lib/minisplit.rb, line 17
def run?(runnable)
  split_key_for(runnable) % split_count == current_split
end

Private Class Methods

current_split() click to toggle source
# File lib/minisplit.rb, line 23
def current_split
  ENV.fetch('MINISPLIT_INDEX', 0).to_i
end
split_count() click to toggle source
# File lib/minisplit.rb, line 27
def split_count
  [ENV.fetch('MINISPLIT_TOTAL', 1).to_i, 1].max
end
split_key_for(runnable) click to toggle source
# File lib/minisplit.rb, line 31
def split_key_for(runnable)
  # Use a non-cryptographic hash function:
  Zlib.crc32(runnable.name)
end