Sha256: 754745fd78ded1522bbaf25b6ee03356671608492b7dfd6dda4a44a294396056
Contents?: true
Size: 1.19 KB
Versions: 73
Compression:
Stored size: 1.19 KB
Contents
module Embulk module Formatter class <%= ruby_class_name %> < FormatterPlugin Plugin.register_formatter(<%= name.dump %>, self) def self.transaction(config, schema, &control) # configuration code: task = { "option1" => config.param("option1", :integer), # integer, required "option2" => config.param("option2", :string, default: "myvalue"), # string, optional "option3" => config.param("option3", :string, default: nil), # string, optional } yield(task) end def init # initialization code: @option1 = task["option1"] @option2 = task["option2"] @option3 = task["option3"] # your data @current_file == nil @current_file_size = 0 end def close end def add(page) # output code: page.each do |record| if @current_file == nil || @current_file_size > 32*1024 @current_file = file_output.next_file @current_file_size = 0 end @current_file.write "|mydata|" end end def finish file_output.finish end end end end
Version data entries
73 entries across 73 versions & 1 rubygems