Class: Specbandit::Worker
- Inherits:
-
Object
- Object
- Specbandit::Worker
- Defined in:
- lib/specbandit/worker.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
readonly
Returns the value of attribute batch_size.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#key_rerun ⇒ Object
readonly
Returns the value of attribute key_rerun.
-
#key_rerun_ttl ⇒ Object
readonly
Returns the value of attribute key_rerun_ttl.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#rspec_opts ⇒ Object
readonly
Returns the value of attribute rspec_opts.
Instance Method Summary collapse
-
#initialize(key: Specbandit.configuration.key, batch_size: Specbandit.configuration.batch_size, rspec_opts: Specbandit.configuration.rspec_opts, key_rerun: Specbandit.configuration.key_rerun, key_rerun_ttl: Specbandit.configuration.key_rerun_ttl, queue: nil, output: $stdout) ⇒ Worker
constructor
A new instance of Worker.
-
#run ⇒ Object
Main entry point.
Constructor Details
#initialize(key: Specbandit.configuration.key, batch_size: Specbandit.configuration.batch_size, rspec_opts: Specbandit.configuration.rspec_opts, key_rerun: Specbandit.configuration.key_rerun, key_rerun_ttl: Specbandit.configuration.key_rerun_ttl, queue: nil, output: $stdout) ⇒ Worker
Returns a new instance of Worker.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/specbandit/worker.rb', line 9 def initialize( key: Specbandit.configuration.key, batch_size: Specbandit.configuration.batch_size, rspec_opts: Specbandit.configuration.rspec_opts, key_rerun: Specbandit.configuration.key_rerun, key_rerun_ttl: Specbandit.configuration.key_rerun_ttl, queue: nil, output: $stdout ) @key = key @batch_size = batch_size @rspec_opts = Array(rspec_opts) @key_rerun = key_rerun @key_rerun_ttl = key_rerun_ttl @queue = queue || RedisQueue.new @output = output end |
Instance Attribute Details
#batch_size ⇒ Object (readonly)
Returns the value of attribute batch_size.
7 8 9 |
# File 'lib/specbandit/worker.rb', line 7 def batch_size @batch_size end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/specbandit/worker.rb', line 7 def key @key end |
#key_rerun ⇒ Object (readonly)
Returns the value of attribute key_rerun.
7 8 9 |
# File 'lib/specbandit/worker.rb', line 7 def key_rerun @key_rerun end |
#key_rerun_ttl ⇒ Object (readonly)
Returns the value of attribute key_rerun_ttl.
7 8 9 |
# File 'lib/specbandit/worker.rb', line 7 def key_rerun_ttl @key_rerun_ttl end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
7 8 9 |
# File 'lib/specbandit/worker.rb', line 7 def output @output end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
7 8 9 |
# File 'lib/specbandit/worker.rb', line 7 def queue @queue end |
#rspec_opts ⇒ Object (readonly)
Returns the value of attribute rspec_opts.
7 8 9 |
# File 'lib/specbandit/worker.rb', line 7 def rspec_opts @rspec_opts end |
Instance Method Details
#run ⇒ Object
Main entry point. Detects the operating mode and dispatches accordingly.
Returns 0 if all batches passed (or nothing to do), 1 if any batch failed.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/specbandit/worker.rb', line 30 def run if key_rerun rerun_files = queue.read_all(key_rerun) if rerun_files.any? run_replay(rerun_files) else run_steal(record: true) end else run_steal(record: false) end end |