Class: RDI::Testers::RubyRequires
- Inherits:
-
Model::Tester
- Object
- Model::Tester
- RDI::Testers::RubyRequires
- Defined in:
- lib/rdi/Plugins/Testers/RubyRequires.rb
Overview
Test that some Ruby files are accessible
Instance Attribute Summary
Attributes inherited from Model::Tester
Instance Method Summary collapse
-
#getAffectingContextModifiers ⇒ Object
Give the name of possible ContextModifiers that might change the resolution of this Tester.
-
#isContentResolved?(iContent) ⇒ Boolean
Test if a given content is resolved.
Instance Method Details
#getAffectingContextModifiers ⇒ Object
Give the name of possible ContextModifiers that might change the resolution of this Tester. This is used to know what context modifiers the user can use to resolve dependencies without having to install.
Return:
-
list<String>: The list of ContextModifiers names
21 22 23 |
# File 'lib/rdi/Plugins/Testers/RubyRequires.rb', line 21 def getAffectingContextModifiers return [ 'GemPath', 'RubyLoadPath' ] end |
#isContentResolved?(iContent) ⇒ Boolean
Test if a given content is resolved
Parameters:
-
iContent (Object): The tester’s content
Return:
-
Boolean: Is the content resolved ?
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rdi/Plugins/Testers/RubyRequires.rb', line 31 def isContentResolved?(iContent) # * *iContent* (<em>list<String></em>): The list of requires to resolve rSuccess = false # Handle RubyGems as an option if (defined?(Gem) == nil) # No RubyGem. # For each required file, test that it exists among $LOAD_PATH iContent.each do |iRequireName| lFileFilter = iRequireName if (File.extname(iRequireName).empty?) lFileFilter = "#{iRequireName}.{rb,so,o,sl,dll}" end rSuccess = false $LOAD_PATH.each do |iDir| rSuccess = (!Dir.glob(File.("#{iDir}/#{lFileFilter}")).empty?) if (rSuccess) # We found it. Don't try other paths. break end end if (!rSuccess) # We didn't find this require. Don't try other requires. break end end else # RubyGems is here. Use it. # For each required file, test that it exists among the RubyGems' loaded paths iContent.each do |iRequireName| rSuccess = (!Gem.find_files(iRequireName).empty?) if (!rSuccess) # We did not find this one: don't even try the next ones break end end end return rSuccess end |