tabbit 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tabbit.rb +8 -7
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94308328d60f339509c995c85f7c4422caad16f9
|
4
|
+
data.tar.gz: a38b7cdba853b47590d62057b1462df11349d63d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5196b63840a753d4c55fb875d4f789413ea7f7efc904adc6db04afe26eadf7ac494153ed4cca9f66343adea49d4f17315b32f5802fb2719870dfdf30462e3c83
|
7
|
+
data.tar.gz: 9eaac2f4f46edb772451cfe8486dbddde7e201fb3228609138ff509c834c14949b8e721e0cc4d99fe865e0126ff0a22580b835d58dd3201e68a773ad2c010a4d
|
data/lib/tabbit.rb
CHANGED
@@ -3,17 +3,21 @@ require 'toc'
|
|
3
3
|
class Tabbit
|
4
4
|
# When Tabbit.new is called, takes a undefined amount of headers to add
|
5
5
|
# to the table.
|
6
|
+
|
7
|
+
# Table initialized as an Array
|
6
8
|
def initialize(*headers)
|
7
9
|
@table = [[]]
|
8
10
|
headers.each { |h| @table[0].push h }
|
9
11
|
end
|
10
12
|
|
13
|
+
# Adds line to @table in form of Array
|
11
14
|
def add_line(*items)
|
12
15
|
line = []
|
13
16
|
items.each { |i| line.push i }
|
14
17
|
@table.push line
|
15
18
|
end
|
16
19
|
|
20
|
+
# Changes @table Array into format for printing to console.
|
17
21
|
def to_s
|
18
22
|
# Set instance variables for maximum length of each column
|
19
23
|
@table[0].length.times do |n|
|
@@ -49,8 +53,8 @@ class Tabbit
|
|
49
53
|
line = @table[n]
|
50
54
|
line.length.times do |i|
|
51
55
|
item = line[i]
|
52
|
-
|
53
|
-
difference2 =
|
56
|
+
max_len_of_column = self.instance_variable_get("@max_length_#{i}")
|
57
|
+
difference2 = max_len_of_column - item.length + 2 # Spaces needed after item in column.
|
54
58
|
if item == line.last
|
55
59
|
puts '|' + (' ' * 2) + item + (' ' * difference2) + '|'
|
56
60
|
else
|
@@ -69,11 +73,8 @@ class Tabbit
|
|
69
73
|
def divider(split, table, options = {})
|
70
74
|
total_title_length = 0
|
71
75
|
table[0].length.times { |n| total_title_length += self.instance_variable_get("@max_length_#{n}") }
|
76
|
+
statement = split * ((table[0].length * 5) + total_title_length + 1)
|
72
77
|
|
73
|
-
|
74
|
-
puts split * ((table[0].length * 5) + total_title_length + 1)
|
75
|
-
else
|
76
|
-
print split * ((table[0].length * 5) + total_title_length + 1)
|
77
|
-
end
|
78
|
+
options[:new_line] ? puts(statement) : print(statement)
|
78
79
|
end
|
79
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Green
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,14 +38,14 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description: Tabbit is a simple tool for making tables in the command line.
|
42
42
|
email: tiimgreen@gmail.com
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
47
|
- lib/tabbit.rb
|
48
|
-
homepage: https://github.com/tiimgreen/
|
48
|
+
homepage: https://github.com/tiimgreen/tabbit
|
49
49
|
licenses:
|
50
50
|
- MIT
|
51
51
|
metadata: {}
|
@@ -68,6 +68,6 @@ rubyforge_project:
|
|
68
68
|
rubygems_version: 2.1.11
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
|
-
summary:
|
71
|
+
summary: Make tables in the command line.
|
72
72
|
test_files: []
|
73
73
|
has_rdoc:
|