Sha256: d65052dd893a5fc0f095510634479b90832d4056ca8c0383be4c2dd8963ad934
Contents?: true
Size: 946 Bytes
Versions: 6
Compression:
Stored size: 946 Bytes
Contents
require 'yaml' module RuboCop module RSpec # Builds a YAML config file from two config hashes class ConfigFormatter NAMESPACES = /^(#{Regexp.union('RSpec', 'Capybara', 'FactoryBot')})/ STYLE_GUIDE_BASE_URL = 'http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'.freeze def initialize(config, descriptions) @config = config @descriptions = descriptions end def dump 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)) .merge('StyleGuide' => STYLE_GUIDE_BASE_URL + cop.sub('RSpec/', '')) end end def cops (descriptions.keys | config.keys).grep(NAMESPACES) end attr_reader :config, :descriptions end end end
Version data entries
6 entries across 6 versions & 1 rubygems