Sha256: b90f9e0dfa4244d583762c50620f5bb2c5c187de62596270a2520875857b3d6f

Contents?: true

Size: 1.01 KB

Versions: 28

Compression:

Stored size: 1.01 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 = {
          "property1" => config.param("property1", :string),
          "property2" => config.param("property2", :integer, default: 0),
        }

        yield(task)
      end

      def init
        # initialization code:
        @property1 = task["property1"]
        @property2 = task["property2"]

        # 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

28 entries across 28 versions & 1 rubygems

Version Path
embulk-0.6.16 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.15 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.14 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.13 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.12 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.11 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.10 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.9 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.8 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.7 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.6 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.5 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.4 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.3 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.2 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.1 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.6.0 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.5.5 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.5.4 lib/embulk/data/new/ruby/formatter.rb.erb
embulk-0.5.3 lib/embulk/data/new/ruby/formatter.rb.erb