lib/marc_cleanup/bib_rubymarc_fixes.rb
### Replace obsolete values with current values when possible
Replace obsolete values with current values when possible
Replace obsolete values with current values when possible
def fix_008(record)
    target_fields = record.fields('008')
    return record if target_fields.size != 1
    rec_type = record.leader[6..7]
    return record unless rec_type =~ /^[ac-gijkmoprt][abcdims]$/
    fixed_record = record
    field = target_fields.first
    return record if field.value.size != 40
    field_index = fixed_record.fields.index(field)
    field_value = field.value
    specific_008 = field_value[18..34]
    modified = field_value[38]
    cat_source = field_value[39]
    fixed_008 = field_value
    fixed_008[38] = '|' if modified == 'u'
    if cat_source =~ /[abl]/
      fixed_008[39] = ' '
    elsif [' ', 'c', 'd', 'u', '|'].include? cat_source
      fixed_008[39] = cat_source
    elsif cat_source == 'o'
      fixed_008[39] = 'd'
    end
    fixed_008[18..34] =
      if book.include? rec_type
        fix_book_008(specific_008)
      elsif comp_file.include? rec_type
        fix_comp_008(specific_008)
      elsif map.include? rec_type
        fix_map_008(specific_008)
      elsif music.include? rec_type
        fix_music_008(specific_008)
      elsif continuing_resource.include? rec_type
        fix_continuing_resource_008(specific_008)
      elsif visual.include? rec_type
        fix_visual_008(specific_008)
      elsif mixed.include? rec_type
        fix_mix_mat_008(specific_008)
      else
        specific_008
      end
    fixed_record.fields[field_index].value = fixed_008
    fixed_record
  end
def fix_008 ( record ) target_fields = record . fields ( '008' ) return record if target_fields . size != 1 rec_type = record . leader [ 6 .. 7 ] return record unless rec_type =~ / ^[ac-gijkmoprt][abcdims]$ / fixed_record = record field = target_fields . first return record if field . value . size != 40 field_index = fixed_record . fields . index ( field ) field_value = field . value specific_008 = field_value [ 18 .. 34 ] modified = field_value [ 38 ] cat_source = field_value [ 39 ] fixed_008 = field_value fixed_008 [ 38 ] = '|' if modified == 'u' if cat_source =~ / [abl] / fixed_008 [ 39 ] = ' ' elsif [ ' ' , 'c' , 'd' , 'u' , '|' ] . include? cat_source fixed_008 [ 39 ] = cat_source elsif cat_source == 'o' fixed_008 [ 39 ] = 'd' end fixed_008 [ 18 .. 34 ] = if book . include? rec_type fix_book_008 ( specific_008 ) elsif comp_file . include? rec_type fix_comp_008 ( specific_008 ) elsif map . include? rec_type fix_map_008 ( specific_008 ) elsif music . include? rec_type fix_music_008 ( specific_008 ) elsif continuing_resource . include? rec_type fix_continuing_resource_008 ( specific_008 ) elsif visual . include? rec_type fix_visual_008 ( specific_008 ) elsif mixed . include? rec_type fix_mix_mat_008 ( specific_008 ) else specific_008 end fixed_record . fields [ field_index ] . value = fixed_008 fixed_record end
Replace obsolete values with current values when possible
Replace obsolete values with current values when possible
record