Logo: Relish

  1. Sign in

Project: Cute-print 0.2.0

Pretty-print with source location

Kernel#qql works just like Kernel#pp from the built-in pp library,
except that it writes to $stderr and it labels the output with
the source location.

If the filename is long, then the source location is printed on a
line of its own.

Scenarios
One argument
Given
a file named "example.rb" with:
require "cute_print"
a = [
  "Once upon a time there were four little Rabbits, ",
  "and their names were",
  "Flopsy,",
  "Mopsy,",
  "Cotton-tail, and",
  "Peter.",
]
qql a
Then
stderr should be
example.rb:10: ["Once upon a time there were four little Rabbits, ",
                "and their names were",
                "Flopsy,",
                "Mopsy,",
                "Cotton-tail, and",
                "Peter."]
Two arguments
Given
a file named "example.rb" with:
require "cute_print"
qql 1, "foo"
Then
stderr should be
example.rb:2: 1
example.rb:2: "foo"
Very long label
Given
a file named "long____________________________filename.rb" with:
require "cute_print"
a = [
  "Once upon a time there were four little Rabbits, ",
  "and their names were",
  "Flopsy,",
  "Mopsy,",
  "Cotton-tail, and",
  "Peter.",
]
qql a
Then
stderr should be
long____________________________filename.rb:10:
  ["Once upon a time there were four little Rabbits, ",
   "and their names were",
   "Flopsy,",
   "Mopsy,",
   "Cotton-tail, and",
   "Peter."]

Last published about 7 years ago by Wayne Conrad.