Class: JBundler::ClasspathFile
- Inherits:
-
Object
- Object
- JBundler::ClasspathFile
- Defined in:
- lib/jbundler/classpath_file.rb
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #generate(classpath_array, test_array = [], jruby_array = []) ⇒ Object
-
#initialize(classpathfile = '.jbundler/classpath.rb') ⇒ ClasspathFile
constructor
A new instance of ClasspathFile.
- #mtime ⇒ Object
- #needs_update?(jarfile, gemfile_lock) ⇒ Boolean
- #require_classpath ⇒ Object
- #require_test_classpath ⇒ Object
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
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 |
#mtime ⇒ Object
39 40 41 |
# File 'lib/jbundler/classpath_file.rb', line 39 def mtime File.mtime(@classpathfile) end |
#needs_update?(jarfile, gemfile_lock) ⇒ 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_classpath ⇒ Object
29 30 31 32 |
# File 'lib/jbundler/classpath_file.rb', line 29 def require_classpath load File. @classpathfile JBUNDLER_CLASSPATH.each { |c| require c } end |
#require_test_classpath ⇒ Object
34 35 36 37 |
# File 'lib/jbundler/classpath_file.rb', line 34 def require_test_classpath load File. @classpathfile unless defined? JBUNLDER_TEST_CLASSPATH JBUNDLER_TEST_CLASSPATH.each { |c| require c } end |