Class: Embulk::OutputVim
- Inherits:
-
OutputPlugin
- Object
- OutputPlugin
- Embulk::OutputVim
- Defined in:
- lib/embulk/output_vim.rb
Class Method Summary collapse
Instance Method Summary collapse
- #abort ⇒ Object
- #add(page) ⇒ Object
- #close ⇒ Object
- #commit ⇒ Object
- #finish ⇒ Object
-
#initialize(task, schema, index) ⇒ OutputVim
constructor
A new instance of OutputVim.
Constructor Details
#initialize(task, schema, index) ⇒ OutputVim
Returns a new instance of OutputVim.
10 11 12 13 14 15 16 17 18 |
# File 'lib/embulk/output_vim.rb', line 10 def initialize(task, schema, index) @vim = `vim --serverlist`.lines.first raise "embulk-plugin-vim require gvim!" unless @vim @vim.chomp! system('vim', '--servername', @vim, '--remote-send', ":silent sp embulk.csv<cr>:%d<cr>") system('vim', '--servername', @vim, '--remote-expr', "append('$', '#{schema.map{|x| x.name}.join(",").gsub(/(['\\])/, '\\\1')}') ? '' : 'OK'") super @records = 0 end |
Class Method Details
.transaction(config, schema, processor_count, &control) ⇒ Object
5 6 7 8 |
# File 'lib/embulk/output_vim.rb', line 5 def self.transaction(config, schema, processor_count, &control) commit_reports = yield({}) return {} end |
Instance Method Details
#abort ⇒ Object
33 34 |
# File 'lib/embulk/output_vim.rb', line 33 def abort end |
#add(page) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/embulk/output_vim.rb', line 23 def add(page) page.each do |record| system('vim', '--servername', @vim, '--remote-expr', "append('$', '#{record.join(",").gsub(/(['\\])/, '\\\1')}') ? '' : 'OK'") @records += 1 end end |
#close ⇒ Object
20 21 |
# File 'lib/embulk/output_vim.rb', line 20 def close end |
#commit ⇒ Object
36 37 38 39 |
# File 'lib/embulk/output_vim.rb', line 36 def commit system('vim', '--servername', @vim, '--remote-send', "ggdd<c-l>") return { "records" => @records } end |
#finish ⇒ Object
30 31 |
# File 'lib/embulk/output_vim.rb', line 30 def finish end |