Created
February 26, 2015 21:37
-
-
Save frsyuki/2b7cb2331e3525af92a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id "com.jfrog.bintray" version "1.1" | |
id "com.github.jruby-gradle.base" version "0.1.5" | |
id "java" | |
} | |
import com.github.jrubygradle.JRubyExec | |
repositories { | |
mavenCentral() | |
jcenter() | |
} | |
configurations { | |
provided | |
} | |
version = "0.1.0" | |
dependencies { | |
compile "org.embulk:embulk-core:0.4.9" | |
provided "org.embulk:embulk-core:0.4.9" | |
compile("com.google.apis:google-api-services-storage:v1-rev27-1.19.1") { exclude module: 'guava-jdk5' } | |
testCompile "junit:junit:4.+" | |
} | |
task classpath(type: Copy, dependsOn: ["jar"]) { | |
doFirst { file("classpath").deleteDir() } | |
from (configurations.runtime - configurations.provided + files(jar.archivePath)) | |
into "classpath" | |
} | |
clean { delete 'classpath' } | |
task gem(type: JRubyExec, dependsOn: ["build", "gemspec", "classpath"]) { | |
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build" | |
script "build/gemspec" | |
doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") } | |
} | |
task gemspec << { file("build/gemspec").write($/ | |
Gem::Specification.new do |spec| | |
spec.name = "${project.name}" | |
spec.version = "${project.version}" | |
spec.authors = ["Sadayuki Furuhashi"] | |
spec.summary = %[Gapi input plugin for Embulk] | |
spec.description = %["Loads records from Gapi."] | |
spec.email = ["frsyuki@gmail.com"] | |
spec.licenses = ["MIT"] | |
# TODO: spec.homepage = "https://github.com/frsyuki/embulk-input-gapi" | |
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"] | |
spec.test_files = spec.files.grep(%r"^(test|spec)/") | |
spec.require_paths = ["lib"] | |
#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION'] | |
spec.add_development_dependency 'bundler', ['~> 1.0'] | |
spec.add_development_dependency 'rake', ['>= 10.0'] | |
end | |
/$) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.embulk.input; | |
import java.util.List; | |
import java.util.ArrayList; | |
import com.google.common.base.Optional; | |
import org.embulk.config.CommitReport; | |
import org.embulk.config.Config; | |
import org.embulk.config.ConfigDefault; | |
import org.embulk.config.ConfigDiff; | |
import org.embulk.config.ConfigSource; | |
import org.embulk.config.Task; | |
import org.embulk.config.TaskSource; | |
import org.embulk.spi.Exec; | |
import org.embulk.spi.InputPlugin; | |
import org.embulk.spi.PageOutput; | |
import org.embulk.spi.Schema; | |
import org.embulk.spi.Column; | |
import org.embulk.spi.SchemaConfig; | |
public class GapiInputPlugin | |
implements InputPlugin | |
{ | |
public interface PluginTask | |
extends Task | |
{ | |
@Config("last_path") | |
@ConfigDefault("null") | |
public Optional<String> getLastPath(); | |
} | |
public ConfigDiff transaction(ConfigSource config, | |
InputPlugin.Control control) | |
{ | |
PluginTask task = config.loadConfig(PluginTask.class); | |
Schema schema = new Schema(new ArrayList<Column>()); | |
int taskCount = 1; // number of run() method calls | |
return resume(task.dump(), schema, taskCount, control); | |
} | |
public ConfigDiff resume(TaskSource taskSource, | |
Schema schema, int taskCount, | |
InputPlugin.Control control) | |
{ | |
control.run(taskSource, schema, taskCount); | |
return Exec.newConfigDiff(); | |
} | |
public void cleanup(TaskSource taskSource, | |
Schema schema, int taskCount, | |
List<CommitReport> successCommitReports) | |
{ | |
} | |
public CommitReport run(TaskSource taskSource, | |
Schema schema, int taskIndex, | |
PageOutput output) | |
{ | |
PluginTask task = taskSource.loadTask(PluginTask.class); | |
// TODO | |
throw new UnsupportedOperationException("The 'run' method needs to be implemented"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment