Class: RubocopTodoCorrector::IgnoreFile
- Inherits:
-
Object
- Object
- RubocopTodoCorrector::IgnoreFile
- Defined in:
- lib/rubocop_todo_corrector/ignore_file.rb
Instance Method Summary collapse
- #append_cop_name(cop_name) ⇒ Object
- #ignored_cop_names ⇒ Array<String>
-
#initialize(path:) ⇒ IgnoreFile
constructor
A new instance of IgnoreFile.
Constructor Details
#initialize(path:) ⇒ IgnoreFile
Returns a new instance of IgnoreFile.
8 9 10 |
# File 'lib/rubocop_todo_corrector/ignore_file.rb', line 8 def initialize(path:) @path = path end |
Instance Method Details
#append_cop_name(cop_name) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rubocop_todo_corrector/ignore_file.rb', line 13 def append_cop_name(cop_name) return if include?(cop_name) appendix = "#{cop_name}\n" appendix.prepend("\n") if !content.empty? && !content.end_with?("\n") pathname.write("#{content}#{appendix}") end |
#ignored_cop_names ⇒ Array<String>
22 23 24 25 26 |
# File 'lib/rubocop_todo_corrector/ignore_file.rb', line 22 def ignored_cop_names content.split("\n").map do |line| line.sub(/#.+/, '').strip end.reject(&:empty?) end |