Skip to content

Commit

Permalink
Merge pull request #16 from pulibrary/development
Browse files Browse the repository at this point in the history
correct fixed field autofixes
  • Loading branch information
mzelesky authored Nov 26, 2018
2 parents 819945d + 7517f5a commit 7c6a349
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.5
0.8.6
17 changes: 13 additions & 4 deletions lib/marc_cleanup/bib_rubymarc_fixes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,13 @@ def fix_007(record)
target_fields = record.fields('007')
return record if target_fields.empty?
target_fields.each do |field|
rec_type = field[0]
field_index = record.fields.index(field)
field_value = field.value
rec_type = field_value[0]
next unless %w[a c d f g h k m o q r s t v z].include? rec_type
fixed_007 = rec_type
specific_007 = field[1..-1]
specific_007 = field_value[1..-1]
next unless specific_007
case rec_type
when 'a'
fixed_007 << fix_map_007(specific_007)
Expand Down Expand Up @@ -282,7 +285,9 @@ def fix_007(record)
when 'z'
fixed_007 << fix_unspec_007(specific_007)
end
record.fields[field_index].value = fixed_007
end
record
end

def fix_map_007(specific_007)
Expand Down Expand Up @@ -602,6 +607,8 @@ def fix_sound_rec_007(specific_007)
'e'
when 'f'
'i'
else
mat_designation
end
mat_designation.gsub!(/[^degiq-uwz|]/, 'u')
speed = specific_007[2]
Expand All @@ -620,6 +627,8 @@ def fix_sound_rec_007(specific_007)
'o'
when 'c'
'p'
else
width
end
width.gsub!(/[^l-puz|]/, 'u')
configuration = specific_007[7]
Expand Down Expand Up @@ -693,7 +702,7 @@ def contents_chars
end

def fix_contents_chars(contents)
return contents if contents == '||||'
return contents if contents =~ /[\|]+$/
contents.chars.each_with_index do |char, index|
case char
when 'h'
Expand All @@ -707,7 +716,7 @@ def fix_contents_chars(contents)
end
end
contents_values = contents.chars.select { |c| contents_chars.include? c }.sort.join('')
contents_values.ljust(4)
contents_values.ljust(contents.size)
end

def fix_006(record)
Expand Down

0 comments on commit 7c6a349

Please sign in to comment.