Class: JavaClass::Classpath::ConventionClasspath

Inherits:
FolderClasspath show all
Defined in:
lib/javaclass/classpath/convention_classpath.rb

Overview

A Java project by naming convention, contains a classes and a lib folder.

Author

Peter Kofler

Constant Summary collapse

CLASSES =
'classes'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FolderClasspath

#count, #includes?, #load_binary, #names

Methods inherited from FileClasspath

#==, #elements, #jar?, #to_key, #to_s

Constructor Details

#initialize(folder) ⇒ ConventionClasspath

Create a classpath for folder / classes.



20
21
22
23
# File 'lib/javaclass/classpath/convention_classpath.rb', line 20

def initialize(folder)
  super(File.join(folder, CLASSES))
  @root = folder
end

Class Method Details

.valid_location?(file) ⇒ Boolean

Check if the file is a valid location.

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/javaclass/classpath/convention_classpath.rb', line 14

def self.valid_location?(file)
  FolderClasspath.valid_location?(file) &&
  FolderClasspath.valid_location?(File.join(file, CLASSES))
end

Instance Method Details

#additional_classpathObject

Return list of additional classpath elements defined in the lib folder.



26
27
28
29
30
31
32
33
# File 'lib/javaclass/classpath/convention_classpath.rb', line 26

def additional_classpath
  lib = File.join(@root, 'lib')
  if FolderClasspath.valid_location?(lib)
    Dir.entries(lib).map { |e| File.join(lib, e) }.find_all { |e| JarClasspath.valid_location?(e) }
  else
    []
  end
end