embulk-output-mongodb 0.1.0

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: e811f6f756e5af252bc1b71ce3ea3f5b0286e2f8
4
+ data.tar.gz: 96b3cea553cf29b979714648aa59263786e92608
5
+ SHA512:
6
+ metadata.gz: e4aa5de302c11d6fd25ad67faecfeb7c1e0f3f18fe0e58dac38c79e80ebdd968177f8a62d55c64380deb269634773a718a45ff3ba9232fbcef83e5a382e49ffe
7
+ data.tar.gz: 7c2c8e4137c8d0321eac626d936fb72e522b8bbbe1848c48a03378cba72df5d0477e4b360f64d512f58e03ee8b20cbb1be0010dd747c579dbac071d2fa22b650
@@ -0,0 +1,8 @@
1
+ *~
2
+ /pkg/
3
+ /tmp/
4
+ /.bundle/
5
+ /Gemfile.lock
6
+
7
+ .gem
8
+ .idea
@@ -0,0 +1 @@
1
+ jruby-9.1.5.0
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec
@@ -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,31 @@
1
+ # Mongodb output plugin for Embulk
2
+
3
+ TODO: Write short description here and embulk-output-mongodb.gemspec file.
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: output
8
+ * **Load all or nothing**: no
9
+ * **Resume supported**: no
10
+ * **Cleanup supported**: yes
11
+
12
+ ## Configuration
13
+
14
+ - **uri**: description (string, default: "mongodb://127.0.01:27017/test")
15
+ - **collection**: description (string, required)
16
+
17
+ ## Example
18
+
19
+ ```yaml
20
+ out:
21
+ type: mongodb
22
+ uri: mongodb://127.0.01:27017/test
23
+ collection: collection_name
24
+ ```
25
+
26
+
27
+ ## Build
28
+
29
+ ```
30
+ $ rake
31
+ ```
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task default: :build
@@ -0,0 +1,20 @@
1
+
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "embulk-output-mongodb"
4
+ spec.version = "0.1.0"
5
+ spec.authors = ["Hiroki Mizumoto"]
6
+ spec.summary = "Mongodb output plugin for Embulk"
7
+ spec.description = "Dumps records to Mongodb."
8
+ spec.email = ["shuibenhonggui@gmail.com"]
9
+ spec.licenses = ["MIT"]
10
+ spec.homepage = "https://github.com/motomizuki/embulk-output-mongodb"
11
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
12
+ spec.test_files = spec.files.grep(%r{^(test|spec)/})
13
+ spec.require_paths = ["lib"]
14
+
15
+ #spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
16
+ spec.add_development_dependency 'embulk', ['>= 0.8.18']
17
+ spec.add_development_dependency 'bundler', ['>= 1.10.6']
18
+ spec.add_development_dependency 'rake', ['>= 10.0']
19
+ spec.add_dependency 'mongo', ['>= 2.4']
20
+ end
@@ -0,0 +1,61 @@
1
+ module Embulk
2
+ module Output
3
+
4
+ class Mongodb < OutputPlugin
5
+ require 'mongo'
6
+ Plugin.register_output('mongodb', self)
7
+
8
+ def self.transaction(config, schema, count, &control)
9
+ # configuration code:
10
+ task = {
11
+ 'uri' => config.param('uri', :string, default: 'mongodb://127.0.0.1:27017/test'), # string, optional
12
+ 'collection' => config.param('collection', :string) # string, required
13
+ }
14
+
15
+ # resumable output:
16
+ # resume(task, schema, count, &control)
17
+
18
+ # non-resumable output:
19
+ task_reports = yield(task)
20
+ next_config_diff = {}
21
+ return next_config_diff
22
+ end
23
+
24
+ #def self.resume(task, schema, count, &control)
25
+ # task_reports = yield(task)
26
+ #
27
+ # next_config_diff = {}
28
+ # return next_config_diff
29
+ #end
30
+
31
+ def init
32
+ # initialization code:
33
+ @client = Mongo::Client.new(task['uri'])
34
+ @collection = @client[task['collection']]
35
+ end
36
+
37
+ def close
38
+ end
39
+
40
+ def add(page)
41
+ # output code:
42
+ page.each do |record|
43
+ hash = Hash[schema.names.zip(record)]
44
+ @collection.insert_one(hash)
45
+ end
46
+ end
47
+
48
+ def finish
49
+ end
50
+
51
+ def abort
52
+ end
53
+
54
+ def commit
55
+ task_report = {}
56
+ return task_report
57
+ end
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,14 @@
1
+ in:
2
+ type: file
3
+ path_prefix: ./test/test_data.csv
4
+ parser:
5
+ type: csv
6
+ columns:
7
+ - {name: a, type: long}
8
+ - {name: b, type: long}
9
+ - {name: c, type: long}
10
+
11
+ out:
12
+ type: mongodb
13
+ uri: mongodb://127.0.0.1:27018/test
14
+ collection: embulk
@@ -0,0 +1,6 @@
1
+ a,b,c
2
+ 1,2,3
3
+ 2,3,4
4
+ 5,6,7
5
+ 8,9,10
6
+ 15,11,12
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-output-mongodb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiroki Mizumoto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: embulk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.18
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.18
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.10.6
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.10.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mongo
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '2.4'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '2.4'
69
+ description: Dumps records to Mongodb.
70
+ email:
71
+ - shuibenhonggui@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".ruby-version"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - embulk-output-mongodb.gemspec
83
+ - lib/embulk/output/mongodb.rb
84
+ - test/config.yml
85
+ - test/test_data.csv
86
+ homepage: https://github.com/motomizuki/embulk-output-mongodb
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.5.1
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Mongodb output plugin for Embulk
110
+ test_files:
111
+ - test/config.yml
112
+ - test/test_data.csv