@@ -281,57 +281,47 @@ def automated_validation
281281 # persistent
282282 def check_pdf_files
283283 has_acc = false
284- bnames = Hash [ names . map { |n | [ n . base_name , false ] } ]
285- cnames = Hash [ names . map { |n | [ n . base_name , n . corrigendum_from ] } ]
284+ inames = Hash [ names . map { |n | [ n , false ] } ]
286285 [ publication_pdf , supplementary_pdf ] . each do |as |
287- break if has_acc && bnames . values . all?
286+ break if has_acc && inames . values . all?
288287 next unless as . attached?
289288
290289 as . open do |file |
291290 render = PDF ::Reader . new ( file . path )
292291 render . pages . each do |page |
293292 txt = page . text
294293 has_acc = true if txt . index ( accession )
295- bnames . each_key do |bn |
296- if txt . index ( bn ) || ( cnames [ bn ] && txt . index ( cnames [ bn ] ) )
297- bnames [ bn ] = true
298- end
294+ inames . each_key do |n |
295+ bn = n . base_name
296+ cn = n . corrigendum_from
297+ inames [ n ] = true if txt . index ( bn ) || ( cn && txt . index ( cn ) )
299298 end
300- break if has_acc && bnames . values . all?
299+ break if has_acc && inames . values . all?
301300 end
302301 end
303302 end
304303
305304 if has_acc
306305 add_note ( 'The effective publication includes the SeqCode accession' )
307306 else
308- add_note (
309- 'The effective publication does not include the accession ' \
310- '(SeqCode, Rule 26, Note 2)'
311- )
307+ names . each do |n |
308+ Check . find_or_create_by (
309+ name : n , kind : :effective_publication_missing_accession , pass : false
310+ )
311+ end
312312 end
313313
314- if bnames . values . all?
314+ if inames . values . all?
315315 add_note ( 'The effective publication mentions all names in the list' )
316- elsif bnames . values . any?
317- if bnames . values . count ( &:! ) > 5
318- add_note (
319- 'The effective publication mentions' \
320- " #{ bnames . values . count ( &:itself ) } out of" \
321- " #{ bnames . count } names in the list"
322- )
323- else
324- add_note (
325- 'The effective publication mentions some names in the list,' \
326- " but not: #{ bnames . select { |_ , v | !v } . keys . join ( ', ' ) } "
316+ else
317+ inames . each do |n , v |
318+ next if v
319+ Check . find_or_create_by (
320+ name : n , kind : :name_missing_in_effective_publication , pass : false
327321 )
328322 end
329- else
330- add_note (
331- 'The effective publication does not mention any names in the list'
332- )
333323 end
334324
335- has_acc && bnames . values . all?
325+ has_acc && inames . values . all?
336326 end
337327end
0 commit comments