class Embulk::Output::ExampleOutputPlugin

Public Class Methods

new(task, schema, index) click to toggle source
Calls superclass method
# File lib/embulk/data/bundle/embulk/output/example.rb, line 25
def initialize(task, schema, index)
  puts "Example output thread #{index}..."
  super
  @message = task.param('message', :string)
  @records = 0
end
resume(task, schema, count) { |task| ... } click to toggle source
# File lib/embulk/data/bundle/embulk/output/example.rb, line 16
def self.resume(task, schema, count, &control)
  puts "Example output started."
  task_reports = yield(task)
  puts "Example output finished. Commit reports = #{task_reports.to_json}"

  next_config_diff = {}
  return next_config_diff
end
transaction(config, schema, count, &control) click to toggle source
# File lib/embulk/data/bundle/embulk/output/example.rb, line 8
def self.transaction(config, schema, count, &control)
  task = {
    'message' => config.param('message', :string, default: "record")
  }

  resume(task, schema, count, &control)
end

Public Instance Methods

abort() click to toggle source
# File lib/embulk/data/bundle/embulk/output/example.rb, line 46
def abort
end
add(page) click to toggle source
# File lib/embulk/data/bundle/embulk/output/example.rb, line 35
def add(page)
  page.each do |record|
    hash = Hash[schema.names.zip(record)]
    STDOUT.write "#{@message}: #{hash.to_json}\n"
    @records += 1
  end
end
close() click to toggle source
# File lib/embulk/data/bundle/embulk/output/example.rb, line 32
def close
end
commit() click to toggle source
# File lib/embulk/data/bundle/embulk/output/example.rb, line 49
def commit
  task_report = {
    "records" => @records
  }
  return task_report
end
finish() click to toggle source
# File lib/embulk/data/bundle/embulk/output/example.rb, line 43
def finish
end