embulk-filter-ruby_proc 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/embulk-filter-ruby_proc.gemspec +1 -1
- data/lib/embulk/filter/ruby_proc.rb +32 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 754bf37f61d14a24054997630406b8c9b02e7aff
|
4
|
+
data.tar.gz: c47c596b3745548ac8919e7be92727e6157bfd70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acf1ee4540152e40b7e706466b67f1f4f48eb23d200c988a3d46fe21dce669c19897c8f000cfbcf55f600c7c908a9accd7b51b268ecc7c9ad92f1cf1c5a733df
|
7
|
+
data.tar.gz: d3757d66ef78d46463a533b436fb4ae58c2e8a7fe09c9baad6c238eaca5204a5d6b76de095c7733ffa6e9f289056d7879e6e2e6fe534a82c7c83cbe55bde5fa6
|
@@ -113,9 +113,39 @@ module Embulk
|
|
113
113
|
@row_proc_store
|
114
114
|
end
|
115
115
|
|
116
|
+
def self.parse_col_procs(columns, evaluator_binding)
|
117
|
+
Hash[columns.map {|col|
|
118
|
+
if col["proc"]
|
119
|
+
[col["name"], eval(col["proc"], evaluator_binding)]
|
120
|
+
else
|
121
|
+
[col["name"], eval(File.read(col["proc_file"]), evaluator_binding, File.expand_path(col["proc_file"]))]
|
122
|
+
end
|
123
|
+
}]
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.parse_row_procs(rows, evaluator_binding)
|
127
|
+
rows.map {|rowdef|
|
128
|
+
if rowdef["proc"]
|
129
|
+
eval(rowdef["proc"], evaluator_binding)
|
130
|
+
else
|
131
|
+
eval(File.read(rowdef["proc_file"]), evaluator_binding, File.expand_path(rowdef["proc_file"]))
|
132
|
+
end
|
133
|
+
}.compact
|
134
|
+
end
|
135
|
+
|
116
136
|
def init
|
117
|
-
|
118
|
-
|
137
|
+
task["requires"].each do |lib|
|
138
|
+
require lib
|
139
|
+
end
|
140
|
+
|
141
|
+
if self.class.proc_store.nil? || self.class.row_proc_store.nil?
|
142
|
+
evaluator_binding = Evaluator.new(task["variables"]).get_binding
|
143
|
+
@procs = self.class.parse_col_procs(task["columns"], evaluator_binding)
|
144
|
+
@row_procs = self.class.parse_row_procs(task["rows"], evaluator_binding)
|
145
|
+
else
|
146
|
+
@procs = self.class.proc_store[task["transaction_id"]]
|
147
|
+
@row_procs = self.class.row_proc_store[task["transaction_id"]]
|
148
|
+
end
|
119
149
|
@skip_nils = Hash[task["columns"].map {|col|
|
120
150
|
[col["name"], col["skip_nil"].nil? ? true : !!col["skip_nil"]]
|
121
151
|
}]
|
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.
|
4
|
+
version: 0.7.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-
|
11
|
+
date: 2016-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: embulk
|