Class: GraphQL::Upgrader::RemoveExcessWhitespaceTransform

Inherits:
Transform
  • Object
show all
Defined in:
lib/graphql/upgrader/member.rb

Overview

Remove redundant newlines, which may have trailing spaces Remove double newline after do Remove double newline before end Remove lines with whitespace only

Instance Method Summary collapse

Methods inherited from Transform

#apply_processor, #normalize_type_expression, #reindent_lines, #trim_lines, #underscorize

Instance Method Details

#apply(input_text) ⇒ Object



753
754
755
756
757
758
759
# File 'lib/graphql/upgrader/member.rb', line 753

def apply(input_text)
  input_text
    .gsub(/\n{3,}/m, "\n\n")
    .gsub(/do\n{2,}/m, "do\n")
    .gsub(/\n{2,}(\s*)end/m, "\n\\1end")
    .gsub(/\n +\n/m, "\n\n")
end