Class: JBundler::ClasspathFile

Inherits:
Object
  • Object
show all
Defined in:
lib/jbundler/classpath_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(classpathfile = '.jbundler/classpath.rb') ⇒ ClasspathFile

Returns a new instance of ClasspathFile.



25
26
27
# File 'lib/jbundler/classpath_file.rb', line 25

def initialize(classpathfile = '.jbundler/classpath.rb')
  @classpathfile = classpathfile
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/jbundler/classpath_file.rb', line 43

def exists?
  File.exists?(@classpathfile)
end

#generate(classpath_array, test_array = [], jruby_array = []) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/jbundler/classpath_file.rb', line 51

def generate( classpath_array, test_array = [], jruby_array = [] )
  FileUtils.mkdir_p(File.dirname(@classpathfile))
  File.open(@classpathfile, 'w') do |f|
    dump_array( f, jruby_array || [], 'JRUBY_' )
    dump_array( f, test_array || [], 'TEST_' )
    dump_array( f, classpath_array || [], '' )
    f.puts "JBUNDLER_CLASSPATH.each { |c| require c }"
    f.close
  end
end

#mtimeObject



39
40
41
# File 'lib/jbundler/classpath_file.rb', line 39

def mtime
  File.mtime(@classpathfile)
end

#needs_update?(jarfile, gemfile_lock) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/jbundler/classpath_file.rb', line 47

def needs_update?(jarfile, gemfile_lock)
  (jarfile.exists? || gemfile_lock.exists? || jarfile.exists_lock?) && (!exists? || !jarfile.exists_lock? || (jarfile.exists? && (jarfile.mtime > mtime)) || (jarfile.exists_lock? && (jarfile.mtime_lock > mtime)) || (gemfile_lock.exists? && (gemfile_lock.mtime > mtime)))
end

#require_classpathObject



29
30
31
32
# File 'lib/jbundler/classpath_file.rb', line 29

def require_classpath
  load File.expand_path @classpathfile
  JBUNDLER_CLASSPATH.each { |c| require c }
end

#require_test_classpathObject



34
35
36
37
# File 'lib/jbundler/classpath_file.rb', line 34

def require_test_classpath
  load File.expand_path @classpathfile unless defined? JBUNLDER_TEST_CLASSPATH
  JBUNDLER_TEST_CLASSPATH.each { |c| require c }
end