{"id":13483296,"url":"https://github.com/geemus/formatador","last_synced_at":"2025-05-14T19:09:57.618Z","repository":{"id":736951,"uuid":"387168","full_name":"geemus/formatador","owner":"geemus","description":"STDOUT text formatting","archived":false,"fork":false,"pushed_at":"2024-01-21T15:54:46.000Z","size":126,"stargazers_count":450,"open_issues_count":1,"forks_count":29,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-28T06:36:37.426Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geemus.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"geemus","tidelift":"rubygems/formatador"}},"created_at":"2009-11-27T05:06:28.000Z","updated_at":"2025-02-18T16:45:45.000Z","dependencies_parsed_at":"2023-12-08T15:30:52.787Z","dependency_job_id":"e34a5082-6b65-45c6-bf6c-a0b40895fcee","html_url":"https://github.com/geemus/formatador","commit_stats":{"total_commits":148,"total_committers":26,"mean_commits":"5.6923076923076925","dds":0.6621621621621622,"last_synced_commit":"803223a40af11c115aa89c1a78a2fb67aba6d9f5"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geemus%2Fformatador","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geemus%2Fformatador/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geemus%2Fformatador/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geemus%2Fformatador/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geemus","download_url":"https://codeload.github.com/geemus/formatador/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252284937,"owners_count":21723671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:01:09.818Z","updated_at":"2025-05-14T19:09:56.400Z","avatar_url":"https://github.com/geemus.png","language":"Ruby","readme":"# formatador\n\nSTDOUT text formatting\n\n[![Build Status](https://github.com/geemus/formatador/actions/workflows/ruby.yml/badge.svg)](https://github.com/geemus/formatador/actions/workflows/ruby.yml)\n\n## Quick and dirty\n\nYou can call class methods to print out single lines like this:\n\n```ruby\nFormatador.display_line('Hello World')\n```\n\nYou use tags, similar to html, to set formatting options:\n\n```ruby\nFormatador.display_line('[green]Hello World[/]')\n```\n\n`[/]` resets everything to normal, colors are supported and `[_color_]` sets the background color.\n\n## Standard options\n\n* format - and adds color codes if STDOUT.tty? is true\n* display - calls format on the input and prints it\n* display_line - calls display, but adds on a newline (\\n)\n* redisplay - Displays text, prepended with \\r which will overwrite the last existing line\n\n## Extensions\n\n* display_table: takes an array of hashes. Each hash is a row, with the keys being the headers and values being the data. An optional second argument can specify which headers/columns to include and in what order they should appear.\n* display_compact_table: Same as display_table, execpt that split lines are not drawn by default in the body of the table. If you need a split line, put a :split constant in the body array.\n* redisplay_progressbar: takes the current and total values as its first two arguments and redisplays a progressbar (until current = total and then it display_lines). An optional third argument represents the start time and will add an elapsed time counter.\n\n### Progress Bar examples\n\n```ruby\ntotal    = 1000\nprogress = Formatador::ProgressBar.new(total)\n\n1000.times do\n  progress.increment\nend\n\n#=\u003e 978/1000  |************************************************* |\n\n# Change the color of the bar\ntotal    = 1000\nprogress = Formatador::ProgressBar.new(total, :color =\u003e \"light_blue\")\n\n1000.times do\n  progress.increment\nend\n\n# Change the color of a completed progress bar\ntotal    = 1000\nprogress = Formatador::ProgressBar.new(total) { |b| b.opts[:color] = \"green\" }\n\n1000.times do\n  progress.increment\nend\n```\n\n### Table examples\n\n```ruby\ntable_data = [\n  { :name =\u003e \"Joe\",  :food =\u003e \"Burger\" },\n  { :name =\u003e \"Bill\", :food =\u003e \"French fries\" }\n]\nFormatador.display_table(table_data)\n\n#=\u003e +------+--------------+\n#   | name | food         |\n#   +------+--------------+\n#   | Joe  | Burger       |\n#   +------+--------------+\n#   | Bill | French fries |\n#   +------+--------------+\n\ntable_data = [\n  {\n    :name =\u003e \"Joe\",\n    :meal =\u003e {\n      :main_dish =\u003e \"Burger\",\n      :drink =\u003e \"water\"\n    }\n  },\n  {\n    :name =\u003e \"Bill\",\n    :meal =\u003e {\n      :main_dish =\u003e \"Chicken\",\n      :drink =\u003e \"soda\"\n    }\n  }\n]\nFormatador.display_table(table_data, [:name, :\"meal.drink\"])\n\n#=\u003e +------+------------+\n#   | name | meal.drink |\n#   +------+------------+\n#   | Joe  | water      |\n#   +------+------------+\n#   | Bill | soda       |\n#   +------+------------+\n```\n\n## Indentation\n\nBy initializing a formatador object you can keep track of indentation:\n\n```ruby\nformatador = Formatador.new\nformatador.display_line('one level of indentation')\nformatador.indent {\n  formatador.display_line('two levels of indentation')\n}\nformatador.display_line('one level of indentation')\n```\n\n## Copyright\n\n(The MIT License)\n\nCopyright (c) 2022 [geemus (Wesley Beary)](http://github.com/geemus)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":["https://github.com/sponsors/geemus","https://tidelift.com/funding/github/rubygems/formatador"],"categories":["CLI Utilities","Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeemus%2Fformatador","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeemus%2Fformatador","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeemus%2Fformatador/lists"}