Module: RubyCrystalCodemod::Settings

Included in:
Formatter
Defined in:
lib/ruby_crystal_codemod/settings.rb

Constant Summary collapse

OPTIONS =
{
  parens_in_def: [:yes, :dynamic],
  align_case_when: [false, true],
  align_chained_calls: [false, true],
  trailing_commas: [true, false],
  quote_style: [:double, :single],
  store_logs: [false, true],
}

Instance Method Summary collapse

Instance Method Details

#init_settings(options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby_crystal_codemod/settings.rb', line 13

def init_settings(options)
  OPTIONS.each do |name, valid_options|
    default = valid_options.first
    value = options.fetch(name, default)
    unless valid_options.include?(value)
      $stderr.puts "Invalid value for #{name}: #{value.inspect}. Valid " \
                   "values are: #{valid_options.map(&:inspect).join(", ")}"
      value = default
    end
    self.public_send("#{name}=", value)
  end
  diff = options.keys - OPTIONS.keys
  diff.each do |key|
    $stderr.puts "Invalid config option=#{key}"
  end
end