ruby - How to rewrite file content with inline Guard (gem), avoiding infinite loop -


how can avoid infinite loop kind of code? (rubocop's auto-correct re-write files, although system command think)

require 'guard/compat/plugin'  module ::guard   class rubyhtmlsyntaxfixer < plugin     def run_on_modifications(paths)       paths.each |path|         text = file.read(path)         text.gsub!('replace text', 'with cool')         file.open(path, 'w') {|file| file.puts text }       end     end   end end   guard 'ruby_html_syntax_fixer'   watch(%r{app/views/.+\.(erb|haml|slim)}) end 


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -