class RuboCop::RSpec::ConfigFormatter
Builds a YAML config file from two config hashes
Constants
- EXTENSION_ROOT_DEPARTMENT
- STYLE_GUIDE_BASE_URL
- SUBDEPARTMENTS
Attributes
config[R]
descriptions[R]
Public Class Methods
new(config, descriptions)
click to toggle source
# File lib/rubocop/rspec/config_formatter.rb, line 13 def initialize(config, descriptions) @config = config @descriptions = descriptions end
Public Instance Methods
dump()
click to toggle source
# File lib/rubocop/rspec/config_formatter.rb, line 18 def dump YAML.dump(unified_config) .gsub(EXTENSION_ROOT_DEPARTMENT, "\n\\1") .gsub(/^(\s+)- /, '\1 - ') end
Private Instance Methods
cops()
click to toggle source
# File lib/rubocop/rspec/config_formatter.rb, line 36 def cops (descriptions.keys | config.keys).grep(EXTENSION_ROOT_DEPARTMENT) end
unified_config()
click to toggle source
# File lib/rubocop/rspec/config_formatter.rb, line 26 def unified_config cops.each_with_object(config.dup) do |cop, unified| next if SUBDEPARTMENTS.include?(cop) unified[cop] = config.fetch(cop) .merge(descriptions.fetch(cop)) .merge('StyleGuide' => STYLE_GUIDE_BASE_URL + cop.sub('RSpec/', '')) end end