embulk-plugin-filter-convert 0.0.1
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.
- checksums.yaml +7 -0
- data/README.md +37 -0
- data/lib/embulk/filter_convert.rb +49 -0
- metadata +60 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 45a7808c48b447eb5ec9947a83dfb291c80d9c10
|
|
4
|
+
data.tar.gz: eef210d7a0a7d2844584a16c8d7058fac56a4e49
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 65db5dcd765ef613c27dfbb4b0e80faf5e5f0f9e043ff4846c2d76887b244d79fbabf96221fb89ce9cab0e08ee7bb1528db00cb64405ac19d2b60967a1f482f1
|
|
7
|
+
data.tar.gz: 5b4f814a136514d0dfa82f87abd8833167a96aa3750608596cfa8a6b30b6905d1bf4061f18bb692b4fdae31df5caabc17b9ca67b6e7abeb52e7c65840f373ab2
|
data/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Embulk filter plugin for data convert
|
|
2
|
+
|
|
3
|
+
data convert
|
|
4
|
+
|
|
5
|
+
no filter:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
id,account,time,comment
|
|
9
|
+
1,32864,2015-01-27 19:23:49.000000 +0000,embulk
|
|
10
|
+
2,14824,2015-01-27 19:01:23.000000 +0000,embulk jruby
|
|
11
|
+
3,27559,2015-01-28 02:20:02.000000 +0000,embulk core
|
|
12
|
+
4,11270,2015-01-29 11:54:36.000000 +0000,Embulk "csv" parser plugin
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
filter convert: comment,id,time
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
comment,id,time,
|
|
19
|
+
embulk,32864,2015-01-27 19:23:49.000000 +0000
|
|
20
|
+
embulk jruby,14824,2015-01-27 19:01:23.000000 +0000
|
|
21
|
+
embulk core,27559,2015-01-28 02:20:02.000000 +0000
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Configuration
|
|
25
|
+
|
|
26
|
+
- **columns** need column name and type (array)
|
|
27
|
+
|
|
28
|
+
### Example
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
filters:
|
|
32
|
+
- type: convert
|
|
33
|
+
columns:
|
|
34
|
+
- {name: comment, type: string}
|
|
35
|
+
- {name: account, type: long}
|
|
36
|
+
- {name: time, type: timestamp}
|
|
37
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Embulk
|
|
2
|
+
module Plugin
|
|
3
|
+
|
|
4
|
+
class FilterConvert < FilterPlugin
|
|
5
|
+
|
|
6
|
+
Plugin.register_filter('convert', self)
|
|
7
|
+
|
|
8
|
+
def self.transaction(config, in_schema, &control)
|
|
9
|
+
task = {
|
|
10
|
+
'columns' => config.param('columns', :array),
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
out_columns = []
|
|
14
|
+
|
|
15
|
+
record = 0
|
|
16
|
+
task['columns'].each do |column|
|
|
17
|
+
out_columns << Column.new(record, column['name'], column['type'].to_sym)
|
|
18
|
+
record += 1
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
yield(task, out_columns)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def initialize(task, in_schema, out_schema, page_builder)
|
|
25
|
+
super
|
|
26
|
+
@columns = task['columns']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def close
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def add(page)
|
|
33
|
+
page.each do |record|
|
|
34
|
+
hash = Hash[in_schema.names.zip(record)]
|
|
35
|
+
out_record = []
|
|
36
|
+
@columns.each do |column|
|
|
37
|
+
out_record << hash[column['name']]
|
|
38
|
+
end
|
|
39
|
+
@page_builder.add(out_record)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def finish
|
|
44
|
+
@page_builder.finish
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: embulk-plugin-filter-convert
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tadaichiro Nakano
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-02-14 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.8'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.8'
|
|
27
|
+
description: Embulk Fileter Plugin Convert
|
|
28
|
+
email:
|
|
29
|
+
- nakanotadaichiro@outlook.jp
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- lib/embulk/filter_convert.rb
|
|
35
|
+
- README.md
|
|
36
|
+
homepage: https://github.com/tadaichiro/embulk-plugin-filter-convert
|
|
37
|
+
licenses:
|
|
38
|
+
- MIT
|
|
39
|
+
metadata: {}
|
|
40
|
+
post_install_message:
|
|
41
|
+
rdoc_options: []
|
|
42
|
+
require_paths:
|
|
43
|
+
- lib
|
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - '>='
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
requirements: []
|
|
55
|
+
rubyforge_project:
|
|
56
|
+
rubygems_version: 2.0.14
|
|
57
|
+
signing_key:
|
|
58
|
+
specification_version: 4
|
|
59
|
+
summary: Embulk Fileter Plugin Convert
|
|
60
|
+
test_files: []
|