Class: RubocopChallenger::Rubocop::TodoWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop_challenger/rubocop/todo_writer.rb

Overview

To edit ‘.rubocop_todo.yml`

Instance Method Summary collapse

Constructor Details

#initialize(source, destination = source) ⇒ TodoWriter

Returns a new instance of TodoWriter.



7
8
9
10
# File 'lib/rubocop_challenger/rubocop/todo_writer.rb', line 7

def initialize(source, destination = source)
  @source = source
  @destination = destination
end

Instance Method Details

#delete_rule(rubocop_rule) ⇒ Object



12
13
14
15
16
# File 'lib/rubocop_challenger/rubocop/todo_writer.rb', line 12

def delete_rule(rubocop_rule)
  current_data = File.read(source)
  contents = current_data.sub("\n#{rubocop_rule.contents}", '')
  File.write(destination, contents)
end