class Codeowners::Cli::Wizards::UnrecognizedLineWizard

Suggests to fix unrecognized lines in the codeowners file. Only returns decision without applying any modifications.

Public Instance Methods

suggest_fixing(line) click to toggle source
# File lib/codeowners/cli/wizards/unrecognized_line_wizard.rb, line 13
def suggest_fixing(line)
  case prompt(line)
  when 'i' then :ignore
  when 'y' then [:replace, keep_asking_until_valid_line]
  when 'd' then :delete
  end
end

Private Instance Methods

keep_asking_until_valid_line() click to toggle source
# File lib/codeowners/cli/wizards/unrecognized_line_wizard.rb, line 32
def keep_asking_until_valid_line
  line = nil
  loop do
    new_line_string = ask('New line: ')
    line = Codeowners::Checker::Group::Line.build(new_line_string)
    break unless line.is_a?(Codeowners::Checker::Group::UnrecognizedLine)
  end
  line
end
prompt(line) click to toggle source
# File lib/codeowners/cli/wizards/unrecognized_line_wizard.rb, line 23
        def prompt(line)
          ask(<<~QUESTION, limited_to: %w[y i d])
            #{line.to_s.inspect} is in unrecognized format. Would you like to edit?
            (y) yes
            (i) ignore
            (d) delete the line
          QUESTION
        end