Class: JBundler::Vendor
- Inherits:
-
Object
- Object
- JBundler::Vendor
- Defined in:
- lib/jbundler/vendor.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #copy_jar(coord, file) ⇒ Object
-
#initialize(dir) ⇒ Vendor
constructor
A new instance of Vendor.
- #require_jars ⇒ Object
- #setup(classpath_file) ⇒ Object
- #vendored? ⇒ Boolean
Constructor Details
#initialize(dir) ⇒ Vendor
Returns a new instance of Vendor.
4 5 6 |
# File 'lib/jbundler/vendor.rb', line 4 def initialize( dir ) @dir = File.( dir ) end |
Instance Method Details
#clear ⇒ Object
18 19 20 21 22 23 |
# File 'lib/jbundler/vendor.rb', line 18 def clear FileUtils.mkdir_p( @dir ) Dir[ File.join( @dir, '*' ) ].each do |f| FileUtils.rm_rf( f ) end end |
#copy_jar(coord, file) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/jbundler/vendor.rb', line 34 def copy_jar( coord, file ) target = File.join( *coord.sub( /:jar:/, '-') .split( /:/ ) ) target_file = File.join( @dir, target ) + '.jar' FileUtils.mkdir_p( File.dirname( target_file ) ) FileUtils.cp( file, target_file ) puts "\t#{coord} to #{target}" end |
#require_jars ⇒ Object
12 13 14 15 16 |
# File 'lib/jbundler/vendor.rb', line 12 def require_jars Dir[ File.join( @dir, '**', '*' ) ].each do |f| require f end end |
#setup(classpath_file) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/jbundler/vendor.rb', line 25 def setup( classpath_file ) classpath_file.require_classpath FileUtils.mkdir_p( @dir ) JBUNDLER_CLASSPATH.each do |f| FileUtils.cp( f, File.join( @dir, File.basename( f ) ) ) end end |
#vendored? ⇒ Boolean
8 9 10 |
# File 'lib/jbundler/vendor.rb', line 8 def vendored? File.exists?( @dir ) && Dir[ File.join( @dir, '*' ) ].size > 0 end |