Class: Gherkin::Tools::Reformat
- Defined in:
- lib/gherkin/tools/reformat.rb
Instance Method Summary collapse
Methods inherited from Files
Constructor Details
This class inherits a constructor from Gherkin::Tools::Files
Instance Method Details
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gherkin/tools/reformat.rb', line 9 def run each do |file| io = defined?(JRUBY_VERSION) ? Java.java.io.StringWriter.new : StringIO.new formatter = Formatter::PrettyFormatter.new(io, true) listener = Listener::FormatterListener.new(formatter) scan(file, listener) string = defined?(JRUBY_VERSION) ? io.getBuffer.toString : io.string File.open(file, 'w') {|io| io.write(string)} end end |