44require 'yaml'
55require 'date'
66
7+ # Get the project root directory (parent of scripts directory)
8+ PROJECT_ROOT = File . expand_path ( '..' , __dir__ )
9+
710def validate_file ( filepath )
811 puts "Validating #{ filepath } ..."
912
@@ -41,8 +44,8 @@ def validate_members(data, filepath)
4144 end
4245 end
4346
44- # Check if image file exists
45- image_path = File . join ( File . dirname ( __dir__ ) , member [ 'image' ] )
47+ # Check if image file exists (resolve relative to project root)
48+ image_path = File . expand_path ( member [ 'image' ] , PROJECT_ROOT )
4649 unless File . exist? ( image_path )
4750 puts " Warning: Image not found for #{ member [ 'name' ] } : #{ member [ 'image' ] } "
4851 end
@@ -80,12 +83,12 @@ def validate_publications(data, filepath)
8083 raise "Publication #{ pub [ 'id' ] } has invalid year: #{ pub [ 'year' ] } "
8184 end
8285
83- # Check if files exist
86+ # Check if files exist (resolve relative to project root)
8487 [ 'image' , 'bibtex' , 'pdf' ] . each do |file_field |
8588 next unless pub [ file_field ]
8689 next if pub [ file_field ] . start_with? ( 'http' )
8790
88- file_path = File . join ( File . dirname ( __dir__ ) , pub [ file_field ] )
91+ file_path = File . expand_path ( pub [ file_field ] , PROJECT_ROOT )
8992 unless File . exist? ( file_path )
9093 puts " Warning: File not found for #{ pub [ 'id' ] } : #{ pub [ file_field ] } "
9194 end
@@ -96,6 +99,9 @@ def validate_publications(data, filepath)
9699# Main execution
97100exit_code = 0
98101
102+ # Change to project root directory to find _data files
103+ Dir . chdir ( PROJECT_ROOT )
104+
99105Dir . glob ( '_data/*.yml' ) . each do |file |
100106 unless validate_file ( file )
101107 exit_code = 1
0 commit comments