Module: Bundler::SharedHelpers

Extended by:
SharedHelpers
Included in:
Runtime, SharedHelpers
Defined in:
lib/bundler/shared_helpers.rb

Constant Summary

CHDIR_MONITOR =
Monitor.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gem_loadedObject

Returns the value of attribute gem_loaded



21
22
23
# File 'lib/bundler/shared_helpers.rb', line 21

def gem_loaded
  @gem_loaded
end

Instance Method Details

#chdir(dir, &blk) ⇒ Object



42
43
44
45
46
# File 'lib/bundler/shared_helpers.rb', line 42

def chdir(dir, &blk)
  chdir_monitor.synchronize do
    Dir.chdir dir, &blk
  end
end

#chdir_monitorObject



38
39
40
# File 'lib/bundler/shared_helpers.rb', line 38

def chdir_monitor
  CHDIR_MONITOR
end

#default_gemfileObject

Raises:



24
25
26
27
28
# File 'lib/bundler/shared_helpers.rb', line 24

def default_gemfile
  gemfile = find_gemfile
  raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
  Pathname.new(gemfile)
end

#default_lockfileObject



30
31
32
# File 'lib/bundler/shared_helpers.rb', line 30

def default_lockfile
  Pathname.new("#{default_gemfile}.lock")
end

#in_bundle?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/bundler/shared_helpers.rb', line 34

def in_bundle?
  find_gemfile
end

#pwdObject



48
49
50
51
52
# File 'lib/bundler/shared_helpers.rb', line 48

def pwd
  chdir_monitor.synchronize do
    Dir.pwd
  end
end

#with_clean_git_env(&block) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/bundler/shared_helpers.rb', line 54

def with_clean_git_env(&block)
  keys    = %w[GIT_DIR GIT_WORK_TREE]
  old_env = keys.inject({}) do |h, k|
    h.update(k => ENV[k])
  end

  keys.each {|key| ENV.delete(key) }

  block.call
ensure
  keys.each {|key| ENV[key] = old_env[key] }
end