Sha256: 6a94fc3fc06459d402333c9c81dfd201ab54d562f3b1f477bdf515b6132e47f5

Contents?: true

Size: 653 Bytes

Versions: 35

Compression:

Stored size: 653 Bytes

Contents

require 'stringio'
require 'gherkin/tools/files'
require 'gherkin/formatter/pretty_formatter'
require 'gherkin/listener/formatter_listener'

module Gherkin
  module Tools
    class Reformat < Files
      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
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
gherkin-2.2.0 lib/gherkin/tools/reformat.rb
gherkin-2.2.0-i386-mswin32 lib/gherkin/tools/reformat.rb
gherkin-2.2.0-i386-mingw32 lib/gherkin/tools/reformat.rb
gherkin-2.2.0-universal-dotnet lib/gherkin/tools/reformat.rb
gherkin-2.2.0-java lib/gherkin/tools/reformat.rb
gherkin-2.1.5 lib/gherkin/tools/reformat.rb
gherkin-2.1.5-i386-mswin32 lib/gherkin/tools/reformat.rb
gherkin-2.1.5-i386-mingw32 lib/gherkin/tools/reformat.rb
gherkin-2.1.5-universal-dotnet lib/gherkin/tools/reformat.rb
gherkin-2.1.5-java lib/gherkin/tools/reformat.rb
gherkin-2.1.4 lib/gherkin/tools/reformat.rb
gherkin-2.1.4-i386-mswin32 lib/gherkin/tools/reformat.rb
gherkin-2.1.4-i386-mingw32 lib/gherkin/tools/reformat.rb
gherkin-2.1.4-universal-dotnet lib/gherkin/tools/reformat.rb
gherkin-2.1.4-java lib/gherkin/tools/reformat.rb
gherkin-2.1.3 lib/gherkin/tools/reformat.rb
gherkin-2.1.3-i386-mswin32 lib/gherkin/tools/reformat.rb
gherkin-2.1.3-i386-mingw32 lib/gherkin/tools/reformat.rb
gherkin-2.1.3-universal-dotnet lib/gherkin/tools/reformat.rb
gherkin-2.1.3-java lib/gherkin/tools/reformat.rb