Closed JoshCheek closed 7 years ago
I'm thinking about adding this, I'm mostly unsure about the representation (inspected strings with plusses to imply concatenation). Since I know @jcinnamond and @avdi use it, I'll solicit opinions from y'all :)
If you want to play with it, here's the code that does it, I've modified it since the screenshot, it now displays the newlines. I also might add some sort of a conditional to not run it unless PP
is defined.
diff --git a/lib/seeing_is_believing/the_matrix.rb b/lib/seeing_is_believing/the_matrix.rb
index 0bb9410..e20df3d 100644
--- a/lib/seeing_is_believing/the_matrix.rb
+++ b/lib/seeing_is_believing/the_matrix.rb
@@ -2,6 +2,12 @@ require_relative 'version'
require_relative 'safe'
require_relative 'event_stream/producer'
+class String
+ def pretty_print(pp)
+ pp.text inspect.gsub(/\\n(?!")/, '\n" +'+"\n"+'"')
+ end
+end
+
sib_vars = Marshal.load ENV["SIB_VARIABLES.MARSHAL.B64"].unpack('m0').first
event_stream = IO.open sib_vars.fetch(:event_stream_fd), "w"
$SiB = SeeingIsBelieving::EventStream::Producer.new(event_stream)
I keep doing stuff like this
So that it will display the output across lines. It would be nice if the pretty printed string in this case would display better so that I don't have to turn it into an array of lines.