Class: LockJar::Bundler

Inherits:
Object
  • Object
show all
Defined in:
lib/lock_jar/bundler.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.skip_lockObject

Returns the value of attribute skip_lock.



15
16
17
# File 'lib/lock_jar/bundler.rb', line 15

def skip_lock
  @skip_lock
end

Class Method Details

.expand_gem_paths(merged) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/lock_jar/bundler.rb', line 35

def expand_gem_paths(merged)
  
  merged_gem_paths = []
  Gem.path.each do |gem_root|
    merged.each do |merge|
      # merged gems follow the notation: gem:gemname:path

      if merge.start_with? 'gem:'
        gem_path = merge.gsub(/^gem:.+:/, '')
        gem_path = File.join( gem_root, gem_path )
        if File.exists? gem_path
          merged_gem_paths << gem_path
        end
      end
    end
  end
  
  merged_gem_paths
end

.load(*groups) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/lock_jar/bundler.rb', line 17

def load(*groups)
  if groups && !groups.empty?  && File.exists?( 'Jarfile.lock')
    
    lockfile = LockJar::Domain::Lockfile.read( 'Jarfile.lock' )
    
    # expand merged paths to include gem base path

    unless lockfile.merged.empty?
      lockfile.merged = LockJar::Bundler.expand_gem_paths( lockfile.merged )
    end
    
    LockJar.load( lockfile, groups )
    
    if ENV["DEBUG"]
      puts "[LockJar] Loaded Jars for #{groups.inspect}: #{LockJar::Registry.instance.loaded_jars.inspect}"
    end
  end
end