Module: Kernel
- Defined in:
- lib/reverse_require/extensions/kernel.rb
Instance Method Summary collapse
-
#require_all(path) ⇒ Object
Requires files from previously installed RubyGems that also end with the specified path.
-
#require_for(gem, path) ⇒ Object
Requires files that end with the specified path, from previously installed RubyGems which depend on the specified gem.
-
#reverse_require(*paths) ⇒ Object
Require the given paths in reverse.
Instance Method Details
#require_all(path) ⇒ Object
Requires files from previously installed RubyGems that also end with the specified path. Returns false
if no RubyGem contains the specified path, returns true
otherwise.
require_all 'ronin/models'
# => true
32 33 34 |
# File 'lib/reverse_require/extensions/kernel.rb', line 32 def require_all(path) reverse_require(*Gem.find_files(path)) end |
#require_for(gem, path) ⇒ Object
Requires files that end with the specified path, from previously installed RubyGems which depend on the specified gem. Returns false
if no RubyGem contains the specified path, returns true
otherwise.
require_for 'ronin', 'ronin/models'
# => true
44 45 46 |
# File 'lib/reverse_require/extensions/kernel.rb', line 44 def require_for(gem,path) reverse_require(*Gem.find_files_for(gem,path)) end |
#reverse_require(*paths) ⇒ Object
Require the given paths in reverse. Returns false
if all of the paths are already loaded, returns true
otherwise.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/reverse_require/extensions/kernel.rb', line 8 def reverse_require(*paths) was_loaded = false paths.reverse_each do |path| begin if File.file?(path) was_loaded ||= require path end rescue next end end return was_loaded end |