Class: Splot::Runner
- Inherits:
-
Object
- Object
- Splot::Runner
- Defined in:
- lib/splot/runner.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #parse ⇒ Object
- #parse_command_line_arguments ⇒ Object
- #parse_splotrc ⇒ Object
- #run! ⇒ Object
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
9 10 11 |
# File 'lib/splot/runner.rb', line 9 def initialize @params = {} end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/splot/runner.rb', line 3 def params @params end |
Class Method Details
.run! ⇒ Object
5 6 7 |
# File 'lib/splot/runner.rb', line 5 def self.run! new.tap(&:parse).run! end |
Instance Method Details
#command ⇒ Object
13 14 15 |
# File 'lib/splot/runner.rb', line 13 def command ::Splot.command params end |
#parse ⇒ Object
17 18 19 20 |
# File 'lib/splot/runner.rb', line 17 def parse parse_splotrc parse_command_line_arguments end |
#parse_command_line_arguments ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/splot/runner.rb', line 22 def parse_command_line_arguments OptionParser.new do |opts| opts. = "Usage: #{File.basename($PROGRAM_NAME)} [options]" opts.on('-f', '--file FILE', 'Run test for a given FILE') do |file| params[:file] = file end opts.on('-i', '--include-path PATH', 'Add an include PATH') do |path| params[:include_path] = path end opts.on('-l', '--line LINE', 'Only run test on LINE') do |line| params[:line] = line.to_i end opts.on('-r', '--runner RUNNER', 'Specify alternate runner') do |runner| params[:runner] = runner end opts.on('-p', '--preloader PRELOADER', 'Use e.g. zeus or spring to preload the environment') do |preloader| params[:preloader] = preloader end end.parse! end |
#parse_splotrc ⇒ Object
48 49 50 |
# File 'lib/splot/runner.rb', line 48 def parse_splotrc params[:config_file] = splotrc if File.size? splotrc end |
#run! ⇒ Object
52 53 54 55 56 57 |
# File 'lib/splot/runner.rb', line 52 def run! Kernel.exec command rescue RunnerNotFoundError => e warn "Warning: #{e}; will not run any test" exit 2 end |