Method: Gitlab::CLI::Helpers.record_table
- Defined in:
- lib/gitlab/cli_helpers.rb
permalink .record_table(data, cmd, args) ⇒ Terminal::Table
Table to display records.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/gitlab/cli_helpers.rb', line 127 def record_table(data, cmd, args) return 'No data' if data.empty? arr, keys = get_keys(args, data) table do |t| t.title = "Gitlab.#{cmd} #{args.join(', ')}" t.headings = keys arr.each_with_index do |hash, index| values = [] keys.each do |key| case value = hash[key] when Hash value = value.key?('id') ? value['id'] : 'Hash' when StringIO value = 'File' when nil value = 'null' end values << value end t.add_row values t.add_separator unless arr.size - 1 == index end end end |