Module: Mry::Runner

Defined in:
lib/mry/runner.rb

Class Method Summary collapse

Class Method Details

.run(files, to:, from:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mry/runner.rb', line 4

def run(files, to: , from:)
  rewriters, reverse_rewriters = *Rewriters.rewriters(to)

  files.each do |file|
    yaml = File.read(file)
    reverse_rewriters.each do |r|
      yaml = r.new(yaml, reverse: true).rewrite
    end
    rewriters.each do |r|
      yaml = r.new(yaml).rewrite
    end
    yaml += added_cops(from: from, to: to) if from
    File.write(file, yaml)
  end
end