Sha256: 05537faa27f45f620d0f712796694abdd4b414d9c1cd36f63aa6549a15642427

Contents?: true

Size: 1.58 KB

Versions: 42

Compression:

Stored size: 1.58 KB

Contents

module Embulk
  module Input

    class ${rubyClassName} < InputPlugin
      Plugin.register_input("${name}", 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)
        task_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

        task_report = {}
        return task_report
      end
    end

  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
embulk-0.8.39 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.39-java lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.38 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.38-java lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.37 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.37-java lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.36 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.36-java lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.35 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.35-java lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.34 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.34-java lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.33 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.33-java lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.32 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.32-java lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.31 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.31-java lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.30 lib/embulk/data/new/ruby/input.rb.vm
embulk-0.8.30-java lib/embulk/data/new/ruby/input.rb.vm