module CelluloidBenchmark::DataSources

Public Instance Methods

data_source(key) click to toggle source
# File lib/celluloid_benchmark/data_sources.rb, line 17
def data_source(key)
  raise_empty(key) if empty?(key)
  data_sources[key]
end
data_sources() click to toggle source
# File lib/celluloid_benchmark/data_sources.rb, line 7
def data_sources
  @data_sources ||= Hash.new do |hash, key|
    hash[key] = File.readlines("tmp/data/#{key}s.csv").map(&:strip)
  end
end
data_sources=(hash) click to toggle source
# File lib/celluloid_benchmark/data_sources.rb, line 13
def data_sources=(hash)
  @data_sources = hash
end
empty?(key) click to toggle source
# File lib/celluloid_benchmark/data_sources.rb, line 26
def empty?(key)
  data_sources[key].size == 0
end
raise_empty(key) click to toggle source
# File lib/celluloid_benchmark/data_sources.rb, line 22
def raise_empty(key)
  raise "Empty random data for '#{key}'. Ensure target has test data and run rake app:performance:get_random_data."
end
random_data(key) click to toggle source
# File lib/celluloid_benchmark/data_sources.rb, line 3
def random_data(key)
  data_source(key).sample
end