geemus / formatador Goto Github PK
View Code? Open in Web Editor NEWSTDOUT text formatting
License: MIT License
STDOUT text formatting
License: MIT License
Hi! Nice gem.
I'm on a project that us going to use some Presenters to render tabularized info to HTML and spreadsheets... a pretty common task.
But, instead of writing it as yet another small clump of template presentation code, we'd like to do it as a gem. Yours came up as an example of a tool that operates on a similar input /output mapping, though (currently) it is only for ANSI/stdout.
What would you think of a refactoring that separated it so yoy could conveniently swap rendering targets, and maybe threw in some other spiffups, like totals?
We could do most of the code+tests, but it would be nice for that work to have a proper home.
Thanks!
This will make it show up on rubygems.org. I'm doing due diligence on our gems and need to find out the licenses for all the gems. Having it show up on rubygems.org cuts out the step of having to go to the github repo.
The idea is to use the syntax specification that Markdown allows for a better visualization of the code (and even results).
Here an example of how it would look like:
total = 1000
progress = ProgressBar.new(total)
1000.times do
progress.increment
end
#=> 978/1000 |************************************************* |
# Change the color of the bar
total = 1000
progress = ProgressBar.new(total, :color => "light_blue")
1000.times do
progress.increment
end
# Change the color of a completed progress bar
total = 1000
progress = ProgressBar.new(total) { |b| b.opts[:color] = "green" }
1000.times do
progress.increment
end
Would you consider a patch would allow a hash to be passed as the second argument to display_table
so an alternate name could be given for columns? Currently I don't think this is possible without renaming all the keys in each hash.
Here's an example:
table_data = [
{:name => "Joe", :meal => {:main_dish => "Burger", :drink => "water"}},
{:name => "Bill", :meal => {:main_dish => "Chicken", :drink => "soda"}}
]
Formatador.display_table(table_data, {"name": "Name", "meal.drink": "Drink"})
+------+------------+
| Name | Drink |
+------+------------+
| Joe | water |
+------+------------+
| Bill | soda |
+------+------------+
Are there plans on using Semantic Versioning for formatador? http://semver.org/
I was updating my version of the fog gem and having a 1.0 release of formatador would have helped make me more confident that upgrading wouldn't introduce any breaking changes
It looks like 1.1 got released, but there isn't any mention of it in the changelog.txt
Hi,
I am not sure if I am running tests correctly, but I keep getting this error:
Formatador
#display_table([{:a => 1}, {:a => 2}]) - returns " +---+\n | \e[1ma\e[0m |\n +---+\n | 1 |\n +---+\n | 2 |\n +---+\n"
uninitialized constant StringIO (NameError)
./tests/tests_helper.rb:9:in `capture_stdout'
./tests/table_tests.rb:14
(...)
A simple fix is to add "requires 'stringio'" to tests_helper.rb. Am I missing something, or is this require needed for the tests to work properly?
Thank you very much,
Bohuslav Kabrda.
I'm constructing a DataFrame gem for ruby called daru, and it involves row and column indexed data structures.
Currently I've rolled my own version of #inspect
to display a DataFrame in the console (somewhat) pretty, but if support for single level and hierarchical row indexing could be added to Formatador in the future then that would be fantastic!
Hi,
I don't know if it is a issue, but I can't fix a problem I got with my own code, please forgive me if it isn't an issue :s
The problem is fairly simple, it is a simple table, only containing simple hashes, as it doesn't got any linking, it is displayed on several lines. But I couldn't find any formatador option to fix it.
Formatador.display_compact_table(@clients_array)
Thanks you for your work and for having read.
https://travis-ci.org/github/geemus/formatador
Why not take this opportunity to migrate to GitHub Actions?
Hi,
I am having a small issue seeing how I can add a custom header of my own onto this.
The reason being is that I hit a third party API and instead of it return a JSON object with a key of "nickname", I would like it to be "username" instead. I could iterate over the response and create a new object from the response but I would like to avoid extra handling where possible.
Any help would be appreciated!
I want to right-justify a numeric.
example:
table_data = [
{ :name => "Burger", :price => 200 },
{ :name => "French fries", :price => 120 }
]
Formatador.display_table(table_data)
#=> +--------------+-------+
# | name | price |
# +--------------+-------+
# | Burger | 200 |
# +--------------+-------+
# | French fries | 120 |
# +--------------+-------+
Sometimes we need to send the color codes to log files, or stdout is replaced by a logging process like daemontools. Formatador needs an option to force the color codes.
Thanks.
Hi,
I just found out, that when you redirect the test output to a file, the 3 table tests fail, because you don't do the formatting. For example:
expected => " +---+\n | \e[1ma\e[0m |\n +---+\n | 1 |\n +---+\n | 2 |\n +---+\n"
returned => " +---+\n | a |\n +---+\n | 1 |\n +---+\n | 2 |\n +---+\n"
I believe that this is not an issue with formatador itself, but with the tests. I think they should react to the situation when redirected to a file.
Thanks,
Bohuslav Kabrda.
Hi,
I noticed that the last release on rubygems is quite old and has no license specified. This is already fixed in the master branch. Could you publish a new release please?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.