Sha256: 0a8f15960ab348f87c3bc8489570cf55075135863121589742f7dcb2459bcdac
Contents?: true
Size: 710 Bytes
Versions: 8
Compression:
Stored size: 710 Bytes
Contents
class Preprocessor def self.process(file) self.process_imports(file, []) end private IMPORT_STATEMENT = /#import "([^"]+)"/ def self.process_imports(file, imported_file_names) content = File.read(file) content.gsub(IMPORT_STATEMENT) do next if imported_file_names.include? $1 imported_file_names << $1 import_file = File.join(File.dirname(file), $1) begin "// begin #{File.basename($1)}" << "\n" << process_imports(import_file, imported_file_names) << "\n" << "// end #{File.basename($1)}" << "\n" rescue Exception => e STDERR.puts "Unable to process file #{import_file}: #{e}" $& end end end end
Version data entries
8 entries across 8 versions & 1 rubygems