embulk 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -23,7 +23,7 @@ EOF
23
23
  f.write <<EOF
24
24
  in:
25
25
  type: file
26
- paths: ["#{File.expand_path File.join(path, 'csv')}"]
26
+ path_prefix: "#{File.expand_path File.join(path, 'csv', 'sample_')}"
27
27
  out:
28
28
  type: stdout
29
29
  EOF
@@ -0,0 +1,87 @@
1
+ module Embulk
2
+ def self.new_plugin(name, language, category)
3
+ require 'embulk/data/package_data'
4
+ require 'embulk/version'
5
+ require 'fileutils'
6
+
7
+ embulk_category = category
8
+ embulk_category = :input if category == :file_input
9
+ embulk_category = :output if category == :file_output
10
+
11
+ project_name = "embulk-#{embulk_category}-#{name}"
12
+ plugin_path = "lib/embulk/#{embulk_category}/#{name}.rb"
13
+
14
+ if File.exist?(project_name)
15
+ raise "./#{project_name} already exists. Please delete it first."
16
+ end
17
+ FileUtils.mkdir_p(project_name)
18
+
19
+ puts "Creating #{project_name}/"
20
+
21
+ success = false
22
+ begin
23
+ author = `git config user.name`.strip
24
+ author = "YOUR_NAME" if author.empty?
25
+ email = `git config user.email`.strip
26
+ email = "YOUR_NAME" if email.empty?
27
+
28
+ ruby_class_name = name.split('-').map {|a| a.capitalize }.join + category.to_s.split('_').map {|a| a.capitalize }.join + "Plugin"
29
+ java_iface = category.to_s.split('_').map {|a| a.capitalize }.join
30
+ java_class_name = name.split('-').map {|a| a.capitalize }.join + java_iface + "Plugin"
31
+ display_name = name.split('-').map {|a| a.capitalize }.join(' ')
32
+ display_category = category.to_s.gsub('_', ' ')
33
+
34
+ description =
35
+ case category
36
+ when :input
37
+ %[that loads records from #{display_name} so that any output plugins can receive the records. Search the output plugins by "embulk-output" keyword.]
38
+ when :file_input
39
+ %[that reads files from #{display_name} and parses the file using any parser plugins. Search the parser plugins by "embulk-parser" keyword.]
40
+ when :parser
41
+ %[that parses #{display_name} file format read by any file input plugins. Search the file input plugins by "embulk-input file" keywords.]
42
+ when :decoder
43
+ %[that decodes files encoded by #{display_name} read by any file input plugins. Search the file input plugins by "embulk-input file" keywords.]
44
+ when :output
45
+ %[that loads records to #{display_name} read by any input plugins. Search the input plugins by "embulk-input" keyword.]
46
+ when :file_output
47
+ %[that stores files to #{display_name} formatted by any formatter plugins. Search the formatter plugins by "embulk-formatter" keyword.]
48
+ when :formtter
49
+ %[that formats records using #{display_name} file format and so that any file output plugins can store the files. Search the file output plugins by "embulk-output file" keywords.]
50
+ when :encoder
51
+ %[that encodes files using #{display_name} so that any file output plugins can store the files. Search the file output plugins by "embulk-output file" keywords.]
52
+ when :filter
53
+ %[that converts records read by an input plugin before passing it to an output plugins. Search the input and plugins by "embulk-input" and "embulk-output" plugins.]
54
+ end
55
+
56
+ pkg = Embulk::PackageData.new("new", project_name, binding())
57
+
58
+ pkg.cp_erb("README.md.erb", "README.md")
59
+ pkg.cp("LICENSE.txt", "LICENSE.txt")
60
+ pkg.cp_erb("gitignore.erb", ".gitignore")
61
+
62
+ case language
63
+ when :ruby
64
+ pkg.cp("ruby/Rakefile", "Rakefile")
65
+ pkg.cp("ruby/Gemfile", "Gemfile")
66
+ pkg.cp_erb("ruby/gemspec.erb", "#{project_name}.gemspec")
67
+ pkg.cp_erb("ruby/#{category}.rb.erb", plugin_path)
68
+
69
+ when :java
70
+ pkg.cp("java/gradle/wrapper/gradle-wrapper.jar", "gradle/wrapper/gradle-wrapper.jar")
71
+ pkg.cp("java/gradle/wrapper/gradle-wrapper.properties", "gradle/wrapper/gradle-wrapper.properties")
72
+ pkg.cp("java/gradlew.bat", "gradlew.bat")
73
+ pkg.cp("java/gradlew", "gradlew")
74
+ pkg.set_executable("gradlew")
75
+ pkg.cp_erb("java/build.gradle.erb", "build.gradle")
76
+ pkg.cp_erb("java/plugin_loader.rb.erb", plugin_path)
77
+ pkg.cp_erb("java/#{category}.java.erb", "src/main/java/org/embulk/#{embulk_category}/#{java_class_name}.java")
78
+ pkg.cp_erb("java/test.java.erb", "src/test/java/org/embulk/#{embulk_category}/Test#{java_class_name}.java")
79
+ end
80
+
81
+ success = true
82
+ puts ""
83
+ ensure
84
+ FileUtils.rm_rf project_name unless success
85
+ end
86
+ end
87
+ end
@@ -14,13 +14,19 @@ module Embulk
14
14
  Gem.clear_paths # force rubygems to reload GEM_HOME
15
15
  end
16
16
 
17
+ # to make sure org.embulk.jruby.JRubyScriptingModule can require 'embulk/java/bootstrap'
18
+ $LOAD_PATH << Embulk.home('lib')
19
+
20
+ if argv.include?('--version')
21
+ require 'embulk/version'
22
+ puts "embulk #{Embulk::VERSION}"
23
+ exit 1
24
+ end
25
+
17
26
  i = argv.find_index {|arg| arg !~ /^\-/ }
18
27
  usage nil unless i
19
28
  subcmd = argv.slice!(i)
20
29
 
21
- # to make sure org.embulk.jruby.JRubyScriptingModule can require 'embulk/java/bootstrap'
22
- $LOAD_PATH << Embulk.home('lib')
23
-
24
30
  require 'java'
25
31
  require 'optparse'
26
32
  op = OptionParser.new
@@ -36,6 +42,7 @@ module Embulk
36
42
 
37
43
  case subcmd.to_sym
38
44
  when :bundle
45
+ op.remove # remove --bundle
39
46
  if default_bundle_path
40
47
  op.banner = "Usage: bundle [directory=#{default_bundle_path}]"
41
48
  args = 0..1
@@ -46,8 +53,6 @@ module Embulk
46
53
 
47
54
  when :run
48
55
  op.banner = "Usage: run <config.yml>"
49
- op.on('-b', '--bundle BUNDLE_DIR', 'Path to a Gemfile directory') do |path|
50
- end
51
56
  op.on('-I', '--load-path PATH', 'Add ruby script directory path ($LOAD_PATH)') do |load_path|
52
57
  load_paths << load_path
53
58
  end
@@ -64,8 +69,6 @@ module Embulk
64
69
 
65
70
  when :cleanup
66
71
  op.banner = "Usage: run <config.yml>"
67
- op.on('-b', '--bundle BUNDLE_DIR', 'Path to a Gemfile directory') do |path|
68
- end
69
72
  op.on('-I', '--load-path PATH', 'Add ruby script directory path ($LOAD_PATH)') do |load_path|
70
73
  load_paths << load_path
71
74
  end
@@ -79,8 +82,6 @@ module Embulk
79
82
 
80
83
  when :preview
81
84
  op.banner = "Usage: preview <config.yml>"
82
- op.on('-b', '--bundle BUNDLE_DIR', 'Path to a Gemfile directory') do |path|
83
- end
84
85
  op.on('-I', '--load-path PATH', 'Add ruby script directory path ($LOAD_PATH)') do |load_path|
85
86
  load_paths << load_path
86
87
  end
@@ -102,8 +103,34 @@ module Embulk
102
103
  end
103
104
  args = 1..1
104
105
 
105
- #when :generate # or :new
106
- # TODO create plugin templates
106
+ when :new
107
+ op.remove # remove --bundle
108
+ op.banner = "Usage: new <category> <name>" + %[
109
+ categories:
110
+ ruby-input Ruby record input plugin (like "mysql")
111
+ ruby-output Ruby record output plugin (like "mysql")
112
+ ruby-filter Ruby record filter plugin (like "add-hostname")
113
+ #ruby-file-input Ruby file input plugin (like "ftp") # not implemented yet [#21]
114
+ #ruby-file-output Ruby file output plugin (like "ftp") # not implemented yet [#22]
115
+ #ruby-parser Ruby file parser plugin (like "csv") # not implemented yet [#33]
116
+ #ruby-formatter Ruby file formatter plugin (like "csv") # not implemented yet [#34]
117
+ #ruby-decoder Ruby file decoder plugin (like "gzip") # not implemented yet [#31]
118
+ #ruby-encoder Ruby file encoder plugin (like "gzip") # not implemented yet [#32]
119
+ java-input Java record input plugin (like "mysql")
120
+ java-output Java record output plugin (like "mysql")
121
+ java-filter Java record filter plugin (like "add-hostname")
122
+ java-file-input Java file input plugin (like "ftp")
123
+ java-file-output Java file output plugin (like "ftp")
124
+ java-parser Java file parser plugin (like "csv")
125
+ java-formatter Java file formatter plugin (like "csv")
126
+ java-decoder Java file decoder plugin (like "gzip")
127
+ java-encoder Java file encoder plugin (like "gzip")
128
+
129
+ examples:
130
+ new ruby-output hbase
131
+ new ruby-filter int-to-string
132
+ ]
133
+ args = 2..2
107
134
 
108
135
  when :gem
109
136
  require 'rubygems/gem_runner'
@@ -124,10 +151,10 @@ module Embulk
124
151
  begin
125
152
  op.parse!(argv)
126
153
  unless args.include?(argv.length)
127
- usage nil
154
+ usage_op op, nil
128
155
  end
129
156
  rescue => e
130
- usage e.to_s
157
+ usage_op op, e.to_s
131
158
  end
132
159
 
133
160
  case subcmd.to_sym
@@ -146,19 +173,10 @@ module Embulk
146
173
  success = false
147
174
 
148
175
  # copy embulk/data/bundle/ directory
149
- if __FILE__ =~ /^classpath:/ || __FILE__.include?('!/')
150
- # data is in embulk-core jar
151
- resource_class = org.embulk.command.Runner.java_class
152
- %w[.bundle/config embulk/input_example.rb embulk/filter_example.rb embulk/output_example.rb Gemfile Gemfile.lock].each do |file| # TODO get file list from the jar
153
- url = resource_class.resource("/embulk/data/bundle/#{file}").to_s
154
- dst = File.join(path, file)
155
- FileUtils.mkdir_p File.dirname(dst)
156
- FileUtils.cp(url, dst)
157
- end
158
- else
159
- #tmpl = File.join(File.dirname(__FILE__), '../data/bundle')
160
- tmpl = File.join(Embulk.home('lib'), 'embulk', 'data', 'bundle')
161
- FileUtils.cp_r tmpl, path
176
+ require 'embulk/data/package_data'
177
+ pkg = PackageData.new("bundle", path)
178
+ %w[.bundle/config embulk/input/example.rb embulk/output/example.rb embulk/filter/example.rb Gemfile].each do |file|
179
+ pkg.cp(file, file)
162
180
  end
163
181
 
164
182
  ## TODO this is disabled for now. enable this if you want to use
@@ -207,6 +225,36 @@ module Embulk
207
225
  puts " 3. run config.yml"
208
226
  puts ""
209
227
 
228
+ when :new
229
+ lang_cate = ARGV[0]
230
+ name = ARGV[1]
231
+
232
+ language, category = case lang_cate
233
+ when "java-input" then [:java, :input]
234
+ when "java-output" then [:java, :output]
235
+ when "java-filter" then [:java, :filter]
236
+ when "java-file-input" then [:java, :file_input]
237
+ when "java-file-output" then [:java, :file_output]
238
+ when "java-parser" then [:java, :parser]
239
+ when "java-formatter" then [:java, :formatter]
240
+ when "java-decoder" then [:java, :decoder]
241
+ when "java-encoder" then [:java, :encoder]
242
+ when "ruby-input" then [:ruby, :input]
243
+ when "ruby-output" then [:ruby, :output]
244
+ when "ruby-filter" then [:ruby, :filter]
245
+ when "ruby-file-input" then raise "ruby-file-input is not implemented yet. See #21 on github." #[:ruby, :file_input]
246
+ when "ruby-file-output" then raise "ruby-file-output is not implemented yet. See #22 on github." #[:ruby, :file_output]
247
+ when "ruby-parser" then raise "ruby-parser is not implemented yet. See #33 on github." #[:ruby, :parser]
248
+ when "ruby-formatter" then raise "ruby-formatter is not implemented yet. See #34 on github." #[:ruby, :formatter]
249
+ when "ruby-decoder" then raise "ruby-decoder is not implemented yet. See #31 on github." #[:ruby, :decoder]
250
+ when "ruby-encoder" then raise "ruby-decoder is not implemented yet. See #32 on github." #[:ruby, :encoder]
251
+ else
252
+ usage_op op, "Unknown category '#{lang_cate}'"
253
+ end
254
+
255
+ require 'embulk/command/embulk_new_plugin'
256
+ Embulk.new_plugin(name, language, category)
257
+
210
258
  else
211
259
  require 'json'
212
260
 
@@ -265,6 +313,7 @@ module Embulk
265
313
  STDERR.puts " guess <partial-config.yml> -o <output.yml> # guess missing parameters to create a complete configuration file."
266
314
  STDERR.puts " gem <install | list | help> # install a plugin or show installed plugins."
267
315
  STDERR.puts " # plugin path is #{ENV['GEM_HOME']}"
316
+ STDERR.puts " new <category> <name> # generates new plugin template"
268
317
  STDERR.puts " example [path] # creates an example config file and csv file to try embulk."
269
318
  STDERR.puts ""
270
319
  if message
@@ -274,4 +323,13 @@ module Embulk
274
323
  end
275
324
  exit 1
276
325
  end
326
+
327
+ def self.usage_op(op, message)
328
+ STDERR.puts op.help
329
+ STDERR.puts
330
+ if message
331
+ STDERR.puts message
332
+ end
333
+ exit 1
334
+ end
277
335
  end
@@ -1,31 +1,23 @@
1
1
  source 'https://rubygems.org/'
2
-
3
- # Plugin bundle:
4
2
  #
5
- # a) Using plugins released on RubyGems:
6
- # You can write plugin names (and versions) to this file to include
7
- # the plugins released on RubyGems. To use those plugins,
3
+ # Note: After updating this file, run this command to update Gemfile.lock:
8
4
  #
9
- # 1. modify this Gemfile. Examples are at the end of this file.
10
- # 2. update Gemfile.lock using: embulk bundle <this dir>
11
- # 3. run embulk with -b option: embulk run -b <this dir> example.yml
5
+ # embulk bundle <this_dir>
12
6
  #
13
- # b) Using simple single-file ruby plugins:
14
- # You can put a simple ruby plugins to <this dir>/embulk directory.
15
- # When you run embulk with -b <this dir> option, embulk loads them:
7
+
16
8
  #
17
- # $ embulk run -b <this dir> example.yml
9
+ # RubyGems Plugins
18
10
  #
19
- # See <this dir>/embulk/* files for example. When the plugin works,
20
- # you can release the plugin to RubyGems with "embulk-plugin-foobar"
21
- # name to deploy them to servers.
11
+ #gem 'embulk-output-mysql'
12
+ #gem 'embulk-output-postgresql', '>= 0.1.0'
13
+ #gem 'embulk-input-baz', '= 0.2.0'
14
+ #gem 'embulk-input-xyz', '~> 0.3.0'
22
15
  #
23
16
 
24
- # Plugins
25
17
  #
26
- #gem 'embulk-plugin-foo'
27
- #gem 'embulk-plugin-bar', '~> 0.1.0'
28
- #gem 'embulk-plugin-baz', '= 0.2.0'
29
- #gem 'embulk-plugin-xyz', '>= 0.3.0'
18
+ # Private plugins
19
+ #
20
+ #gem 'embulk-inupt-awesome', path: '/path/to/your/embulk-input-awesome'
21
+ #gem 'embulk-output-awesome', git: 'https://github.com/you/embulk-output-awesome.git', branch: 'master'
30
22
  #
31
23
 
@@ -1,8 +1,8 @@
1
1
  module Embulk
2
- module Plugin
2
+ module Filter
3
3
 
4
- class FilterExample < FilterPlugin
5
- # filter plugin file name must be: embulk/filter_<name>.rb
4
+ class ExampleFilterPlugin < FilterPlugin
5
+ # filter plugin file name must be: embulk/filter/<name>.rb
6
6
  Plugin.register_filter('example', self)
7
7
 
8
8
  def self.transaction(config, in_schema, &control)
@@ -1,8 +1,8 @@
1
1
  module Embulk
2
- module Plugin
2
+ module Input
3
3
 
4
- class InputExample < InputPlugin
5
- # input plugin file name must be: embulk/input_<name>.rb
4
+ class ExampleInputPlugin < InputPlugin
5
+ # input plugin file name must be: embulk/input/<name>.rb
6
6
  Plugin.register_input('example', self)
7
7
 
8
8
  def self.transaction(config, &control)
@@ -1,8 +1,8 @@
1
1
  module Embulk
2
- module Plugin
2
+ module Output
3
3
 
4
- class OutputExample < OutputPlugin
5
- # output plugin file name must be: embulk/output_<name>.rb
4
+ class ExampleOutputPlugin < OutputPlugin
5
+ # output plugin file name must be: embulk/output/<name>.rb
6
6
  Plugin.register_output('example', self)
7
7
 
8
8
  def self.transaction(config, schema, count, &control)
@@ -0,0 +1,21 @@
1
+
2
+ MIT License
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,75 @@
1
+ # <%= display_name %> <%= display_category %> plugin for Embulk
2
+
3
+ TODO: Write short description here
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: <%= embulk_category %>
8
+ * **Load all or nothing**: yes
9
+ * **Resume supported**: no
10
+
11
+ ## Configuration
12
+
13
+ - **property1**: description (string, required)
14
+ - **property2**: description (integer, default: default-value)
15
+
16
+ ## Example
17
+
18
+ ```yaml
19
+ %case category
20
+ %when :input, :file_input
21
+ in:
22
+ type: <%= name %>
23
+ property1: example1
24
+ property2: example2
25
+ %when :output, :file_output
26
+ out:
27
+ type: <%= name %>
28
+ property1: example1
29
+ property2: example2
30
+ %when :filter
31
+ filters:
32
+ - type: <%= name %>
33
+ property1: example1
34
+ property2: example2
35
+ %when :parser
36
+ in:
37
+ type: any file input plugin type
38
+ parser:
39
+ type: <%= name %>
40
+ property1: example1
41
+ property2: example2
42
+ %when :formatter
43
+ out:
44
+ type: any output input plugin type
45
+ formatter:
46
+ type: <%= name %>
47
+ property1: example1
48
+ property2: example2
49
+ %when :decoder
50
+ in:
51
+ type: any output input plugin type
52
+ decoders:
53
+ - type: <%= name %>
54
+ property1: example1
55
+ property2: example2
56
+ %when :encoder
57
+ out:
58
+ type: any output input plugin type
59
+ encoders:
60
+ - type: <%= name %>
61
+ property1: example1
62
+ property2: example2
63
+ %end
64
+ ```
65
+
66
+ ## Build
67
+
68
+ ```
69
+ %case language
70
+ %when :ruby
71
+ $ rake
72
+ %when :java
73
+ $ ./gradlew gem
74
+ % end
75
+ ```