Class: HammerCLI::Output::Adapter::Json
Instance Method Summary
collapse
#prepare_collection
Methods inherited from Abstract
#initialize, #print_error, #tags
Instance Method Details
#print_collection(fields, collection) ⇒ Object
9
10
11
12
|
# File 'lib/hammer_cli/output/adapter/json.rb', line 9
def print_collection(fields, collection)
result = prepare_collection(fields, collection)
puts JSON.pretty_generate(result)
end
|
#print_message(msg, msg_params = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/hammer_cli/output/adapter/json.rb', line 14
def print_message(msg, msg_params={})
id = msg_params["id"] || msg_params[:id]
name = msg_params["name"] || msg_params[:name]
data = {
:message => msg.format(msg_params)
}
data[:id] = id unless id.nil?
data[:name] = name unless name.nil?
puts JSON.pretty_generate(data)
end
|
#print_record(fields, record) ⇒ Object
4
5
6
7
|
# File 'lib/hammer_cli/output/adapter/json.rb', line 4
def print_record(fields, record)
result = prepare_collection(fields, [record].flatten(1))
puts JSON.pretty_generate(result.first)
end
|