Module: Kernel
- Defined in:
- lib/baretest.rb,
lib/ruby/kernel.rb,
lib/command/kernel.rb,
lib/baretest/irb_mode.rb
Constant Summary collapse
- RequireExtensions =
All extensions Kernel#require_path and Kernel#expanded_require_path will try for a given filename
%w[.rb .so .dll .bundle .dylib]
Class Method Summary collapse
-
.BareTest(&block) ⇒ Object
Execute a piece of code in the context of BareTest.
-
.expanded_require_path(name, extensions = nil) ⇒ Object
Returns the absolute path to the file require would load, also see Kernel#require_path.
-
.load_into(name, mod = nil) ⇒ Object
Will load the given file like load (but accepts files without .rb in the end, like require), but evaluate it into the module given with the second arg (defaulting to Module.new).
-
.require_path(name, extensions = nil) ⇒ Object
Returns the path to the file require would load, also see Kernel#expanded_require_path.
Class Method Details
.BareTest(&block) ⇒ Object
Execute a piece of code in the context of BareTest
24 25 26 |
# File 'lib/baretest.rb', line 24 def BareTest(&block) BareTest.instance_eval(&block) end |
.expanded_require_path(name, extensions = nil) ⇒ Object
Returns the absolute path to the file require would load, also see Kernel#require_path
24 25 26 27 |
# File 'lib/ruby/kernel.rb', line 24 def (name, extensions=nil) path = require_path(name, extensions) path && File.(path) end |
.load_into(name, mod = nil) ⇒ Object
Will load the given file like load (but accepts files without .rb in the end, like require), but evaluate it into the module given with the second arg (defaulting to Module.new). It uses Kernel#expanded_require_path with ” and ‘.rb’ as extensions to determine the file to load uses the returned path for error messages (second argument to Module#modul_eval).
33 34 35 36 37 38 39 40 |
# File 'lib/ruby/kernel.rb', line 33 def load_into(name, mod=nil) mod ||= Module.new path = (name, ['', '.rb']) raise LoadError, "No such file to load -- #{name}" unless path mod.module_eval(File.read(path), path) mod end |
.require_path(name, extensions = nil) ⇒ Object
Returns the path to the file require would load, also see Kernel#expanded_require_path
15 16 17 18 19 20 21 |
# File 'lib/ruby/kernel.rb', line 15 def require_path(name, extensions=nil) extensions = (extensions || ::Kernel::RequireExtensions).join(',') Dir.glob("{#{$LOAD_PATH.join(',')}}/#{name}{#{extensions}}") { |path| return path } nil end |