Project

atv

0.01
No commit activity in last 3 years
No release in over 3 years
Read data from an ascii table.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.7
~> 10.0
 Project Readme

ATV: Ascii Table Values

ATV is a reader for data in ascii table format. It allows you to read data formatted like this:

|------------------+--------------------|
| name             | dob                |
|------------------+--------------------|
| Malcolm Reynolds | September 20, 2468 |
|------------------+--------------------|
| Zoe Washburne    | February 15, 2484  |
|------------------+--------------------|

or, without separators, like this:

|------------------+--------------------|
| name             | dob                |
|------------------+--------------------|
| Malcolm Reynolds | September 20, 2468 |
| Zoe Washburne    | February 15, 2484  |
|------------------+--------------------|

In Ascii Tables For Clearer Testing I discuss using ascii tables to improve comprehension of software tests.

This gem was originally created when I worked at Indiegogo. Indiegogo has graciously transferred ownership of the gem to me so that I can maintain it going forward.

Installation

Add this line to your application's Gemfile:

gem 'atv'

And then execute:

$ bundle

Or install it yourself as:

$ gem install atv

Usage

Rows are returned or yielded as CSV::Row objects.

|-----------------------+------------------------------+-----------------------------------|
| **Ascii Table Value** | **Returned Value**           | **Notes**                         |
|-----------------------+------------------------------+-----------------------------------|
| Malcolm Reynolds      | "Malcolm Reynolds"           | Most values returned as string    |
|-----------------------+------------------------------+-----------------------------------|
| 123                   | "123"                        | including numbers                 |
|-----------------------+------------------------------+-----------------------------------|
| wrapped strings are   | "wrapped strings are folded" | Similar to yaml, wrapped          |
| folded                |                              | strings are folded with a single  |
|                       |                              | space replacing the new line      |
|-----------------------+------------------------------+-----------------------------------|
|                       | nil                          | The CSV::Row object will have nil |
|                       |                              | for blank values                  |
|-----------------------+------------------------------+-----------------------------------|
| null                  | nil                          | null, true, and false are         |
|                       |                              | special values                    |
|-----------------------+------------------------------+-----------------------------------|
| true                  | true                         |                                   |
|-----------------------+------------------------------+-----------------------------------|
| false                 | false                        |                                   |
|-----------------------+------------------------------+-----------------------------------|
#| commented rows        | not included                 | As you would expect, commented    |
#|                       |                              | rows are not included             |
#|-----------------------+------------------------------+-----------------------------------|

Reading a String

atv = ATV.from_string(string)
atv.each do |row|
  # use row here...
end

Reading from am IO object

atv = ATV.new(io)
atv.each do |row|
  # use row here...
end

More examples can be found in the Examples of Testing With ASCII Tables repo.

Contributing

  1. Fork it ( https://github.com/kellyfelkins/atv )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request