Module: BrineUtil
- Defined in:
- lib/brine/util.rb
Overview
Assorted utility functions The deprecation piece should be extracted and the rest considered dead.
Instance Method Summary collapse
-
#retry_for(time, interval = 1) ⇒ Object
reevaluate passed block until it returns without throwing an exception or ‘time` elapses; retry every `interval`.
-
#transform_table!(table) ⇒ Object
iterate over data table and shave_value for each cell value mutates and returns table FIXME: Shouldn’t be needed and removed after use of tables is dropped.
Instance Method Details
#retry_for(time, interval = 1) ⇒ Object
reevaluate passed block until it returns without throwing an exception or ‘time` elapses; retry every `interval`
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/brine/util.rb', line 6 def retry_for(time, interval=1) failure = nil quit = Time.now + time while (Time.now <= quit) begin return yield rescue Exception => ex failure = ex sleep interval end end raise failure end |
#transform_table!(table) ⇒ Object
iterate over data table and shave_value for each cell value mutates and returns table FIXME: Shouldn’t be needed and removed after use of tables is dropped
23 24 25 26 27 28 |
# File 'lib/brine/util.rb', line 23 def transform_table!(table) table.cells_rows.each do |row| row.each{|cell| cell.value = Transform(cell.value)} end table end |