Module: Bismas::Filter
Constant Summary
Constants included from Bismas
CATEGORY_CHAR_SKIP, CHARS, DEFAULT_CATEGORY_LENGTH, DEFAULT_ENCODING, DEFAULT_PADDING_LENGTH, REGEX, VERSION
Instance Method Summary collapse
Methods included from Bismas
amend_encoding, chars, encode, execute, execute_options, filter, input_options, mapping, regex, require_gem, safe_yaml, to_xml
Instance Method Details
#run(klass, options, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/bismas/filter.rb', line 35 def run(klass, , &block) execute = (, &block) mapping = mapping([:mapping], &block) key_format = [:key_format] , = (), { encoding: encoding = [:output_encoding], key: [:output_key], sort: [:sort], padding_length: [:padding_length], category_length: [:category_length] } execute[0][bind1 = binding] klass.open([:output], ) { |writer| Reader.parse_file([:input], ) { |id, record| execute[1][bind2 = binding] record = mapping.apply(encode(record, encoding)) execute[2][bind2] writer[key_format % id] = record } } execute[3][bind1] end |