Sha256: 922ba75f66cb96528a613c4247f2a068627a944bd24bc055fbae158715213571
Contents?: true
Size: 911 Bytes
Versions: 1
Compression:
Stored size: 911 Bytes
Contents
require 'yaml' module RuboCop module RSpec # Builds a YAML config file from two config hashes class ConfigFormatter 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(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) end end def cops (descriptions.keys | config.keys).grep(NAMESPACES) end attr_reader :config, :descriptions end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-1.16.0 | lib/rubocop/rspec/config_formatter.rb |