{"id":20032528,"url":"https://github.com/akicho8/table_format","last_synced_at":"2025-05-05T05:30:38.103Z","repository":{"id":59157116,"uuid":"138954036","full_name":"akicho8/table_format","owner":"akicho8","description":"TableFormat shows text table like emacs org-table for easy reading.","archived":false,"fork":false,"pushed_at":"2025-03-25T01:54:41.000Z","size":108,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-08T17:08:30.481Z","etag":null,"topics":["data-visualization","ruby","table"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akicho8.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-28T02:05:03.000Z","updated_at":"2025-03-25T01:54:45.000Z","dependencies_parsed_at":"2024-11-13T09:49:36.061Z","dependency_job_id":null,"html_url":"https://github.com/akicho8/table_format","commit_stats":{"total_commits":122,"total_committers":1,"mean_commits":122.0,"dds":0.0,"last_synced_commit":"4a00b91a36c65e912aacc8586edcc1831532352e"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akicho8%2Ftable_format","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akicho8%2Ftable_format/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akicho8%2Ftable_format/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akicho8%2Ftable_format/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akicho8","download_url":"https://codeload.github.com/akicho8/table_format/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252445603,"owners_count":21749085,"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":["data-visualization","ruby","table"],"created_at":"2024-11-13T09:38:10.350Z","updated_at":"2025-05-05T05:30:38.096Z","avatar_url":"https://github.com/akicho8.png","language":"Ruby","readme":"#+html: \u003ca href=\"https://badge.fury.io/rb/table_format\"\u003e\u003cimg src=\"https://badge.fury.io/rb/table_format.svg\" alt=\"Gem Version\" height=\"18\"\u003e\u003c/a\u003e\n#+html: \u003ca href=\"https://travis-ci.org/akicho8/table_format\"\u003e\u003cimg src=\"https://travis-ci.org/akicho8/table_format.svg?branch=master\" /\u003e\u003c/a\u003e\n#+html: \u003ca href=\"https://codeclimate.com/github/akicho8/table_format/maintainability\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/3af6a246ec61ddafd45d/maintainability\" /\u003e\u003c/a\u003e\n\n* TableFormat\n\n  TableFormat shows text table like emacs org-table for easy reading.\n\n#+BEGIN_SRC ruby\ntp Object.constants.grep(/RUBY_/).map { |e| [e, Object.const_get(e)] }.to_h\n# \u003e\u003e |---------------------+------------------------------------------------------------|\n# \u003e\u003e |        RUBY_VERSION | 2.5.0                                                      |\n# \u003e\u003e |   RUBY_RELEASE_DATE | 2017-12-25                                                 |\n# \u003e\u003e |       RUBY_PLATFORM | x86_64-darwin16                                            |\n# \u003e\u003e |     RUBY_PATCHLEVEL | 0                                                          |\n# \u003e\u003e |    RUBY_DESCRIPTION | ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16] |\n# \u003e\u003e |         RUBY_ENGINE | ruby                                                       |\n# \u003e\u003e |       RUBY_REVISION | 61468                                                      |\n# \u003e\u003e | RUBY_ENGINE_VERSION | 2.5.0                                                      |\n# \u003e\u003e |      RUBY_COPYRIGHT | ruby - Copyright (C) 1993-2017 Yukihiro Matsumoto          |\n# \u003e\u003e |---------------------+------------------------------------------------------------|\n#+END_SRC\n\n  In the case of Rails\n\n#+BEGIN_SRC ruby\nclass ApplicationController \u003c ActionController::Base\n  if Rails.env.development?\n    before_action do\n      logger.debug params.to_unsafe_h.to_t(truncate: 40)\n    end\n  end\nend\n#+END_SRC\n\n#+BEGIN_SRC shell\n% cat log/development.log\nStarted POST \"/api/xy_master/time_records\" for ::1 at 2021-11-18 13:52:25 +0900\nProcessing by Api::XyMaster::TimeRecordsController#create as JSON\n  Parameters: (snip)\n|-------------+---------------------------------------------|\n|   scope_key | scope_today                                 |\n| time_record | {\"rule_key\"=\u003e\"rule100t\", \"spent_sec\"=\u003e0,... |\n|      format | json                                        |\n|  controller | api/xy_master/time_records                  |\n|      action | create                                      |\n|-------------+---------------------------------------------|\n#+END_SRC\n\n** Installation\n\nInstall as a standalone gem\n\n#+BEGIN_SRC shell-script\n$ gem install table_format\n#+END_SRC\n\nOr install within application using Gemfile\n\n#+BEGIN_SRC shell-script\n$ bundle add table_format\n$ bundle install\n#+END_SRC\n\n** Examples\n\n*** Array of hash\n\n#+BEGIN_SRC ruby\ntp [{id: 1, name: \"alice\"}, {id: 2, name: \"bob\"}]\n# \u003e\u003e |----+-------|\n# \u003e\u003e | id | name  |\n# \u003e\u003e |----+-------|\n# \u003e\u003e |  1 | alice |\n# \u003e\u003e |  2 | bob   |\n# \u003e\u003e |----+-------|\n#+END_SRC\n\n*** Hash\n\n#+BEGIN_SRC ruby\ntp({id: 1, name: \"alice\"})\n# \u003e\u003e |------+-------|\n# \u003e\u003e |   id | 1     |\n# \u003e\u003e | name | alice |\n# \u003e\u003e |------+-------|\n#+END_SRC\n\n*** Array\n\n#+BEGIN_SRC ruby\ntp [:alice, :bob]\n# \u003e\u003e |-------|\n# \u003e\u003e | alice |\n# \u003e\u003e | bob   |\n# \u003e\u003e |-------|\n#+END_SRC\n\n*** ActiveRecord or Mongoid\n\n#+BEGIN_SRC ruby\n[\"alice\", \"bob\"].each { |e| User.create!(name: e) }\n#+END_SRC\n\n#+BEGIN_SRC ruby\ntp User\n# \u003e\u003e |----+-------|\n# \u003e\u003e | id | name  |\n# \u003e\u003e |----+-------|\n# \u003e\u003e |  1 | alice |\n# \u003e\u003e |  2 | bob   |\n# \u003e\u003e |----+-------|\n#+END_SRC\n\n#+BEGIN_SRC ruby\ntp User.limit(1)\n# \u003e\u003e |----+-------|\n# \u003e\u003e | id | name  |\n# \u003e\u003e |----+-------|\n# \u003e\u003e |  1 | alice |\n# \u003e\u003e |----+-------|\n#+END_SRC\n\n#+BEGIN_SRC ruby\ntp User.first\n# \u003e\u003e |------+-------|\n# \u003e\u003e |   id | 1     |\n# \u003e\u003e | name | alice |\n# \u003e\u003e |------+-------|\n#+END_SRC\n\n**** ActiveRecord::Result\n\n#+BEGIN_SRC ruby\ntp ActiveRecord::Base.connection.select_all(\"SELECT * FROM users\")\n# \u003e\u003e |----+-------|\n# \u003e\u003e | id | name  |\n# \u003e\u003e |----+-------|\n# \u003e\u003e |  1 | alice |\n# \u003e\u003e |  2 | bob   |\n# \u003e\u003e |----+-------|\n#+END_SRC\n\n** How to table as string\n\nUse to_t method.\n\n#+BEGIN_SRC ruby\nputs [{id: 1, name: \"alice\"}, {id: 2, name: \"bob\"}].to_t\n# \u003e\u003e |----+-------|\n# \u003e\u003e | id | name  |\n# \u003e\u003e |----+-------|\n# \u003e\u003e |  1 | alice |\n# \u003e\u003e |  2 | bob   |\n# \u003e\u003e |----+-------|\n#+END_SRC\n\n** Options\n\nPass as the second argument to tp or the first argument to to_t.\n\n#+BEGIN_SRC ruby\ntp 1\n# \u003e\u003e |---|\n# \u003e\u003e | 1 |\n# \u003e\u003e |---|\n\ntp 1, intersection_both: \"+\"\n# \u003e\u003e +---+\n# \u003e\u003e | 1 |\n# \u003e\u003e +---+\n#+END_SRC\n\n*** Markdown format example\n\n=markdown: true= has the same meaning as =intersection: \"|\", cover: false=\n\n#+BEGIN_SRC ruby\ntp [{id: 1, name: \"alice\"}, {id: 2, name: \"bob\"}], markdown: true\n# \u003e\u003e | id | name  |\n# \u003e\u003e |----|-------|\n# \u003e\u003e |  1 | alice |\n# \u003e\u003e |  2 | bob   |\n#+END_SRC\n\n#+BEGIN_SRC ruby\ntp [{id: 1, name: \"alice\"}, {id: 2, name: \"bob\"}], intersection: \"|\", cover: false\n# \u003e\u003e | id | name  |\n# \u003e\u003e |----|-------|\n# \u003e\u003e |  1 | alice |\n# \u003e\u003e |  2 | bob   |\n#+END_SRC\n\n** Global Options\n\n#+BEGIN_SRC ruby\ntp TableFormat.default_options\n# \u003e\u003e |-------------------+-------|\n# \u003e\u003e |          markdown | false |\n# \u003e\u003e |            header |       |\n# \u003e\u003e |             cover | true  |\n# \u003e\u003e |          vertical | |     |\n# \u003e\u003e |      intersection | +     |\n# \u003e\u003e | intersection_both | |     |\n# \u003e\u003e |           horizon | -     |\n# \u003e\u003e |           padding |       |\n# \u003e\u003e |           in_code | UTF-8 |\n# \u003e\u003e |-------------------+-------|\n\ntp 1\n# \u003e\u003e |---|\n# \u003e\u003e | 1 |\n# \u003e\u003e |---|\n\nTableFormat.default_options[:intersection_both] = \"+\"\n\ntp 1\n# \u003e\u003e +---+\n# \u003e\u003e | 1 |\n# \u003e\u003e +---+\n#+END_SRC\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakicho8%2Ftable_format","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakicho8%2Ftable_format","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakicho8%2Ftable_format/lists"}