Class: JBundler::LockDown

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ LockDown

Returns a new instance of LockDown.



15
16
17
18
# File 'lib/jbundler/lock_down.rb', line 15

def initialize( config )
  @config = config
  @configurator = Configurator.new( config )
end

Instance Method Details

#lock_down(needs_vendor = false, debug = false, verbose = false) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/jbundler/lock_down.rb', line 34

def lock_down( needs_vendor = false, debug = false, verbose = false )
  jarfile = Maven::Tools::Jarfile.new( @config.jarfile )
  classpath = JBundler::ClasspathFile.new( @config.classpath_file )
  if jarfile.exists_lock? && classpath.exists?
    needs_update = false
  else
    needs_update = needs_update?( jarfile, classpath )
  end
  if ( ! needs_update && ! needs_vendor ) || vendor.vendored?

    puts 'Jar dependencies are up to date !'

    if needs_update?( jarfile, classpath )
      f = classpath.file.sub(/#{Dir.pwd}#{File::SEPARATOR}/, '' )
      "the #{f} is stale, i.e. Gemfile or Jarfile is newer. `jbundle update` will update it"
    end
  else

    puts '...'
   
    deps = install_dependencies( debug, verbose, jarfile.exists_lock? )

    update_files( classpath, collect_jars( deps ) ) if needs_update

    vendor_it( vendor, deps ) if needs_vendor

  end
end

#update(debug = false, verbose = false) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/jbundler/lock_down.rb', line 24

def update( debug = false, verbose = false )
  if vendor.vendored?
    raise 'can not update vendored jars'
  end

  FileUtils.rm_f( @config.jarfile_lock )
  
  lock_down( false, debug, verbose )
end

#vendorObject



20
21
22
# File 'lib/jbundler/lock_down.rb', line 20

def vendor
  @vendor ||= JBundler::Vendor.new( @config.vendor_dir )
end