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.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/specbandit/worker.rb', line 10 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.
8 9 10 |
# File 'lib/specbandit/worker.rb', line 8 def batch_size @batch_size end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/specbandit/worker.rb', line 8 def key @key end |
#key_rerun ⇒ Object (readonly)
Returns the value of attribute key_rerun.
8 9 10 |
# File 'lib/specbandit/worker.rb', line 8 def key_rerun @key_rerun end |
#key_rerun_ttl ⇒ Object (readonly)
Returns the value of attribute key_rerun_ttl.
8 9 10 |
# File 'lib/specbandit/worker.rb', line 8 def key_rerun_ttl @key_rerun_ttl end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
8 9 10 |
# File 'lib/specbandit/worker.rb', line 8 def output @output end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
8 9 10 |
# File 'lib/specbandit/worker.rb', line 8 def queue @queue end |
#rspec_opts ⇒ Object (readonly)
Returns the value of attribute rspec_opts.
8 9 10 |
# File 'lib/specbandit/worker.rb', line 8 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.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/specbandit/worker.rb', line 31 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 |