def extract_marc_filing_version(spec='245abdefghknp', opts={})
      include_original = opts.delete(:include_original)
      if opts.size > 0
        raise RuntimeError.new("extract_marc_filing_version can take only :include_original as an argument, not #{opts.keys.map{|x| "'#{x}'"}.join(' or ')}")
      end

      extractor = Traject::MarcExtractor.cached(spec, opts)

      lambda do |record, accumulator, context|
        extractor.collect_matching_lines(record) do |field, spec|
          str = extractor.collect_subfields(field, spec).first
          next unless str and !str.empty?
          vals = [Marc21Semantics.filing_version(field, str, spec)]
          if include_original
            vals.unshift str
            vals.uniq!
          end
          accumulator.concat vals
        end
      end
    end
def extract_marc_filing_version(spec='245abdefghknp', opts={})
      include_original = opts.delete(:include_original)
      if opts.size > 0
        raise RuntimeError.new("extract_marc_filing_version can take only :include_original as an argument, not #{opts.keys.map{|x| "'#{x}'"}.join(' or ')}")
      end

      extractor = Traject::MarcExtractor.cached(spec, opts)

      lambda do |record, accumulator, context|
        extractor.collect_matching_lines(record) do |field, spec|
          str = extractor.collect_subfields(field, spec).first
          next unless str and !str.empty?
          vals = [Marc21Semantics.filing_version(field, str, spec)]
          if include_original
            vals.unshift str
            vals.uniq!
          end
          accumulator.concat vals
        end
      end
    end
A generic way to strip a filing version (i.e., a string with the non-filing
 characters stripped off)

 Always returns an array. If :include_original=>true is passed in,
 that array will include the original string with the non-filing
 characters still in it.