lib/rubocop/rspec/config_formatter.rb in rubocop-rspec-1.15.1 vs lib/rubocop/rspec/config_formatter.rb in rubocop-rspec-1.16.0

- old
+ new

@@ -2,30 +2,33 @@ module RuboCop module RSpec # Builds a YAML config file from two config hashes class ConfigFormatter - NAMESPACE = 'RSpec'.freeze + NAMESPACES = /^(#{Regexp.union('RSpec', 'FactoryGirl')})/ + STYLE_GUIDE_BASE_URL = 'http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/'.freeze def initialize(config, descriptions) @config = config @descriptions = descriptions end def dump - YAML.dump(unified_config).gsub(/^#{NAMESPACE}/, "\n#{NAMESPACE}") + YAML.dump(unified_config).gsub(NAMESPACES, "\n\\1") end private def unified_config cops.each_with_object(config.dup) do |cop, unified| - unified[cop] = config.fetch(cop).merge(descriptions.fetch(cop)) + unified[cop] = config.fetch(cop) + .merge(descriptions.fetch(cop)) + .merge('StyleGuide' => STYLE_GUIDE_BASE_URL + cop) end end def cops - (descriptions.keys + config.keys).uniq.grep(/\A#{NAMESPACE}/) + (descriptions.keys | config.keys).grep(NAMESPACES) end attr_reader :config, :descriptions end end