Sha256: 2b6b7abb68711a52e6c4f0d86e346a68fa61ae2ccde29e033cd0c3e15bfd7b5b

Contents?: true

Size: 765 Bytes

Versions: 3

Compression:

Stored size: 765 Bytes

Contents

module HammerCLI::Output::Adapter
  class Yaml < TreeStructure

    def print_record(fields, record)
      result = prepare_collection(fields, [record].flatten(1))
      output_stream.puts YAML.dump(result.first)
    end

    def print_collection(fields, collection)
      result = prepare_collection(fields, collection)
      output_stream.puts YAML.dump(result)
    end

    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 YAML.dump(data)
    end

  end
  HammerCLI::Output::Output.register_adapter(:yaml, Yaml)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hammer_cli-0.14.0 lib/hammer_cli/output/adapter/yaml.rb
hammer_cli-0.13.1 lib/hammer_cli/output/adapter/yaml.rb
hammer_cli-0.13.0 lib/hammer_cli/output/adapter/yaml.rb