embulk-plugin-vim 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aeef6adb44b0fbabe570fb7552206ba4579ee3c3
4
+ data.tar.gz: 27a7aea009e2c6b7f4f659303767db73925f17d6
5
+ SHA512:
6
+ metadata.gz: d24b2c545826e3af841aa8fbd1c0259cbd9599b9f17b88a89371e34d6fd084ba5fb553ffedb903c544d1f159bee0f22b0be09a62e3df7463424a7c244e417518
7
+ data.tar.gz: 7c0b7bd1500e71963f089405b4730d5f5dbd6b20c9c6a2586f1c842091e6c1471f8ebd61889550ff9debb8394557169814d663961e98ef6454407cc0a94ecb53
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
@@ -0,0 +1,11 @@
1
+ # Embulk output plugin for vim
2
+
3
+ This [Embulk](https://github.com/embulk/embulk) output plugin writes records to lines on Vim!
4
+
5
+ ![](http://go-gyazo.appspot.com/c632b79364facb51.png)
6
+
7
+ This plugin runs without transaction for now.
8
+
9
+ ## Configuration
10
+
11
+ Nothing!
@@ -0,0 +1,4 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ task :default => [:build]
@@ -0,0 +1,20 @@
1
+
2
+ Gem::Specification.new do |gem|
3
+ gem.name = "embulk-plugin-vim"
4
+ gem.version = "0.0.2"
5
+
6
+ gem.summary = %q{Embulk plugin for Vim}
7
+ gem.description = gem.summary
8
+ gem.authors = ["Yasuhiro Matsumoto"]
9
+ gem.email = ["mattn.jp@gmail.com"]
10
+ gem.license = "MIT"
11
+ gem.homepage = "https://github.com/mattn/embulk-plugin-vim"
12
+
13
+ gem.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.require_paths = ["lib"]
16
+ gem.has_rdoc = false
17
+
18
+ gem.add_development_dependency 'bundler', ['~> 1.0']
19
+ #gem.add_development_dependency 'rake', ['>= 0.9.2']
20
+ end
@@ -0,0 +1,41 @@
1
+ module Embulk
2
+ class OutputVim < OutputPlugin
3
+ Plugin.register_output('vim', self)
4
+
5
+ def self.transaction(config, schema, processor_count, &control)
6
+ commit_reports = yield({})
7
+ return {}
8
+ end
9
+
10
+ def initialize(task, schema, index)
11
+ @vim = `vim --serverlist`.lines.first
12
+ raise "embulk-plugin-vim require gvim!" unless @vim
13
+ @vim.chomp!
14
+ system('vim', '--servername', @vim, '--remote-send', ":silent sp embulk.csv<cr>:%d<cr>")
15
+ system('vim', '--servername', @vim, '--remote-expr', "append('$', '#{schema.map{|x| x.name}.join(",").gsub(/(['\\])/, '\\\1')}') ? '' : 'OK'")
16
+ super
17
+ @records = 0
18
+ end
19
+
20
+ def close
21
+ end
22
+
23
+ def add(page)
24
+ page.each do |record|
25
+ system('vim', '--servername', @vim, '--remote-expr', "append('$', '#{record.join(",").gsub(/(['\\])/, '\\\1')}') ? '' : 'OK'")
26
+ @records += 1
27
+ end
28
+ end
29
+
30
+ def finish
31
+ end
32
+
33
+ def abort
34
+ end
35
+
36
+ def commit
37
+ system('vim', '--servername', @vim, '--remote-send', "ggdd<c-l>")
38
+ return { "records" => @records }
39
+ end
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-plugin-vim
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Yasuhiro Matsumoto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: Embulk plugin for Vim
28
+ email:
29
+ - mattn.jp@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - Gemfile
35
+ - README.md
36
+ - Rakefile
37
+ - embulk-plugin-vim.gemspec
38
+ - lib/embulk/output_vim.rb
39
+ homepage: https://github.com/mattn/embulk-plugin-vim
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.2.2
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Embulk plugin for Vim
63
+ test_files: []
64
+ has_rdoc: false