embulk 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +16 -0
- data/Gemfile +0 -1
- data/README.md +37 -19
- data/Rakefile +5 -37
- data/bin/embulk +1 -1
- data/build.gradle +178 -95
- data/embulk-core/build.gradle +1 -1
- data/embulk-core/src/main/java/org/embulk/command/Runner.java +11 -10
- data/embulk-core/src/main/java/org/embulk/config/ConfigDiff.java +26 -0
- data/embulk-core/src/main/java/org/embulk/config/ConfigInject.java +14 -0
- data/embulk-core/src/main/java/org/embulk/config/DataSourceImpl.java +2 -2
- data/embulk-core/src/main/java/org/embulk/config/DataSourceSerDe.java +4 -3
- data/embulk-core/src/main/java/org/embulk/config/TaskSerDe.java +5 -3
- data/embulk-core/src/main/java/org/embulk/config/TaskValidationException.java +1 -0
- data/embulk-core/src/main/java/org/embulk/exec/ExecutionResult.java +6 -6
- data/embulk-core/src/main/java/org/embulk/exec/GuessExecutor.java +19 -19
- data/embulk-core/src/main/java/org/embulk/exec/LocalExecutor.java +61 -36
- data/embulk-core/src/main/java/org/embulk/plugin/InjectedPluginSource.java +4 -0
- data/embulk-core/src/main/java/org/embulk/plugin/PluginManager.java +16 -1
- data/embulk-core/src/main/java/org/embulk/spi/Column.java +1 -1
- data/embulk-core/src/main/java/org/embulk/spi/{SchemaVisitor.java → ColumnVisitor.java} +1 -1
- data/embulk-core/src/main/java/org/embulk/spi/Exec.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/ExecSession.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/FileInputPlugin.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/FileInputRunner.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/FileOutputPlugin.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/FileOutputRunner.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/FilterPlugin.java +1 -1
- data/embulk-core/src/main/java/org/embulk/spi/GuessPlugin.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/InputPlugin.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/OutputPlugin.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/PluginClassLoader.java +80 -0
- data/embulk-core/src/main/java/org/embulk/spi/Schema.java +1 -1
- data/embulk-core/src/main/java/org/embulk/spi/time/TimestampFormatter.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/time/TimestampParser.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/util/Filters.java +1 -1
- data/embulk-core/src/main/java/org/embulk/spi/util/LineEncoder.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/util/PagePrinter.java +6 -6
- data/embulk-core/src/main/java/org/embulk/spi/util/Pages.java +6 -6
- data/embulk-core/src/test/java/org/embulk/GuiceBinder.java +1 -1
- data/embulk-core/src/test/java/org/embulk/plugin/MockPluginSource.java +1 -0
- data/embulk-core/src/test/java/org/embulk/spi/MockFormatterPlugin.java +2 -2
- data/embulk-core/src/test/java/org/embulk/spi/PageTestUtils.java +1 -1
- data/embulk-core/src/test/java/org/embulk/spi/TestFileInputRunner.java +3 -3
- data/embulk-core/src/test/java/org/embulk/spi/TestFileOutputRunner.java +4 -4
- data/embulk-docs/Makefile +178 -0
- data/embulk-docs/build.gradle +20 -0
- data/embulk-docs/make.bat +243 -0
- data/embulk-docs/push-gh-pages.sh +29 -0
- data/embulk-docs/src/conf.py +260 -0
- data/embulk-docs/src/index.rst +19 -0
- data/embulk-docs/src/release.rst +14 -0
- data/embulk-docs/src/release/release-0.1.0.rst +8 -0
- data/embulk-docs/src/release/release-0.2.0.rst +16 -0
- data/embulk-docs/src/release/release-0.2.1.rst +19 -0
- data/embulk-docs/src/release/release-0.3.0.rst +34 -0
- data/embulk-docs/src/release/release-0.3.1.rst +11 -0
- data/embulk-docs/src/release/release-0.3.2.rst +15 -0
- data/embulk-docs/src/release/release-0.4.0.rst +74 -0
- data/embulk-standards/build.gradle +0 -1
- data/embulk-standards/src/main/java/org/embulk/standards/CsvFormatterPlugin.java +2 -2
- data/embulk-standards/src/main/java/org/embulk/standards/CsvParserPlugin.java +12 -3
- data/embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java +2 -2
- data/embulk-standards/src/main/java/org/embulk/standards/LocalFileInputPlugin.java +49 -26
- data/embulk-standards/src/main/java/org/embulk/standards/LocalFileOutputPlugin.java +16 -17
- data/embulk-standards/src/main/java/org/embulk/standards/NullOutputPlugin.java +4 -4
- data/embulk-standards/src/main/java/org/embulk/standards/StandardPluginModule.java +0 -1
- data/embulk-standards/src/main/java/org/embulk/standards/StdoutOutputPlugin.java +5 -5
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +2 -2
- data/lib/embulk/buffer.rb +2 -2
- data/lib/embulk/column.rb +6 -6
- data/lib/embulk/command/embulk_example.rb +1 -1
- data/lib/embulk/command/embulk_new_plugin.rb +87 -0
- data/lib/embulk/command/embulk_run.rb +84 -26
- data/lib/embulk/data/bundle/Gemfile +12 -20
- data/lib/embulk/data/bundle/embulk/{filter_example.rb → filter/example.rb} +3 -3
- data/lib/embulk/data/bundle/embulk/{input_example.rb → input/example.rb} +3 -3
- data/lib/embulk/data/bundle/embulk/{output_example.rb → output/example.rb} +3 -3
- data/lib/embulk/data/new/LICENSE.txt +21 -0
- data/lib/embulk/data/new/README.md.erb +75 -0
- data/lib/embulk/data/new/gitignore.erb +12 -0
- data/lib/embulk/data/new/java/build.gradle.erb +57 -0
- data/lib/embulk/data/new/java/decoder.java.erb +40 -0
- data/lib/embulk/data/new/java/encoder.java.erb +40 -0
- data/lib/embulk/data/new/java/file_input.java.erb +64 -0
- data/lib/embulk/data/new/java/file_output.java.erb +66 -0
- data/lib/embulk/data/new/java/filter.java.erb +47 -0
- data/lib/embulk/data/new/java/formatter.java.erb +45 -0
- data/lib/embulk/data/new/java/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/embulk/data/new/java/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/embulk/data/new/java/gradlew +164 -0
- data/lib/embulk/data/new/java/gradlew.bat +90 -0
- data/lib/embulk/data/new/java/input.java.erb +69 -0
- data/lib/embulk/data/new/java/output.java.erb +65 -0
- data/lib/embulk/data/new/java/parser.java.erb +51 -0
- data/lib/embulk/data/new/java/plugin_loader.rb.erb +3 -0
- data/lib/embulk/data/new/java/test.java.erb +5 -0
- data/lib/embulk/data/new/ruby/Gemfile +2 -0
- data/lib/embulk/data/new/ruby/Rakefile +1 -0
- data/lib/embulk/data/new/ruby/filter.rb.erb +39 -0
- data/lib/embulk/data/new/ruby/gemspec.erb +19 -0
- data/lib/embulk/data/new/ruby/input.rb.erb +47 -0
- data/lib/embulk/data/new/ruby/output.rb.erb +59 -0
- data/lib/embulk/data/package_data.rb +64 -0
- data/lib/embulk/data_source.rb +2 -2
- data/lib/embulk/decoder_plugin.rb +27 -0
- data/lib/embulk/encoder_plugin.rb +27 -0
- data/lib/embulk/error.rb +3 -0
- data/lib/embulk/file_input_plugin.rb +27 -0
- data/lib/embulk/file_output_plugin.rb +27 -0
- data/lib/embulk/filter_plugin.rb +28 -9
- data/lib/embulk/formatter_plugin.rb +105 -0
- data/lib/embulk/guess_csv.rb +10 -1
- data/lib/embulk/guess_plugin.rb +22 -27
- data/lib/embulk/input_plugin.rb +34 -20
- data/lib/embulk/java/bootstrap.rb +5 -0
- data/lib/embulk/java/imports.rb +7 -0
- data/lib/embulk/java_plugin.rb +84 -0
- data/lib/embulk/output_plugin.rb +35 -19
- data/lib/embulk/page.rb +1 -1
- data/lib/embulk/page_builder.rb +1 -1
- data/lib/embulk/parser_plugin.rb +76 -0
- data/lib/embulk/plugin.rb +130 -65
- data/lib/embulk/plugin_registry.rb +19 -8
- data/lib/embulk/schema.rb +4 -4
- data/lib/embulk/version.rb +1 -1
- data/settings.gradle +1 -0
- metadata +123 -90
- data/ChangeLog +0 -46
- data/embulk-cli/pom.xml +0 -94
- data/embulk-core/pom.xml +0 -148
- data/embulk-core/src/main/java/org/embulk/config/NextConfig.java +0 -26
- data/embulk-standards/pom.xml +0 -68
- data/embulk-standards/src/main/java/org/embulk/standards/S3FileInputPlugin.java +0 -250
- data/embulk-standards/src/test/java/org/embulk/standards/TestS3FileInputPlugin.java +0 -43
- 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 @@
|
|
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
|