In Files

Parent

Object

Public Instance Methods

fctReturn5() click to toggle source

Define a function that will be used in the file to be required

    # File examples/SimpleExample.rb, line 18
18: def fctReturn5
19:   return 5
20: end
getSpecification() click to toggle source

Return the Gem specification

Return:

  • Gem::Specification: The Gem specification

    # File rcodeleveler.gemspec.rb, line 16
16: def getSpecification
17:   return Gem::Specification.new do |iSpec|
18:     iSpec.name = 'RCodeLeveler'
19:     lNow = DateTime.now
20:     iSpec.version = "0.1.#{sprintf('%04d%02d%02d',lNow.year,lNow.month,lNow.day)}"
21:     iSpec.author = 'Muriel Salvan'
22:     iSpec.email = 'murielsalvan@users.sourceforge.net'
23:     iSpec.homepage = 'http://rcodeleveler.sourceforge.net/'
24:     iSpec.platform = Gem::Platform::RUBY
25:     iSpec.summary = 'A Ruby preprocessor that enables/disables parts of the source code.'
26:     iSpec.files = Dir.glob('{test,lib,docs,examples}/**/*').delete_if do |iFileName|
27:       iFileName == 'CVS'
28:     end
29:     iSpec.require_path = 'lib'
30:     iSpec.autorequire = 'rcodeleveler'
31:     iSpec.test_file = 'test/run.rb'
32:     iSpec.has_rdoc = true
33:     iSpec.extra_rdoc_files = ['README',
34:                               'TODO',
35:                               'Bugs',
36:                               'Releases',
37:                               'LICENSE',
38:                               'AUTHORS',
39:                               'Credits',
40:                               'examples']
41:   end
42: end
requireLevel(iLibraryName) click to toggle source

Require method to use that loads the file by enabling/disabling code levels. This method works only with .rb files.

Parameters:

  • iLibraryName (String): Name of the ruby file to require.

     # File lib/rcodeleveler.rb, line 488
488: def requireLevel(iLibraryName)
489:   lExtension = File.extname(iLibraryName)
490:   if (lExtension == '')
491:     lFileNameWithExt = "#{iLibraryName}.rb"
492:   else
493:     lFileNameWithExt = iLibraryName
494:   end
495:   # Do not process if it was already done (check in $" variable)
496:   if ($".index(lFileNameWithExt) == nil)
497:     # Get the real location
498:     lRealFileName = RCodeLeveler::getRealLibraryPath(iLibraryName)
499:     if (lRealFileName != nil)
500:       # Avoid further parsing of this file with require or requireLevel
501:       $" << lFileNameWithExt
502:       if ($RCLOutputDirectory == nil)
503:         lSourceCode, lDifference = RCodeLeveler::getSourceFileContentLevelized(lRealFileName)
504:       else
505:         lSourceCode, lDifference = RCodeLeveler::getSourceFileContentLevelized(lRealFileName, "#{$RCLOutputDirectory}/#{iLibraryName}.leveled.rb")
506:       end
507:       # Uncomment to dump the file being really evaluated to stdout.
508:       #puts '======================================================================='
509:       #puts '======================================================================='
510:       #puts lRealFileName
511:       #p $RCLLevels
512:       #puts '======================================================================='
513:       #puts '======================================================================='
514:       #puts lSourceCode.join('')
515:       # And now eval the code
516:       eval "#{lSourceCode.join('')}", nil, lRealFileName
517:     else
518:       # Dump error
519:       lDirList = $:.join(', ')
520:       raise LoadError, "Unable to find file #{iLibraryName}. List of directories searched: #{lDirList}. Please use requireLevel with Ruby source files only."
521:     end
522:   end
523: end
requireTestRubyFiles(iDir, iRequireThisDir) click to toggle source

Requires recursively ruby files in sub-directories

Parameters:

  • iDir (String): The directory to check

  • iRequireThisDir (Boolean): Do we require the .rb files of this directory ?

    # File test/RCodeLevelerTest.rb, line 68
68: def requireTestRubyFiles(iDir, iRequireThisDir)
69:   Dir.foreach(iDir) do |iFileName|
70:     lFileName = "#{iDir}/#{iFileName}"
71:     if (File.directory?(lFileName))
72:       if ((iFileName != '.') and
73:           (iFileName != '..') and
74:           (iFileName != 'RequiredFiles'))
75:         # Recursion
76:         requireTestRubyFiles(lFileName, true)
77:       end
78:     else
79:       # If it is a ruby file, we might need to require it.
80:       if ((File.extname(iFileName) == '.rb') and
81:           iRequireThisDir)
82:         # Require it
83:         require lFileName
84:       end
85:     end
86:   end
87: end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.