class HammerCLI::Options::Normalizers::ListNested
Attributes
schema[R]
Public Class Methods
common_description()
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 155 def common_description _('Comma separated list of values defined by a schema.') + "\n" + _('JSON is acceptable and preferred way for such parameters') end
completion_type()
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 151 def completion_type :schema end
new(schema)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 183 def initialize(schema) @schema = Schema.new(schema) end
Public Instance Methods
completion_type()
click to toggle source
Calls superclass method
HammerCLI::Options::Normalizers::AbstractNormalizer::completion_type
# File lib/hammer_cli/options/normalizers.rb, line 200 def completion_type super.merge({ schema: schema.description(richtext: false) }) end
format(val)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 187 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