Class: Wukong::Processor::FromCsv

Inherits:
Serializer show all
Defined in:
lib/wukong/widget/serializers.rb

Overview

A widget for deserializing inputs from CSV.

Examples:

Deserializing from CSV at the beginning of a data flow


Wukong.dataflow(:consumes_csv) do
  from_csv | ...
end

See Also:

Constant Summary

Constants inherited from Wukong::Processor

SerializerError

Instance Method Summary collapse

Methods inherited from Serializer

#handle_error

Methods inherited from Wukong::Processor

configure, consumes, description, #expected_record_type, #expected_serialization, #finalize, #perform_action, produces, #receive_action, #setup, #stop, valid_serializer?, validate_and_set_serialization

Methods included from Logging

included

Methods included from Hanuman::StageClassMethods

#builder, #label, #register, #set_builder

Instance Method Details

#process(csv) {|obj| ... } ⇒ Object

Yields the input record deserialized from CSV.

Parameters:

Yields:

  • (obj)

    the deserialized object

Yield Parameters:

  • obj (Object)


194
195
196
197
198
199
200
201
202
# File 'lib/wukong/widget/serializers.rb', line 194

def process(csv)
  begin
    record = csv.split(/,/)
  rescue => e
    # FIXME -- should we log here or what?
    return
  end
  yield record
end