123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::ConfigRegeneration Private

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: lib/rubocop/config_regeneration.rb

Overview

This class handles collecting the options for regenerating a TODO file.

Constant Summary

Instance Attribute Summary

Instance Method Summary

  • #options Internal use only

    Get options from the comment in the TODO file, and parse them as options.

  • #generation_command private Internal use only

Instance Attribute Details

#todo_exists?Boolean (readonly, private)

[ GitHub ]

  
# File 'lib/rubocop/config_regeneration.rb', line 25

def todo_exists?
  File.exist?(AUTO_GENERATED_FILE) && !File.empty?(AUTO_GENERATED_FILE)
end

Instance Method Details

#generation_command (private)

[ GitHub ]

  
# File 'lib/rubocop/config_regeneration.rb', line 29

def generation_command
  File.foreach(AUTO_GENERATED_FILE).take(2).last
end

#options

Get options from the comment in the TODO file, and parse them as options

[ GitHub ]

  
# File 'lib/rubocop/config_regeneration.rb', line 12

def options
  # If there's no existing TODO file, generate one
  return DEFAULT_OPTIONS unless todo_exists?

  match = generation_command.match(COMMAND_REGEX)
  return DEFAULT_OPTIONS unless match

  options = match[1].split
  Options.new.parse(options).first
end