Sha256: 3a061ed7deb0cbc8ba4bc2568900d73d12027a3b867f281ff8d98ad45547a1ba

Contents?: true

Size: 490 Bytes

Versions: 15

Compression:

Stored size: 490 Bytes

Contents

old_verbose, $VERBOSE = $VERBOSE, nil
require 'unparser'
$VERBOSE = old_verbose

module Reek
  module Source
    #
    # Formats snippets of syntax tree back into Ruby source code.
    #
    class SexpFormatter
      def self.format(sexp)
        return sexp.to_s unless sexp.is_a? AST::Node
        lines = Unparser.unparse(sexp).split "\n"
        if lines.length > 1
          "#{lines.first} ... #{lines.last}"
        else
          lines.first
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
reek-2.1.0 lib/reek/source/sexp_formatter.rb
reek-2.0.4 lib/reek/source/sexp_formatter.rb
reek-2.0.3 lib/reek/source/sexp_formatter.rb
reek-2.0.2 lib/reek/source/sexp_formatter.rb
reek-2.0.1 lib/reek/source/sexp_formatter.rb
reek-2.0.0 lib/reek/source/sexp_formatter.rb
reek-1.6.6 lib/reek/source/sexp_formatter.rb
reek-1.6.5 lib/reek/source/sexp_formatter.rb
reek-1.6.4 lib/reek/source/sexp_formatter.rb
reek-1.6.3 lib/reek/source/sexp_formatter.rb
reek-1.6.2 lib/reek/source/sexp_formatter.rb
reek-1.6.1 lib/reek/source/sexp_formatter.rb
reek-1.6.0 lib/reek/source/sexp_formatter.rb
reek-1.5.1 lib/reek/source/sexp_formatter.rb
reek-1.5.0 lib/reek/source/sexp_formatter.rb