Module: Kernel
- Defined in:
- lib/fastlib.rb
Overview
:nodoc:all
Instance Method Summary collapse
-
#fastlib_already_loaded?(name) ⇒ Boolean
This method determines whether the specific file name has already been loaded ($LOADED_FEATURES aka $“).
-
#fastlib_already_tried?(name) ⇒ Boolean
This method determines whether the specific file name has already been attempted with the included FASTLIB archives.
- #fastlib_original_require ⇒ Object
-
#fastlib_require(name) ⇒ Object
This method handles the loading of FASTLIB archives.
-
#require(name) ⇒ Object
This method hooks the original Kernel.require to support loading files within FASTLIB archives.
Instance Method Details
#fastlib_already_loaded?(name) ⇒ Boolean
This method determines whether the specific file name has already been loaded ($LOADED_FEATURES aka $“)
355 356 357 358 |
# File 'lib/fastlib.rb', line 355 def fastlib_already_loaded?(name) re = Regexp.new("^" + Regexp.escape(name) + "$") $".detect { |e| e =~ re } != nil end |
#fastlib_already_tried?(name) ⇒ Boolean
This method determines whether the specific file name has already been attempted with the included FASTLIB archives.
TODO: Ensure that this only applies to known FASTLIB
archives and that newly included archives will
be searched appropriately.
369 370 371 372 |
# File 'lib/fastlib.rb', line 369 def fastlib_already_tried?(name) $fastlib_miss ||= [] $fastlib_miss.include?(name) end |
#fastlib_original_require ⇒ Object
309 |
# File 'lib/fastlib.rb', line 309 alias :fastlib_original_require :require |
#fastlib_require(name) ⇒ Object
This method handles the loading of FASTLIB archives
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/fastlib.rb', line 322 def fastlib_require(name) name = name + ".rb" if not name =~ /\.rb$/ return false if fastlib_already_loaded?(name) return false if fastlib_already_tried?(name) # TODO: Implement relative path $: checks and adjust the # search path within archives to match. $:.map{ |path| ::Dir["#{path}/*.fastlib"] }.flatten.uniq.each do |lib| data = FastLib.load(lib, name) next if not data $" << name begin Object.class_eval(data) rescue ::Exception => e opath,oerror = e.backtrace.shift.split(':', 2) e.backtrace.unshift("#{lib}::#{name}:#{oerror}") raise e end return true end $fastlib_miss << name false end |
#require(name) ⇒ Object
This method hooks the original Kernel.require to support loading files within FASTLIB archives
315 316 317 |
# File 'lib/fastlib.rb', line 315 def require(name) fastlib_require(name) || fastlib_original_require(name) end |