Project

General

Profile

Feature #12664

Multiline pretty-printing of multiline strings

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

Status:
Closed
Priority:
Normal
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"}

History

Updated by shyouhei (Shyouhei Urabe) almost 3 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) almost 3 years ago

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

Updated by hsbt (Hiroshi SHIBATA) almost 3 years ago

  • Status changed from Assigned to Closed

It's fixed at r56391

Updated by hsbt (Hiroshi SHIBATA) almost 3 years ago

  • Project changed from CommonRuby to Ruby master

Also available in: Atom PDF