class VanishingVision::Engine
Constants
- SKIP_ENCODINGS
Public Class Methods
new(path)
click to toggle source
# File lib/vanishing_vision/engine.rb, line 9 def initialize(path) @path = path end
Public Instance Methods
run(auto_correct)
click to toggle source
# File lib/vanishing_vision/engine.rb, line 13 def run(auto_correct) source = File.read(@path) return if SKIP_ENCODINGS.include?(NKF.guess(source)) core = Core.new(source) changed_source = core.vanish unless source == changed_source puts "diff #{@path}" puts Diffy::Diff.new(source, changed_source) File.open(@path, 'w+') {|f| f.write(changed_source) } if auto_correct end end