class Ruboclean::Grouper
Groups the rubocop configuration items into three categories:
- base: base configuration like 'require', 'inherit_from', etc - namespaces: every item which does **not** include an "/" - cops: every item which **includes** an "/"
Public Class Methods
new(config_hash)
click to toggle source
# File lib/ruboclean/grouper.rb, line 9 def initialize(config_hash) @config_hash = config_hash end
Public Instance Methods
group_config()
click to toggle source
# File lib/ruboclean/grouper.rb, line 13 def group_config @config_hash.each_with_object(empty_groups) do |item, result| key, value = item target_group = find_target_group(key) result[target_group].merge! Hash[key, value] end end
Private Instance Methods
empty_groups()
click to toggle source
# File lib/ruboclean/grouper.rb, line 23 def empty_groups { base: {}, namespaces: {}, cops: {} } end
find_target_group(key)
click to toggle source
# File lib/ruboclean/grouper.rb, line 27 def find_target_group(key) return :base if key.start_with?(/[a-z]/) return :cops if key.include?('/') :namespaces end