Class: RSpec::Core::Parser

Inherits:
Object show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/option_parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_args) ⇒ Parser

Returns a new instance of Parser.



13
14
15
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/option_parser.rb', line 13

def initialize(original_args)
  @original_args = original_args
end

Instance Attribute Details

#original_argsObject (readonly)

Returns the value of attribute original_args.



11
12
13
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/option_parser.rb', line 11

def original_args
  @original_args
end

Class Method Details

.parse(args, source = nil) ⇒ Object



7
8
9
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/option_parser.rb', line 7

def self.parse(args, source=nil)
  new(args).parse(source)
end

Instance Method Details

#parse(source = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/option_parser.rb', line 17

def parse(source=nil)
  return { :files_or_directories_to_run => [] } if original_args.empty?
  args = original_args.dup

  options = args.delete('--tty') ? { :tty => true } : {}
  begin
    parser(options).parse!(args)
  rescue OptionParser::InvalidOption => e
    abort "#{e.message}#{" (defined in #{source})" if source}\n\n" \
          "Please use --help for a listing of valid options"
  end

  options[:files_or_directories_to_run] = args
  options
end