Skip to content

A Ruby class for creating and formatting customizable tables in Slack messages as an alternative to Markdown tables.

License

Notifications You must be signed in to change notification settings

kataring/slack_table-ruby

Repository files navigation

SlackTable

  • SlackTable: A Ruby class for creating and formatting customizable tables in Slack messages as an alternative to Markdown tables.

Installation

gem install slack_table
gem 'slack_table'

Usage

require 'slack_table'

columns = [
  { title: 'Name', align: 'left', width: 10, index: :name },
  { title: 'Age', align: 'right', width: 3, index: :age },
  { title: 'City', align: 'left', width: 15, index: :city }
]

data = [
  '-',
  { name: 'Alice', age: 30, city: 'New York' },
  { name: 'Bob', age: 25, city: 'San Francisco' },
  { name: 'Charlie', age: 22, city: 'Tokyo' }
]

table = SlackTable.new(title: 'User Information', columns: columns, data: data)
puts table.render
*User Information*
```
Name       Age City
------------------------------
Alice       30 New York
Bob         25 San Francisco
Charlie     22 Tokyo
```

image

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kataring/slack_table-ruby

License

The gem is available as open source under the terms of the MIT License.

About

A Ruby class for creating and formatting customizable tables in Slack messages as an alternative to Markdown tables.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published