Requires the library string passed in. If the library fails to load then it will display a helpful message.
Source Code
# File merb/core_ext/kernel.rb, line 59 def requires(library) # TODO: Extract messages out into a messages file. This will also be the first step towards internationalization. # TODO: adjust this message once logging refactor is complete. require(library) message = "#{Time.now.httpdate}: loading library '#{library}' from #{__app_file_trace__.first} ..." puts(message) Merb.logger.info(message) rescue LoadError # TODO: adjust the two messages below to use merb's logger.error/info once logging refactor is complete. message = "#{Time.now.httpdate}: <e> Could not find '#{library}' as either a library or gem, loaded from #{__app_file_trace__.first}.\n" puts(message) Merb.logger.error(message) # Print a helpful message message = "#{Time.now.httpdate}: <i> Please be sure that if '#{library}': \n" message << "#{Time.now.httpdate}: <i> * is a normal ruby library (file), be sure that the path of the library it is present in the $LOAD_PATH via $LOAD_PATH.unshift(\"/path/to/#{library}\") \n" message << "#{Time.now.httpdate}: <i> * is included within a gem, be sure that you are specifying the gem as a dependency \n" puts(message) Merb.logger.error(message) exit() # Missing library/gem must be addressed. end
<code/>and<pre/>for code samples.