class HammerCLI::Options::Normalizers::ListNested

Attributes

schema[R]

Public Class Methods

new(schema) click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 125
def initialize(schema)
  @schema = Schema.new(schema)
end

Public Instance Methods

description() click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 129
def description
  _("Comma separated list of values defined by a schema. See Option details section below.") + "\n" +
  _("JSON is acceptable and preferred way for complex parameters")
end
format(val) click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 134
def format(val)
  return [] unless val.is_a?(String) && !val.empty?
  begin
    JSON.parse(val)
  rescue JSON::ParserError
    HammerCLI::CSVParser.new.parse(val).inject([]) do |results, item|
      next if item.empty?

      results << KeyValueList.new.format(item)
    end
  end
end