Sha256: 5b06717731f1c9965b252b754b0b1f8117bb616ccd80da753961d74c8199ec37

Contents?: true

Size: 1.59 KB

Versions: 11

Compression:

Stored size: 1.59 KB

Contents

module Embulk
  module Input

    class <%= ruby_class_name %> < InputPlugin
      Plugin.register_input(<%= name.dump %>, self)

      def self.transaction(config, &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
        }

        columns = [
          Column.new(0, "example", :string),
          Column.new(1, "column", :long),
          Column.new(2, "value", :double),
        ]

        resume(task, columns, 1, &control)
      end

      def self.resume(task, columns, count, &control)
        commit_reports = yield(task, columns, count)

        next_config_diff = {}
        return next_config_diff
      end

      # TODO
      #def self.guess(config)
      #  sample_records = [
      #    {"example"=>"a", "column"=>1, "value"=>0.1},
      #    {"example"=>"a", "column"=>2, "value"=>0.2},
      #  ]
      #  columns = Guess::SchemaGuess.from_hash_records(sample_records)
      #  return {"columns" => columns}
      #end

      def init
        # initialization code:
        @option1 = task["option1"]
        @option2 = task["option2"]
        @option3 = task["option3"]
      end

      def run
        page_builder.add(["example-value", 1, 0.1])
        page_builder.add(["example-value", 2, 0.2])
        page_builder.finish

        commit_report = {}
        return commit_report
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
embulk-0.6.27 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.26 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.25 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.24 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.23 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.22 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.21 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.20 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.19 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.18 lib/embulk/data/new/ruby/input.rb.erb
embulk-0.6.17 lib/embulk/data/new/ruby/input.rb.erb