Top Level Namespace
Defined Under Namespace
Modules: GreenHat, LogBot, TTY
Classes: Archive, FalseClass, Float, Host, String, Thing, TrueClass
Instance Method Summary
collapse
Instance Method Details
#filter(data, params = {}) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/greenhat/pry_helpers.rb', line 34
def filter(data, params = {})
result = data.clone
params.each do |k, v|
result.select! do |row|
if row.key? k.to_sym
row[k.to_sym].include? v
else
false
end
end
end
result
end
|
#show(data) ⇒ Object
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/greenhat/pry_helpers.rb', line 1
def show(data)
pastel = Pastel.new
TTY::Pager.page do ||
data.each do |e|
table = TTY::Table.new(header: e.keys, rows: [e], orientation: :vertical)
output = table.render(:unicode, multiline: false) do |renderer|
renderer.border.style = :cyan
renderer.filter = lambda { |val, _row_index, col_index|
puts val.class unless val.instance_of? String
if col_index == 1
if val.numeric?
pastel.red.blue(val)
else
val
end
else
val
end
}
end
.write("\n#{output}") end
end
end
|
#version ⇒ Object
49
50
51
|
# File 'lib/greenhat/pry_helpers.rb', line 49
def version
Thing.find_by(name: 'gitlab_version_manifest_json').data.build_version
end
|