Class: TestBench::Runner
- Inherits:
-
Object
- Object
- TestBench::Runner
- Defined in:
- lib/test_bench/runner.rb
Instance Attribute Summary collapse
- #executor ⇒ Object
- #expand_path ⇒ Object
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#telemetry ⇒ Object
readonly
Returns the value of attribute telemetry.
Class Method Summary collapse
- .build(paths, root_directory, exclude_pattern: nil) ⇒ Object
- .call(paths, root_directory = nil, exclude_pattern: nil) ⇒ Object
Instance Method Summary collapse
- #call ⇒ Object
- #execute(files) ⇒ Object
- #gather_files ⇒ Object
-
#initialize(paths, telemetry) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(paths, telemetry) ⇒ Runner
Returns a new instance of Runner.
8 9 10 11 |
# File 'lib/test_bench/runner.rb', line 8 def initialize paths, telemetry @paths = paths @telemetry = telemetry end |
Instance Attribute Details
#executor ⇒ Object
51 52 53 |
# File 'lib/test_bench/runner.rb', line 51 def executor @executor ||= Executor.build end |
#expand_path ⇒ Object
55 56 57 |
# File 'lib/test_bench/runner.rb', line 55 def @expand_path ||= proc do [] end end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
5 6 7 |
# File 'lib/test_bench/runner.rb', line 5 def paths @paths end |
#telemetry ⇒ Object (readonly)
Returns the value of attribute telemetry.
6 7 8 |
# File 'lib/test_bench/runner.rb', line 6 def telemetry @telemetry end |
Class Method Details
.build(paths, root_directory, exclude_pattern: nil) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/test_bench/runner.rb', line 13 def self.build paths, root_directory, exclude_pattern: nil telemetry = Telemetry::Registry.get TOPLEVEL_BINDING instance = new paths, telemetry instance.executor = Executor.build instance. = ExpandPath.build root_directory, exclude_pattern instance end |
.call(paths, root_directory = nil, exclude_pattern: nil) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/test_bench/runner.rb', line 22 def self.call paths, root_directory=nil, exclude_pattern: nil paths = Array paths root_directory ||= File.dirname caller_locations[0].path instance = build paths, root_directory, :exclude_pattern => exclude_pattern instance.() end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/test_bench/runner.rb', line 30 def call telemetry.run_started files = gather_files execute files return telemetry.passed? ensure telemetry.run_finished end |
#execute(files) ⇒ Object
47 48 49 |
# File 'lib/test_bench/runner.rb', line 47 def execute files executor.(files) end |
#gather_files ⇒ Object
41 42 43 44 45 |
# File 'lib/test_bench/runner.rb', line 41 def gather_files paths.flat_map do |path| Array .(path) end end |