embulk-filter-ruby_proc 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69bb84ba17676cef2b758609976a1eea10c774c5
4
- data.tar.gz: 458c5b32584e6faf8028f5742ff9f283eb261123
3
+ metadata.gz: 4abe5f3c208a186c9d25e8a8996cd9c7b210b9c2
4
+ data.tar.gz: eb284df63dabdc64a7068ab98bba99ea60b51139
5
5
  SHA512:
6
- metadata.gz: 83364a693c203516cbef89c2f6678ea2f16822d772dcf20589afd685d25632f7dedf43b207120bdb31f166b894148a6eb9c36bae35114cd316475fb327dd9168
7
- data.tar.gz: 99a2a967da43ed164c32d8c7534bc1da6d647bcc4f5963b2ccb1bd2b0f5ee376729914fd0c7dfeb4b151b98f29b2662fdeef0814ac11975d8fd604b99a8179e4
6
+ metadata.gz: e616ad4b49d0d5b05b336ff66bbf522ed18240973c1e192315b71db0096d37d88f1cabb31b6f621de471a6973faffcccf1e8dbf6020bcadaec3e8b16111e618c
7
+ data.tar.gz: 5f8e9e54f3ee58debbf2fd9a2b45a0e73e7b4b1014c4fef25bdb9ab684a90522cdd50c34628f754d553ea762fe713da2b1dcdb613b41bd1c78013505f9126850
data/README.md CHANGED
@@ -48,11 +48,7 @@ filters:
48
48
  end
49
49
  type: string
50
50
  - name: comment
51
- proc: |
52
- ->(comment, record) do
53
- return [record["account"].to_s].to_json unless comment
54
- comment.upcase.split(" ").map { |s| CGI.escape(s) }
55
- end
51
+ proc_file: comment_upcase.rb
56
52
  skip_nil: false
57
53
  type: json
58
54
  target: events
@@ -61,6 +57,15 @@ filters:
61
57
 
62
58
  ```
63
59
 
60
+ ```rb
61
+ # comment_upcase.rb
62
+
63
+ ->(comment, record) do
64
+ return [record["account"].to_s].to_json unless comment
65
+ comment.upcase.split(" ").map { |s| CGI.escape(s) }
66
+ end
67
+ ```
68
+
64
69
  ### preview
65
70
  ```
66
71
  +-----------+--------------+-------------------------+-------------------------+------------------------------------------+------------------------------------------------------------------------------------------+
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "embulk-filter-ruby_proc"
4
- spec.version = "0.1.1"
4
+ spec.version = "0.2.0"
5
5
  spec.authors = ["joker1007"]
6
6
  spec.summary = "Ruby Proc filter plugin for Embulk"
7
7
  spec.description = "Filter each record by ruby proc"
@@ -0,0 +1,4 @@
1
+ ->(comment, record) do
2
+ return [record["account"].to_s].to_json unless comment
3
+ comment.upcase.split(" ").map { |s| CGI.escape(s) }
4
+ end
data/example/config.yml CHANGED
@@ -41,11 +41,7 @@ filters:
41
41
  end
42
42
  type: string
43
43
  - name: comment
44
- proc: |
45
- ->(comment, record) do
46
- return [record["account"].to_s].to_json unless comment
47
- comment.upcase.split(" ").map { |s| CGI.escape(s) }
48
- end
44
+ proc_file: comment_upcase.rb
49
45
  skip_nil: false
50
46
  type: json
51
47
  target: events
@@ -28,7 +28,11 @@ module Embulk
28
28
  require lib
29
29
  end
30
30
  @procs = Hash[task["columns"].map {|col|
31
- [col["name"], eval(col["proc"])]
31
+ if col["proc"]
32
+ [col["name"], eval(col["proc"])]
33
+ else
34
+ [col["name"], eval(File.read(col["proc_file"]), binding, File.expand_path(col["proc_file"]))]
35
+ end
32
36
  }]
33
37
  @skip_nils = Hash[task["columns"].map {|col|
34
38
  [col["name"], col["skip_nil"].nil? ? true : !!col["skip_nil"]]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-filter-ruby_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2016-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: embulk
@@ -66,6 +66,7 @@ files:
66
66
  - README.md
67
67
  - Rakefile
68
68
  - embulk-filter-ruby_proc.gemspec
69
+ - example/comment_upcase.rb
69
70
  - example/config.yml
70
71
  - example/sample_01.csv
71
72
  - lib/embulk/filter/ruby_proc.rb