Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
How to develop embulk parser plugin

Bundleディレクトリ作成

% embulk bundle hoge 
2015-03-16 09:09:39.698 +0900: Embulk v0.5.2
Initializing hoge...
  Creating hoge/.bundle/config
  Creating hoge/embulk/input/example.rb
  Creating hoge/embulk/output/example.rb
  Creating hoge/embulk/filter/example.rb
  Creating hoge/Gemfile
Fetching: bundler-1.8.5.gem (100%)
Successfully installed bundler-1.8.5
1 gem installed
The Gemfile specifies no dependencies
Resolving dependencies...
Bundle complete! 0 Gemfile dependencies, 1 gem now installed.
Bundled gems are installed into ..

gemの導入

% embulk -b hoge gem install roo 
2015-03-16 09:10:50.406 +0900: Embulk v0.5.2
Fetching: ruby-ole-1.2.11.8.gem (100%)
Successfully installed ruby-ole-1.2.11.8
Fetching: spreadsheet-1.0.3.gem (100%)
Successfully installed spreadsheet-1.0.3
Fetching: nokogiri-1.6.6.2-java.gem (100%)
Successfully installed nokogiri-1.6.6.2-java
Fetching: rubyzip-1.1.7.gem (100%)
Successfully installed rubyzip-1.1.7
Fetching: roo-1.13.2.gem (100%)
Successfully installed roo-1.13.2
5 gems installed

parserひな形の作成

% embulk new ruby-parser roo-excel
Creating embulk-parser-roo-excel/
  Creating embulk-parser-roo-excel/README.md
  Creating embulk-parser-roo-excel/LICENSE.txt
  Creating embulk-parser-roo-excel/.gitignore
  Creating embulk-parser-roo-excel/Rakefile
  Creating embulk-parser-roo-excel/Gemfile
  Creating embulk-parser-roo-excel/embulk-parser-roo-excel.gemspec
  Creating embulk-parser-roo-excel/lib/embulk/parser/roo-excel.rb
  Creating embulk-parser-roo-excel/lib/embulk/guess/roo-excel.rb

Gemファイルの追加

cat hoge/Gemfile
...
gem 'roo'

テスト

% embulk preview -b hoge -I /path/to/embulk-input-roo-excel/lib /path/to/test/guess2.yml
2015-03-16 09:13:39.223 +0900: Embulk v0.5.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment