Module: Smithy::Format
- Defined in:
- lib/smithy/format.rb
Defined Under Namespace
Classes: CSV, Doku, Name, Path, Table
Class Method Summary
collapse
Class Method Details
.print_column_list(items) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/smithy/format.rb', line 40
def self.print_column_list(items)
max_size = 0
items.each { |m| max_size = m.size if m.size > max_size }
width = `tput cols`.to_i
columns = (width/(max_size+3.0)).ceil
items_per_column = (items.size/columns.to_f).ceil
items_copy = items.dup
s = []
columns.times do
s << items_copy.slice!(0, items_per_column)
end
while s.last.size < items_per_column do
s.last << ""
end
table = Terminal::Table.new :rows => s.transpose
puts table.to_s
end
|
.software_row(s) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/smithy/format.rb', line 59
def self.software_row(s)
row = []
row << s
source = s+'/rebuild'
if File.exist?(source)
f = File.stat(source)
else
f = File.stat(s)
end
row << f.mtime.strftime("%Y-%m-%d %H:%M:%S")
begin
user = Etc.getpwuid(f.uid)
row << user.try(:name)
row << user.try(:gecos)
rescue
row << 'unknown'
row << 'unknown'
end
end
|