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 = [], local_repo = nil) ⇒ Object
-
#initialize(classpathfile = '.jbundler/classpath.rb') ⇒ ClasspathFile
constructor
A new instance of ClasspathFile.
- #jarfile_newer?(jarfile) ⇒ Boolean
- #jarlock_newer?(jarfile) ⇒ Boolean
- #load_classpath ⇒ Object
- #missing?(jarfile) ⇒ Boolean
- #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
47 48 49 |
# File 'lib/jbundler/classpath_file.rb', line 47 def exists? File.exists?(@classpathfile) end |
#generate(classpath_array, test_array = [], jruby_array = [], local_repo = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/jbundler/classpath_file.rb', line 71 def generate( classpath_array, test_array = [], jruby_array = [], local_repo = nil ) FileUtils.mkdir_p(File.dirname(@classpathfile)) File.open(@classpathfile, 'w') do |f| if local_repo local_repo = File.( local_repo ) f.puts "require 'jar_dependencies'" f.puts "JBUNDLER_LOCAL_REPO = Jars.home" end dump_array( f, jruby_array || [], 'JRUBY_', local_repo ) dump_array( f, test_array || [], 'TEST_', local_repo ) dump_array( f, classpath_array || [], '', local_repo ) f.close end end |
#jarfile_newer?(jarfile) ⇒ Boolean
55 56 57 |
# File 'lib/jbundler/classpath_file.rb', line 55 def jarfile_newer?( jarfile ) jarfile.exists? && (jarfile.mtime > mtime) end |
#jarlock_newer?(jarfile) ⇒ Boolean
59 60 61 |
# File 'lib/jbundler/classpath_file.rb', line 59 def jarlock_newer?( jarfile ) jarfile.exists_lock? && (jarfile.mtime_lock > mtime) end |
#load_classpath ⇒ Object
29 30 31 |
# File 'lib/jbundler/classpath_file.rb', line 29 def load_classpath load File. @classpathfile end |
#missing?(jarfile) ⇒ Boolean
51 52 53 |
# File 'lib/jbundler/classpath_file.rb', line 51 def missing?( jarfile ) !exists? || !jarfile.exists_lock? end |
#mtime ⇒ Object
43 44 45 |
# File 'lib/jbundler/classpath_file.rb', line 43 def mtime File.mtime(@classpathfile) end |
#needs_update?(jarfile, gemfile_lock) ⇒ Boolean
63 64 65 66 67 68 69 |
# File 'lib/jbundler/classpath_file.rb', line 63 def needs_update?(jarfile, gemfile_lock) if jarfile.exists? || gemfile_lock.exists? || jarfile.exists_lock? missing?( jarfile ) || jarfile_newer?( jarfile ) || jarlock_newer?( jarfile ) || gemfile_lock.newer?( mtime ) else false end end |
#require_classpath ⇒ Object
33 34 35 36 |
# File 'lib/jbundler/classpath_file.rb', line 33 def require_classpath load_classpath JBUNDLER_CLASSPATH.each { |c| require c } end |
#require_test_classpath ⇒ Object
38 39 40 41 |
# File 'lib/jbundler/classpath_file.rb', line 38 def require_test_classpath load_classpath JBUNDLER_TEST_CLASSPATH.each { |c| require c } end |