Skip to content

Instantly share code, notes, and snippets.

@muziyoshiz
Created May 30, 2015 08:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Sample filter: embulk-filter-myapp
module Embulk
module Filter
class MyappFilterPlugin < FilterPlugin
Plugin.register_filter("myapp", self)
def self.transaction(config, in_schema, &control)
yield({}, in_schema)
end
def init
end
def close
end
def add(page)
# find index of "comment" column
columns = page.schema.select{|c| c.name == "comment" }
idx = columns[0].index
# filtering code:
page.each do |record|
case record[idx]
when /^login failure:/
record[idx] = "login failure"
when /^login by/
record[idx] = "login"
end
page_builder.add(record)
end
end
def finish
page_builder.finish
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment