Method: CopHelper#parse_source

Defined in:
lib/rubocop/rspec/cop_helper.rb

#parse_source(source, file = nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rubocop/rspec/cop_helper.rb', line 40

def parse_source(source, file = nil)
  if file.respond_to?(:write)
    file.write(source)
    file.rewind
    file = file.path
  end

  processed_source = RuboCop::ProcessedSource.new(
    source, ruby_version, file, parser_engine: parser_engine
  )
  processed_source.config = configuration
  processed_source.registry = registry
  processed_source
end