tty 0.0.1 → 0.0.2
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.
- data/.gitignore +1 -0
- data/README.md +45 -6
- data/lib/tty.rb +23 -2
- data/lib/tty/color.rb +0 -4
- data/lib/tty/support/conversion.rb +34 -0
- data/lib/tty/support/delegatable.rb +44 -0
- data/lib/tty/support/utils.rb +2 -0
- data/lib/tty/system.rb +31 -0
- data/lib/tty/table.rb +155 -20
- data/lib/tty/table/error.rb +10 -0
- data/lib/tty/table/renderer.rb +16 -6
- data/lib/tty/table/renderer/basic.rb +60 -20
- data/lib/tty/table/renderer/color.rb +1 -1
- data/lib/tty/table/renderer/unicode.rb +1 -1
- data/lib/tty/table/validatable.rb +34 -0
- data/lib/tty/terminal.rb +149 -0
- data/lib/tty/version.rb +1 -1
- data/spec/tty/support/conversion_spec.rb +38 -0
- data/spec/tty/support/delegatable_spec.rb +26 -0
- data/spec/tty/support/fixtures/classes.rb +17 -0
- data/spec/tty/system/platform_spec.rb +21 -0
- data/spec/tty/table/access_spec.rb +59 -0
- data/spec/tty/table/eql_spec.rb +28 -0
- data/spec/tty/table/initialize_spec.rb +53 -0
- data/spec/tty/table/properties_spec.rb +24 -0
- data/spec/tty/table/renderer/basic_spec.rb +20 -0
- data/spec/tty/table/renderer_spec.rb +7 -0
- data/spec/tty/table/validatable_spec.rb +19 -0
- data/spec/tty/terminal/size_spec.rb +94 -0
- metadata +34 -11
- data/lib/tty/support/.utils.rb.swo +0 -0
- data/spec/tty/table/table_spec.rb +0 -75
Binary file
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe TTY::Table do
|
6
|
-
|
7
|
-
it { should be_kind_of(Enumerable) }
|
8
|
-
it { should be_kind_of(Comparable) }
|
9
|
-
|
10
|
-
it { (Enumerable === subject).should be_true }
|
11
|
-
|
12
|
-
context '#initalize' do
|
13
|
-
let(:header) { ['Header1', 'Header2'] }
|
14
|
-
let(:rows) { [['a1', 'a2'], ['b1', 'b2']] }
|
15
|
-
|
16
|
-
it 'initializes table header' do
|
17
|
-
table = TTY::Table.new header
|
18
|
-
table.header.should == header
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'initializes table header as an option' do
|
22
|
-
table = TTY::Table.new :header => header
|
23
|
-
table.header.should == header
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'initializes table rows as an option' do
|
27
|
-
table = TTY::Table.new :header => header, :rows => rows
|
28
|
-
table.to_a.should == rows
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'initializes table rows as an argument' do
|
32
|
-
table = TTY::Table.new header, rows
|
33
|
-
table.to_a.should == rows
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'initializes table rows in a block with param' do
|
37
|
-
table = TTY::Table.new header do |t|
|
38
|
-
t << rows[0]
|
39
|
-
t << rows[1]
|
40
|
-
end
|
41
|
-
table.to_a.should == rows
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'initializes table and adds rows' do
|
45
|
-
table = TTY::Table.new header
|
46
|
-
table << rows[0]
|
47
|
-
table << rows[1]
|
48
|
-
table.to_a.should == rows
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context '#size' do
|
53
|
-
it 'has no size' do
|
54
|
-
table = TTY::Table.new
|
55
|
-
table.size.should == 0
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'has size' do
|
59
|
-
rows = [['a1', 'a2', 'a3'], ['b1', 'b2', 'c3']]
|
60
|
-
table = TTY::Table.new ['Header1', 'Header2'], rows
|
61
|
-
table.size.should == 3
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context '#columns' do
|
66
|
-
it 'looks up column' do
|
67
|
-
rows = [['a1', 'a2'], ['b1', 'b2']]
|
68
|
-
table = TTY::Table.new
|
69
|
-
table << rows[0]
|
70
|
-
table << rows[1]
|
71
|
-
table[0].should == ['a1', 'b1']
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end # TTY::Table
|