embulk 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +5 -13
  2. data/.travis.yml +16 -0
  3. data/Gemfile +0 -1
  4. data/README.md +37 -19
  5. data/Rakefile +5 -37
  6. data/bin/embulk +1 -1
  7. data/build.gradle +178 -95
  8. data/embulk-core/build.gradle +1 -1
  9. data/embulk-core/src/main/java/org/embulk/command/Runner.java +11 -10
  10. data/embulk-core/src/main/java/org/embulk/config/ConfigDiff.java +26 -0
  11. data/embulk-core/src/main/java/org/embulk/config/ConfigInject.java +14 -0
  12. data/embulk-core/src/main/java/org/embulk/config/DataSourceImpl.java +2 -2
  13. data/embulk-core/src/main/java/org/embulk/config/DataSourceSerDe.java +4 -3
  14. data/embulk-core/src/main/java/org/embulk/config/TaskSerDe.java +5 -3
  15. data/embulk-core/src/main/java/org/embulk/config/TaskValidationException.java +1 -0
  16. data/embulk-core/src/main/java/org/embulk/exec/ExecutionResult.java +6 -6
  17. data/embulk-core/src/main/java/org/embulk/exec/GuessExecutor.java +19 -19
  18. data/embulk-core/src/main/java/org/embulk/exec/LocalExecutor.java +61 -36
  19. data/embulk-core/src/main/java/org/embulk/plugin/InjectedPluginSource.java +4 -0
  20. data/embulk-core/src/main/java/org/embulk/plugin/PluginManager.java +16 -1
  21. data/embulk-core/src/main/java/org/embulk/spi/Column.java +1 -1
  22. data/embulk-core/src/main/java/org/embulk/spi/{SchemaVisitor.java → ColumnVisitor.java} +1 -1
  23. data/embulk-core/src/main/java/org/embulk/spi/Exec.java +3 -3
  24. data/embulk-core/src/main/java/org/embulk/spi/ExecSession.java +2 -2
  25. data/embulk-core/src/main/java/org/embulk/spi/FileInputPlugin.java +3 -3
  26. data/embulk-core/src/main/java/org/embulk/spi/FileInputRunner.java +3 -3
  27. data/embulk-core/src/main/java/org/embulk/spi/FileOutputPlugin.java +3 -3
  28. data/embulk-core/src/main/java/org/embulk/spi/FileOutputRunner.java +3 -3
  29. data/embulk-core/src/main/java/org/embulk/spi/FilterPlugin.java +1 -1
  30. data/embulk-core/src/main/java/org/embulk/spi/GuessPlugin.java +2 -2
  31. data/embulk-core/src/main/java/org/embulk/spi/InputPlugin.java +3 -3
  32. data/embulk-core/src/main/java/org/embulk/spi/OutputPlugin.java +3 -3
  33. data/embulk-core/src/main/java/org/embulk/spi/PluginClassLoader.java +80 -0
  34. data/embulk-core/src/main/java/org/embulk/spi/Schema.java +1 -1
  35. data/embulk-core/src/main/java/org/embulk/spi/time/TimestampFormatter.java +2 -2
  36. data/embulk-core/src/main/java/org/embulk/spi/time/TimestampParser.java +2 -2
  37. data/embulk-core/src/main/java/org/embulk/spi/util/Filters.java +1 -1
  38. data/embulk-core/src/main/java/org/embulk/spi/util/LineEncoder.java +2 -2
  39. data/embulk-core/src/main/java/org/embulk/spi/util/PagePrinter.java +6 -6
  40. data/embulk-core/src/main/java/org/embulk/spi/util/Pages.java +6 -6
  41. data/embulk-core/src/test/java/org/embulk/GuiceBinder.java +1 -1
  42. data/embulk-core/src/test/java/org/embulk/plugin/MockPluginSource.java +1 -0
  43. data/embulk-core/src/test/java/org/embulk/spi/MockFormatterPlugin.java +2 -2
  44. data/embulk-core/src/test/java/org/embulk/spi/PageTestUtils.java +1 -1
  45. data/embulk-core/src/test/java/org/embulk/spi/TestFileInputRunner.java +3 -3
  46. data/embulk-core/src/test/java/org/embulk/spi/TestFileOutputRunner.java +4 -4
  47. data/embulk-docs/Makefile +178 -0
  48. data/embulk-docs/build.gradle +20 -0
  49. data/embulk-docs/make.bat +243 -0
  50. data/embulk-docs/push-gh-pages.sh +29 -0
  51. data/embulk-docs/src/conf.py +260 -0
  52. data/embulk-docs/src/index.rst +19 -0
  53. data/embulk-docs/src/release.rst +14 -0
  54. data/embulk-docs/src/release/release-0.1.0.rst +8 -0
  55. data/embulk-docs/src/release/release-0.2.0.rst +16 -0
  56. data/embulk-docs/src/release/release-0.2.1.rst +19 -0
  57. data/embulk-docs/src/release/release-0.3.0.rst +34 -0
  58. data/embulk-docs/src/release/release-0.3.1.rst +11 -0
  59. data/embulk-docs/src/release/release-0.3.2.rst +15 -0
  60. data/embulk-docs/src/release/release-0.4.0.rst +74 -0
  61. data/embulk-standards/build.gradle +0 -1
  62. data/embulk-standards/src/main/java/org/embulk/standards/CsvFormatterPlugin.java +2 -2
  63. data/embulk-standards/src/main/java/org/embulk/standards/CsvParserPlugin.java +12 -3
  64. data/embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java +2 -2
  65. data/embulk-standards/src/main/java/org/embulk/standards/LocalFileInputPlugin.java +49 -26
  66. data/embulk-standards/src/main/java/org/embulk/standards/LocalFileOutputPlugin.java +16 -17
  67. data/embulk-standards/src/main/java/org/embulk/standards/NullOutputPlugin.java +4 -4
  68. data/embulk-standards/src/main/java/org/embulk/standards/StandardPluginModule.java +0 -1
  69. data/embulk-standards/src/main/java/org/embulk/standards/StdoutOutputPlugin.java +5 -5
  70. data/gradle/wrapper/gradle-wrapper.jar +0 -0
  71. data/gradle/wrapper/gradle-wrapper.properties +2 -2
  72. data/lib/embulk/buffer.rb +2 -2
  73. data/lib/embulk/column.rb +6 -6
  74. data/lib/embulk/command/embulk_example.rb +1 -1
  75. data/lib/embulk/command/embulk_new_plugin.rb +87 -0
  76. data/lib/embulk/command/embulk_run.rb +84 -26
  77. data/lib/embulk/data/bundle/Gemfile +12 -20
  78. data/lib/embulk/data/bundle/embulk/{filter_example.rb → filter/example.rb} +3 -3
  79. data/lib/embulk/data/bundle/embulk/{input_example.rb → input/example.rb} +3 -3
  80. data/lib/embulk/data/bundle/embulk/{output_example.rb → output/example.rb} +3 -3
  81. data/lib/embulk/data/new/LICENSE.txt +21 -0
  82. data/lib/embulk/data/new/README.md.erb +75 -0
  83. data/lib/embulk/data/new/gitignore.erb +12 -0
  84. data/lib/embulk/data/new/java/build.gradle.erb +57 -0
  85. data/lib/embulk/data/new/java/decoder.java.erb +40 -0
  86. data/lib/embulk/data/new/java/encoder.java.erb +40 -0
  87. data/lib/embulk/data/new/java/file_input.java.erb +64 -0
  88. data/lib/embulk/data/new/java/file_output.java.erb +66 -0
  89. data/lib/embulk/data/new/java/filter.java.erb +47 -0
  90. data/lib/embulk/data/new/java/formatter.java.erb +45 -0
  91. data/lib/embulk/data/new/java/gradle/wrapper/gradle-wrapper.jar +0 -0
  92. data/lib/embulk/data/new/java/gradle/wrapper/gradle-wrapper.properties +6 -0
  93. data/lib/embulk/data/new/java/gradlew +164 -0
  94. data/lib/embulk/data/new/java/gradlew.bat +90 -0
  95. data/lib/embulk/data/new/java/input.java.erb +69 -0
  96. data/lib/embulk/data/new/java/output.java.erb +65 -0
  97. data/lib/embulk/data/new/java/parser.java.erb +51 -0
  98. data/lib/embulk/data/new/java/plugin_loader.rb.erb +3 -0
  99. data/lib/embulk/data/new/java/test.java.erb +5 -0
  100. data/lib/embulk/data/new/ruby/Gemfile +2 -0
  101. data/lib/embulk/data/new/ruby/Rakefile +1 -0
  102. data/lib/embulk/data/new/ruby/filter.rb.erb +39 -0
  103. data/lib/embulk/data/new/ruby/gemspec.erb +19 -0
  104. data/lib/embulk/data/new/ruby/input.rb.erb +47 -0
  105. data/lib/embulk/data/new/ruby/output.rb.erb +59 -0
  106. data/lib/embulk/data/package_data.rb +64 -0
  107. data/lib/embulk/data_source.rb +2 -2
  108. data/lib/embulk/decoder_plugin.rb +27 -0
  109. data/lib/embulk/encoder_plugin.rb +27 -0
  110. data/lib/embulk/error.rb +3 -0
  111. data/lib/embulk/file_input_plugin.rb +27 -0
  112. data/lib/embulk/file_output_plugin.rb +27 -0
  113. data/lib/embulk/filter_plugin.rb +28 -9
  114. data/lib/embulk/formatter_plugin.rb +105 -0
  115. data/lib/embulk/guess_csv.rb +10 -1
  116. data/lib/embulk/guess_plugin.rb +22 -27
  117. data/lib/embulk/input_plugin.rb +34 -20
  118. data/lib/embulk/java/bootstrap.rb +5 -0
  119. data/lib/embulk/java/imports.rb +7 -0
  120. data/lib/embulk/java_plugin.rb +84 -0
  121. data/lib/embulk/output_plugin.rb +35 -19
  122. data/lib/embulk/page.rb +1 -1
  123. data/lib/embulk/page_builder.rb +1 -1
  124. data/lib/embulk/parser_plugin.rb +76 -0
  125. data/lib/embulk/plugin.rb +130 -65
  126. data/lib/embulk/plugin_registry.rb +19 -8
  127. data/lib/embulk/schema.rb +4 -4
  128. data/lib/embulk/version.rb +1 -1
  129. data/settings.gradle +1 -0
  130. metadata +123 -90
  131. data/ChangeLog +0 -46
  132. data/embulk-cli/pom.xml +0 -94
  133. data/embulk-core/pom.xml +0 -148
  134. data/embulk-core/src/main/java/org/embulk/config/NextConfig.java +0 -26
  135. data/embulk-standards/pom.xml +0 -68
  136. data/embulk-standards/src/main/java/org/embulk/standards/S3FileInputPlugin.java +0 -250
  137. data/embulk-standards/src/test/java/org/embulk/standards/TestS3FileInputPlugin.java +0 -43
  138. data/pom.xml +0 -541
