Class: Jars::Classpath

Inherits:
Object
  • Object
show all
Defined in:
lib/jars/classpath.rb

Constant Summary collapse

DEPENDENCY_LIST =
'dependencies.list'

Instance Method Summary collapse

Constructor Details

#initialize(spec = nil) ⇒ Classpath

Returns a new instance of Classpath.



9
10
11
# File 'lib/jars/classpath.rb', line 9

def initialize( spec = nil )
  @mvn = MavenExec.new( spec )
end

Instance Method Details

#classpath(scope = nil) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/jars/classpath.rb', line 55

def classpath( scope = nil )
  classpath = []
  process( scope ) do |jar|
    classpath << jar.file
  end
  classpath
end

#classpath_string(scope = nil) ⇒ Object



71
72
73
# File 'lib/jars/classpath.rb', line 71

def classpath_string( scope = nil )
  classpath( scope ).join( File::PATH_SEPARATOR )
end

#jars_lockObject



18
19
20
21
22
23
# File 'lib/jars/classpath.rb', line 18

def jars_lock
  deps = Jars.lock
  return deps if File.exists?( deps )
  deps = File.join( @mvn.basedir || '.', Jars.lock )
  deps if File.exists?( deps )
end

#require(scope = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/jars/classpath.rb', line 45

def require( scope = nil )
  process( scope ) do |jar|
    if jar.scope == :system
      Kernel.require jar.path
    else
      require_jar( *jar.gacv )
    end
  end
end

#workdir(dirname) ⇒ Object



13
14
15
16
# File 'lib/jars/classpath.rb', line 13

def workdir( dirname )
  dir = File.join( @mvn.basedir, dirname )
  dir if File.directory?( dir )
end