Class: Forematter::Commands::Cleanup

Inherits:
Forematter::CommandRunner show all
Defined in:
lib/forematter/commands/cleanup.rb

Instance Method Summary collapse

Methods inherited from Forematter::CommandRunner

#call

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/forematter/commands/cleanup.rb', line 22

def run
  require 'stringex_lite'
  require 'titleize'

  files_with(field).each do |file|
    old = file[field].to_ruby
    begin
      val = cleanup(old)
    rescue Forematter::UnexpectedValue => e
      log_skip(file, e.message) && next
    end
    unless val == old
      file[field] = val
      file.write
    end
  end
end