class WhoAmI::Function::RemoveAnnotation

Public Instance Methods

call(file_contents) click to toggle source
# File lib/who_am_i/function/remove_annotation.rb, line 4
def call(file_contents)
  if file_contents !~ /\A# == Schema Info/
    return file_contents
  end

  keep_the_rest = false

  kept_lines =
    file_contents.lines.keep_if do |line|
      if keep_the_rest
        next true
      elsif line[0] == "#"
        next false
      else
        keep_the_rest = true
        next false
      end
    end

  kept_lines.join("")
end