Module: Reek::Configuration::RakeTaskConverter

Defined in:
lib/reek/configuration/rake_task_converter.rb

Overview

Responsible for converting configuration values coming from the outside world to whatever we want to use internally.

Constant Summary collapse

REGEXABLE_ATTRIBUTES =
%w(accept reject exclude).freeze

Class Method Summary collapse

Class Method Details

.convert(configuration) ⇒ Hash

Converts marked strings like “/foobar/” into regexes.

Parameters:

  • configuration (Hash)

    e.g. “exclude”=>[], “reject”=>[/^$/, /[0-9]$/, /[A-Z]/], “accept”=>[]

Returns:

  • (Hash)


18
19
20
21
22
23
24
25
# File 'lib/reek/configuration/rake_task_converter.rb', line 18

def convert(configuration)
  (configuration.keys & REGEXABLE_ATTRIBUTES).each do |attribute|
    configuration[attribute] = configuration[attribute].map do |item|
      item.is_a?(Regexp) ? item.inspect : item
    end
  end
  configuration
end