Class: Specwrk::PendingStore

Inherits:
Store
  • Object
show all
Defined in:
lib/specwrk/store.rb

Constant Summary collapse

RUN_TIME_BUCKET_MAXIMUM_KEY =
:____run_time_bucket_maximum
ORDER_KEY =
:____order
MAX_RETRIES_KEY =
:____max_retries

Instance Method Summary collapse

Methods inherited from Store

#[], #[]=, adapter_klass, #any?, #delete, #empty?, #initialize, #inspect, #length, #multi_read, #to_h, with_lock

Constructor Details

This class inherits a constructor from Specwrk::Store

Instance Method Details

#clearObject



196
197
198
199
# File 'lib/specwrk/store.rb', line 196

def clear
  @order = nil
  super
end

#keysObject



184
185
186
187
188
# File 'lib/specwrk/store.rb', line 184

def keys
  return super if order.length.zero?

  order
end

#max_retriesObject



180
181
182
# File 'lib/specwrk/store.rb', line 180

def max_retries
  @max_retries ||= self[MAX_RETRIES_KEY] || 0
end

#max_retries=(val) ⇒ Object



176
177
178
# File 'lib/specwrk/store.rb', line 176

def max_retries=(val)
  @max_retries = self[MAX_RETRIES_KEY] = val
end

#merge!(hash) ⇒ Object



190
191
192
193
194
# File 'lib/specwrk/store.rb', line 190

def merge!(hash)
  super

  self.order = order + (hash.keys - order)
end

#orderObject



172
173
174
# File 'lib/specwrk/store.rb', line 172

def order
  @order ||= self[ORDER_KEY] || []
end

#order=(val) ⇒ Object



162
163
164
165
166
167
168
169
170
# File 'lib/specwrk/store.rb', line 162

def order=(val)
  @order = nil

  self[ORDER_KEY] = if val.nil? || val.length.zero?
    nil
  else
    val
  end
end

#reloadObject



201
202
203
204
205
# File 'lib/specwrk/store.rb', line 201

def reload
  @order = nil
  @max_retries = nil
  super
end

#run_time_bucket_maximumObject



158
159
160
# File 'lib/specwrk/store.rb', line 158

def run_time_bucket_maximum
  @run_time_bucket_maximum ||= self[RUN_TIME_BUCKET_MAXIMUM_KEY]
end

#run_time_bucket_maximum=(val) ⇒ Object



154
155
156
# File 'lib/specwrk/store.rb', line 154

def run_time_bucket_maximum=(val)
  @run_time_bucket_maximum = self[RUN_TIME_BUCKET_MAXIMUM_KEY] = val
end

#shift_bucketObject



207
208
209
210
211
212
213
214
215
216
# File 'lib/specwrk/store.rb', line 207

def shift_bucket
  return bucket_by_file unless run_time_bucket_maximum&.positive?

  case ENV["SPECWRK_SRV_GROUP_BY"]
  when "file"
    bucket_by_file
  else
    bucket_by_timings
  end
end