Class: Embulk::Plugin::FilterGrep
- Inherits:
-
FilterPlugin
- Object
- FilterPlugin
- Embulk::Plugin::FilterGrep
- Defined in:
- lib/embulk/filter_grep.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(page) ⇒ Object
- #close ⇒ Object
- #finish ⇒ Object
-
#initialize(task, in_schema, out_schema, page_builder) ⇒ FilterGrep
constructor
A new instance of FilterGrep.
Constructor Details
#initialize(task, in_schema, out_schema, page_builder) ⇒ FilterGrep
Returns a new instance of FilterGrep.
20 21 22 23 |
# File 'lib/embulk/filter_grep.rb', line 20 def initialize(task, in_schema, out_schema, page_builder) super @columns = task['columns'] end |
Class Method Details
.transaction(config, in_schema) {|task, out_columns| ... } ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/embulk/filter_grep.rb', line 8 def self.transaction(config, in_schema, &control) task = { 'columns' => config.param('columns', :array), } out_columns = in_schema puts "Extranction filter started." yield(task, out_columns) puts "Extranction filter finished." end |
Instance Method Details
#add(page) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/embulk/filter_grep.rb', line 28 def add(page) page.each do |record| hash = Hash[in_schema.names.zip(record)] @columns.each do |col| regEx = col['regexp'] if hash[col['name']] =~ /#{regEx}/ @page_builder.add(record) end end end end |
#close ⇒ Object
25 26 |
# File 'lib/embulk/filter_grep.rb', line 25 def close end |
#finish ⇒ Object
40 41 42 |
# File 'lib/embulk/filter_grep.rb', line 40 def finish @page_builder.finish end |