Class: Embulk::Plugin::OutputExample
- Inherits:
-
OutputPlugin
- Object
- OutputPlugin
- Embulk::Plugin::OutputExample
- Defined in:
- lib/embulk/data/bundle/embulk/output_example.rb
Instance Attribute Summary
Attributes inherited from OutputPlugin
Class Method Summary collapse
- .resume(task, schema, count, &control) ⇒ Object
- .transaction(config, schema, count, &control) ⇒ Object
Instance Method Summary collapse
- #abort ⇒ Object
- #add(page) ⇒ Object
- #close ⇒ Object
- #commit ⇒ Object
- #finish ⇒ Object
-
#initialize(task, schema, index) ⇒ OutputExample
constructor
A new instance of OutputExample.
Methods inherited from OutputPlugin
Constructor Details
#initialize(task, schema, index) ⇒ OutputExample
Returns a new instance of OutputExample.
25 26 27 28 29 30 |
# 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 |
Class Method Details
.resume(task, schema, count, &control) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 16 def self.resume(task, schema, count, &control) puts "Example output started." commit_reports = yield(task) puts "Example output finished. Commit reports = #{commit_reports.to_json}" next_config_diff = {} return next_config_diff end |
.transaction(config, schema, count, &control) ⇒ Object
8 9 10 11 12 13 14 |
# 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 |
Instance Method Details
#abort ⇒ Object
46 47 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 46 def abort end |
#add(page) ⇒ Object
35 36 37 38 39 40 41 |
# 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 ⇒ Object
32 33 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 32 def close end |
#commit ⇒ Object
49 50 51 52 53 54 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 49 def commit commit_report = { "records" => @records } return commit_report end |
#finish ⇒ Object
43 44 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 43 def finish end |