Class: FlakyTester::CommandParser

Inherits:
Object
  • Object
show all
Defined in:
lib/flaky_tester/command_parser.rb,
lib/flaky_tester/command_parser/errors/invalid_times.rb

Defined Under Namespace

Classes: Errors

Constant Summary collapse

DEFAULT_COMMAND_OPTIONS =
{
  times: 25,
  paths: []
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(command_args = []) ⇒ CommandParser

Returns a new instance of CommandParser.



12
13
14
15
16
17
18
19
20
21
# File 'lib/flaky_tester/command_parser.rb', line 12

def initialize(command_args = [])
  @command_args = command_args
  @command_options = DEFAULT_COMMAND_OPTIONS.dup
  @option_parser = OptionParser.new do |option_parser|
    option_parser.banner = "Usage: fspec [options] [files or directories]"
  end

  set_times_option_handler
  set_help_option_handler
end

Instance Method Details

#parseObject



23
24
25
26
27
# File 'lib/flaky_tester/command_parser.rb', line 23

def parse
  @option_parser.parse!(@command_args)
  set_paths_command_option
  @command_options
end

#to_sObject



29
30
31
# File 'lib/flaky_tester/command_parser.rb', line 29

def to_s
  @option_parser.to_s
end