@@ -0,0 +1,90 @@
1
+ @if "%DEBUG%" == "" @echo off
2
+ @rem ##########################################################################
3
+ @rem
4
+ @rem Gradle startup script for Windows
5
+ @rem
6
+ @rem ##########################################################################
7
+
8
+ @rem Set local scope for the variables with windows NT shell
9
+ if "%OS%"=="Windows_NT" setlocal
10
+
11
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
+ set DEFAULT_JVM_OPTS=
13
+
14
+ set DIRNAME=%~dp0
15
+ if "%DIRNAME%" == "" set DIRNAME=.
16
+ set APP_BASE_NAME=%~n0
17
+ set APP_HOME=%DIRNAME%
18
+
19
+ @rem Find java.exe
20
+ if defined JAVA_HOME goto findJavaFromJavaHome
21
+
22
+ set JAVA_EXE=java.exe
23
+ %JAVA_EXE% -version >NUL 2>&1
24
+ if "%ERRORLEVEL%" == "0" goto init
25
+
26
+ echo.
27
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
+ echo.
29
+ echo Please set the JAVA_HOME variable in your environment to match the
30
+ echo location of your Java installation.
31
+
32
+ goto fail
33
+
34
+ :findJavaFromJavaHome
35
+ set JAVA_HOME=%JAVA_HOME:"=%
36
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
+
38
+ if exist "%JAVA_EXE%" goto init
39
+
40
+ echo.
41
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
+ echo.
43
+ echo Please set the JAVA_HOME variable in your environment to match the
44
+ echo location of your Java installation.
45
+
46
+ goto fail
47
+
48
+ :init
49
+ @rem Get command-line arguments, handling Windowz variants
50
+
51
+ if not "%OS%" == "Windows_NT" goto win9xME_args
52
+ if "%@eval[2+2]" == "4" goto 4NT_args
53
+
54
+ :win9xME_args
55
+ @rem Slurp the command line arguments.
56
+ set CMD_LINE_ARGS=
57
+ set _SKIP=2
58
+
59
+ :win9xME_args_slurp
60
+ if "x%~1" == "x" goto execute
61
+
62
+ set CMD_LINE_ARGS=%*
63
+ goto execute
64
+
65
+ :4NT_args
66
+ @rem Get arguments from the 4NT Shell from JP Software
67
+ set CMD_LINE_ARGS=%$
68
+
69
+ :execute
70
+ @rem Setup the command line
71
+
72
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
+
74
+ @rem Execute Gradle
75
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76
+
77
+ :end
78
+ @rem End local scope for the variables with windows NT shell
79
+ if "%ERRORLEVEL%"=="0" goto mainEnd
80
+
81
+ :fail
82
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
+ rem the _cmd.exe /c_ return code!
84
+ if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85
+ exit /b 1
86
+
87
+ :mainEnd
88
+ if "%OS%"=="Windows_NT" endlocal
89
+
90
+ :omega
@@ -0,0 +1,69 @@
1
+ package org.embulk.<%= embulk_category %>;
2
+
3
+ import java.util.List;
4
+ import org.embulk.config.CommitReport;
5
+ import org.embulk.config.Config;
6
+ import org.embulk.config.ConfigDefault;
7
+ import org.embulk.config.ConfigDiff;
8
+ import org.embulk.config.ConfigSource;
9
+ import org.embulk.config.Task;
10
+ import org.embulk.config.TaskSource;
11
+ import org.embulk.spi.Exec;
12
+ import org.embulk.spi.InputPlugin;
13
+ import org.embulk.spi.PageOutput;
14
+ import org.embulk.spi.Schema;
15
+ import org.embulk.spi.SchemaConfig;
16
+
17
+ public class <%= java_class_name %>
18
+ implements InputPlugin
19
+ {
20
+ public interface PluginTask
21
+ extends Task
22
+ {
23
+ @Config("property1")
24
+ public String getProperty1();
25
+
26
+ @Config("property2")
27
+ @ConfigDefault("0")
28
+ public int getProperty2();
29
+
30
+ // TODO get schema from config or data source
31
+ @Config("columns")
32
+ public SchemaConfig getColumns();
33
+ }
34
+
35
+ public ConfigDiff transaction(ConfigSource config,
36
+ InputPlugin.Control control)
37
+ {
38
+ PluginTask task = config.loadConfig(PluginTask.class);
39
+
40
+ Schema schema = task.getColumns().toSchema();
41
+ int processorCount = 1; // number of run() method calls
42
+
43
+ return resume(task.dump(), schema, processorCount, control);
44
+ }
45
+
46
+ public ConfigDiff resume(TaskSource taskSource,
47
+ Schema schema, int processorCount,
48
+ InputPlugin.Control control)
49
+ {
50
+ control.run(taskSource, schema, processorCount);
51
+ return Exec.newConfigDiff();
52
+ }
53
+
54
+ public void cleanup(TaskSource taskSource,
55
+ Schema schema, int processorCount,
56
+ List<CommitReport> successCommitReports)
57
+ {
58
+ }
59
+
60
+ public CommitReport run(TaskSource taskSource,
61
+ Schema schema, int processorIndex,
62
+ PageOutput output)
63
+ {
64
+ PluginTask task = taskSource.loadTask(PluginTask.class);
65
+
66
+ // TODO
67
+ throw new UnsupportedOperationException("The 'run' method needs to be implemented");
68
+ }
69
+ }
@@ -0,0 +1,65 @@
1
+ package org.embulk.<%= embulk_category %>;
2
+
3
+ import java.util.List;
4
+ import org.embulk.config.CommitReport;
5
+ import org.embulk.config.Config;
6
+ import org.embulk.config.ConfigDefault;
7
+ import org.embulk.config.ConfigDiff;
8
+ import org.embulk.config.ConfigSource;
9
+ import org.embulk.config.Task;
10
+ import org.embulk.config.TaskSource;
11
+ import org.embulk.spi.Exec;
12
+ import org.embulk.spi.OutputPlugin;
13
+ import org.embulk.spi.PageOutput;
14
+ import org.embulk.spi.Schema;
15
+ import org.embulk.spi.TransactionalPageOutput;
16
+
17
+ public class <%= java_class_name %>
18
+ implements OutputPlugin
19
+ {
20
+ public interface PluginTask
21
+ extends Task
22
+ {
23
+ @Config("property1")
24
+ public String getProperty1();
25
+
26
+ @Config("property2")
27
+ @ConfigDefault("0")
28
+ public int getProperty2();
29
+ }
30
+
31
+ public ConfigDiff transaction(ConfigSource config,
32
+ Schema schema, int processorCount,
33
+ OutputPlugin.Control control)
34
+ {
35
+ PluginTask task = config.loadConfig(PluginTask.class);
36
+
37
+ // retryable (idempotent) output:
38
+ // return resume(task.dump(), schema, processorCount, control);
39
+
40
+ // non-retryable (non-idempotent) output:
41
+ control.run(task.dump());
42
+ return Exec.newConfigDiff();
43
+ }
44
+
45
+ public ConfigDiff resume(TaskSource taskSource,
46
+ Schema schema, int processorCount,
47
+ OutputPlugin.Control control)
48
+ {
49
+ throw new UnsupportedOperationException("<%= name %> output plugin does not support resuming");
50
+ }
51
+
52
+ public void cleanup(TaskSource taskSource,
53
+ Schema schema, int processorCount,
54
+ List<CommitReport> successCommitReports)
55
+ {
56
+ }
57
+
58
+ public TransactionalPageOutput open(TaskSource taskSource, Schema schema, int processorIndex)
59
+ {
60
+ PluginTask task = taskSource.loadTask(PluginTask.class);
61
+
62
+ // TODO
63
+ throw new UnsupportedOperationException("The 'open' method needs to be implemented");
64
+ }
65
+ }
@@ -0,0 +1,51 @@
1
+ package org.embulk.<%= embulk_category %>;
2
+
3
+ import org.embulk.config.Config;
4
+ import org.embulk.config.ConfigDefault;
5
+ import org.embulk.config.ConfigDiff;
6
+ import org.embulk.config.ConfigSource;
7
+ import org.embulk.config.Task;
8
+ import org.embulk.config.TaskSource;
9
+ import org.embulk.spi.ParserPlugin;
10
+ import org.embulk.spi.FileInput;
11
+ import org.embulk.spi.PageOutput;
12
+ import org.embulk.spi.Schema;
13
+ import org.embulk.spi.SchemaConfig;
14
+
15
+ public class <%= java_class_name %>
16
+ implements ParserPlugin
17
+ {
18
+ public interface PluginTask
19
+ extends Task
20
+ {
21
+ @Config("property1")
22
+ public String getProperty1();
23
+
24
+ @Config("property2")
25
+ @ConfigDefault("0")
26
+ public int getProperty2();
27
+
28
+ // TODO get schema from config or data source
29
+ @Config("columns")
30
+ public SchemaConfig getColumns();
31
+ }
32
+
33
+ @Override
34
+ public void transaction(ConfigSource config, ParserPlugin.Control control)
35
+ {
36
+ PluginTask task = config.loadConfig(PluginTask.class);
37
+
38
+ Schema schema = task.getColumns().toSchema();
39
+
40
+ control.run(task.dump(), schema);
41
+ }
42
+
43
+ @Override
44
+ public void run(TaskSource taskSource, Schema schema,
45
+ FileInput input, PageOutput output)
46
+ {
47
+ PluginTask task = taskSource.loadTask(PluginTask.class);
48
+
49
+ // TODO
50
+ }
51
+ }
@@ -0,0 +1,3 @@
1
+ Embulk::JavaPlugin.register_<%= embulk_category %>(
2
+ <%= name.to_sym.inspect %>, <%= "org.embulk.#{embulk_category}.#{java_class_name}".dump %>,
3
+ File.expand_path('../../../../classpath', __FILE__))
@@ -0,0 +1,5 @@
1
+ package org.embulk.<%= embulk_category %>;
2
+
3
+ public class Test<%= java_class_name %>
4
+ {
5
+ }
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,39 @@
1
+ module Embulk
2
+ module Filter
3
+
4
+ class <%= ruby_class_name %> < FilterPlugin
5
+ Plugin.register_filter(<%= name %>, self)
6
+
7
+ def self.transaction(config, in_schema, &control)
8
+ # configuration code:
9
+ task = {
10
+ "property1" => config.param("property1", :string)
11
+ "property2" => config.param("property2", :integer, default: 0)
12
+ }
13
+
14
+ yield(task, out_columns)
15
+ end
16
+
17
+ def init
18
+ # initialization code:
19
+ @property1 = task["property1"]
20
+ @property2 = task["property2"]
21
+ end
22
+
23
+ def close
24
+ end
25
+
26
+ def add(page)
27
+ # filtering code:
28
+ page.each do |record|
29
+ @page_builder.add(record)
30
+ end
31
+ end
32
+
33
+ def finish
34
+ @page_builder.finish
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "<%= project_name %>"
4
+ spec.version = "0.1.0"
5
+ spec.authors = [<%= author.dump %>]
6
+ spec.summary = "<%= display_name %> <%= display_category %> plugin for Embulk"
7
+ spec.description = "<%= display_name %> <%= display_category %> plugin is an Embulk plugin <%= description %>"
8
+ spec.email = [<%= email.dump %>]
9
+ spec.licenses = ["MIT"]
10
+ # TODO: spec.homepage = "https://github.com/<%= email[/([^@]*)/] %>/<%= project_name %>"
11
+
12
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
13
+ spec.test_files = spec.files.grep(%r{^(test|spec)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ #spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
17
+ spec.add_development_dependency 'bundler', ['~> 1.0']
18
+ spec.add_development_dependency 'rake', ['>= 10.0']
19
+ end
@@ -0,0 +1,47 @@
1
+ module Embulk
2
+ module Input
3
+
4
+ class <%= ruby_class_name %> < InputPlugin
5
+ Plugin.register_input(<%= name %>, self)
6
+
7
+ def self.transaction(config, &control)
8
+ # configuration code:
9
+ task = {
10
+ "property1" => config.param("property1", :string)
11
+ "property2" => config.param("property2", :integer, default: 0)
12
+ }
13
+
14
+ columns = [
15
+ Column.new(0, "example", :string),
16
+ Column.new(1, "column", :integer),
17
+ Column.new(2, "name", :double),
18
+ ]
19
+
20
+ resume(task, columns, 1, &control)
21
+ end
22
+
23
+ def self.resume(task, columns, count, &control)
24
+ commit_reports = yield(task, columns, count)
25
+
26
+ next_config_diff = {}
27
+ return next_config_diff
28
+ end
29
+
30
+ def init
31
+ # initialization code:
32
+ @property1 = task["property1"]
33
+ @property2 = task["property2"]
34
+ end
35
+
36
+ def run
37
+ @page_builder.add(["example-value", 1, 0.1])
38
+ @page_builder.add(["example-value", 2, 0.2])
39
+ @page_builder.finish
40
+
41
+ commit_report = {}
42
+ return commit_report
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,59 @@
1
+ module Embulk
2
+ module Output
3
+
4
+ class <%= ruby_class_name %> < OutputPlugin
5
+ Plugin.register_output(<%= name.dump %>, self)
6
+
7
+ def self.transaction(config, schema, count, &control)
8
+ # configuration code:
9
+ task = {
10
+ "property1" => config.param("property1", :string)
11
+ "property2" => config.param("property2", :integer, default: 0)
12
+ }
13
+
14
+ # resumable output:
15
+ # resume(task, schema, count, &control)
16
+
17
+ # non-resumable output:
18
+ commit_reports = yield(task)
19
+ next_config_diff = {}
20
+ return next_config_diff
21
+ end
22
+
23
+ #def self.resume(task, schema, count, &control)
24
+ # commit_reports = yield(task)
25
+ #
26
+ # next_config_diff = {}
27
+ # return next_config_diff
28
+ #end
29
+
30
+ def init
31
+ # initialization code:
32
+ @property1 = task["property1"]
33
+ @property2 = task["property2"]
34
+ end
35
+
36
+ def close
37
+ end
38
+
39
+ def add(page)
40
+ # output code:
41
+ page.each do |record|
42
+ #hash = Hash[schema.names.zip(record)]
43
+ end
44
+ end
45
+
46
+ def finish
47
+ end
48
+
49
+ def abort
50
+ end
51
+
52
+ def commit
53
+ commit_report = {}
54
+ return commit_report
55
+ end
56
+ end
57
+
58
+ end
59
+ end