Class: JBundler::GemfileLock

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

Instance Method Summary collapse

Constructor Details

#initialize(jarfile, lockfile = 'Gemfile.lock') ⇒ GemfileLock

Returns a new instance of GemfileLock.



8
9
10
11
# File 'lib/jbundler/gemfile_lock.rb', line 8

def initialize(jarfile, lockfile = 'Gemfile.lock')
  @jarfile = jarfile
  @lockfile = lockfile if File.exists?(lockfile)
end

Instance Method Details

#mtimeObject



13
14
15
# File 'lib/jbundler/gemfile_lock.rb', line 13

def mtime
  File.mtime(@lockfile) if @lockfile
end

#populate_dependencies(aether) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jbundler/gemfile_lock.rb', line 17

def populate_dependencies(aether)
  if @lockfile
    # assuming we run in Bundler context here 
    # at we have a Gemfile.lock :)
    Bundler.load.specs.each do |spec|
      jars = []
      spec.requirements.each do |rr|
        rr.split(/\n/).each do |r|
          jars << r if r =~ /^jar\s/
        end
      end
      unless jars.empty?
        pom = Pom.new(spec.name, spec.version, jars, "pom")
        aether.install(pom.coordinate, pom.file)
        unless @jarfile.locked?(pom.coordinate)
          aether.add_artifact(pom.coordinate)
        end
      end
    end
  end
end