Project

General

Profile

Actions

Feature #12664

closed

Multiline pretty-printing of multiline strings

Added by pitr.ch (Petr Chalupa) about 8 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
-
[ruby-core:76800]

Description

With following addition

class String
  def pretty_print(q)
    lines = self.lines
    if lines.size > 1
      q.group(0, '', '') do
        q.seplist(lines, lambda { q.text ' +'; q.breakable }) do |v|
          q.pp v
        end
      end
    else
      q.text inspect
    end
  end
end

a multiline String will print as follows

[9] pry(main)> pp "bundler.rb"=> "module Bundler\n  BundlerError = Class.new(Exception)\n  def self.setup\n  end\nend\n"
{"bundler.rb"=>
  "module Bundler\n" +
  "  BundlerError = Class.new(Exception)\n" +
  "  def self.setup\n" +
  "  end\n" +
  "end\n"}

Updated by shyouhei (Shyouhei Urabe) about 8 years ago

  • Status changed from Open to Assigned

We looked at this issue in developer meeting today and Akira was positive about this proposal. I'm assigning to him.

Updated by pitr.ch (Petr Chalupa) about 8 years ago

Great, thanks. Would you like me to submit it in form of a patch?

Updated by hsbt (Hiroshi SHIBATA) about 8 years ago

  • Status changed from Assigned to Closed

It's fixed at r56391

Updated by hsbt (Hiroshi SHIBATA) about 8 years ago

  • Project changed from 14 to Ruby master
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0