Method: Gitlab::CLI::Helpers.record_hash
- Defined in:
- lib/gitlab/cli_helpers.rb
permalink .record_hash(data, cmd, args, single_value: false) ⇒ Hash
Renders the result of given commands and arguments into a Hash
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/gitlab/cli_helpers.rb', line 165 def record_hash(data, cmd, args, single_value: false) if data.empty? result = nil else arr, keys = get_keys(args, data) result = [] arr.each do |hash| row = {} keys.each do |key| row[key] = case hash[key] when Hash 'Hash' when StringIO Base64.encode64(hash[key].read) when nil nil else hash[key] end end result.push row end result = result[0] if single_value && result.count.positive? end { cmd: "Gitlab.#{cmd} #{args.join(', ')}".strip, result: result } end |