Closed matti closed 2 years ago
Hi, thanks for an idea. But I'm not sure what's the use case? If you need output string to work with, why won't you use the JSON format?
Also this approach seems a bit complex. Maybe instead setting ENV["RUBY_PG_EXTRAS_NO_COLORS"] = true
would disable the colorize
method?
Also, in addition to disabling colors with an ENV variable you could add a new in_format
option e.g. ascii
.
I just want the table output as strings to be stored in files etc and not to spend time parsing json etc.
and my monkeypatch is not proposed implementation, just something I did fast.
and another usecase is to for example have a sinatra etc route like
get "/table_info" do PgExtras.table_info end
again, much easier to output text instead of json+parse
and, my monkeypatch is "that complex" because the pgextras code doesnt already have that ":ascii" format which would then be used by :table.
like, instead, :table is formatting+puts in a one go, then it could be composer of :ascii+puts
anyway, just saying that pgextras could be refactored. I'm already good with my monkeypatch.
Ok. I don't really see an urgent need for this feature, so if you don't feel like implementing it I'll close the issues for now.
Thanks for this awesome gem - I made a quick monkey patch to puts to return strings so that the output can be caputered/displayed differently. I think this is valid usecase to implement properly in the gem.