Class JavaClass::Classpath::AnyClasspath
In: lib/javaclass/classpath/any_classpath.rb
Parent: CompositeClasspath

Classpath containing everything under a folder. This is for an unstructured collection of JARs and class files.

Author:Peter Kofler

Methods

find_jars   new  

Public Class methods

Create a classpath with all classes found under this folder wherever they are.

[Source]

# File lib/javaclass/classpath/any_classpath.rb, line 12
      def initialize(folder)
        super(File.join(folder, '*'))
        find_jars(folder)
        
        # TODO Implement "find_classes_under(folder)" to find all class folders under this path. 
        # Search for classes, open the first one, check its package, backtrack to its base folder, 
        # add it to this classpath "add_file_name(sub_folders)", skip it in further analysis and continue.
      end

Public Instance methods

Search the given path recursively for zips or jars. Add all found jars to this classpath.

[Source]

# File lib/javaclass/classpath/any_classpath.rb, line 22
      def find_jars(path)
        if FileTest.file?(path) && path =~ /\.jar$|\.zip$/
          add_file_name File.expand_path(path)
          return
        end
        
        current = Dir.getwd
        begin
          Dir.chdir File.expand_path(path)

          Dir['*'].sort.collect do |name|
            if FileTest.directory?(name)
              find_jars(name)
            elsif name =~ /\.jar$|\.zip$/
              add_file_name File.expand_path(name)
            end
          end

        ensure
          Dir.chdir current
        end
      end

[Validate]