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



711
712
713
714
715
716
717
# File 'lib/graphql/upgrader/member.rb', line 711

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