module Bundler::SharedHelpers

Attributes

gem_loaded[RW]

Public Instance Methods

chdir(dir, &blk) click to toggle source
# File lib/bundler/shared_helpers.rb, line 51
def chdir(dir, &blk)
  Bundler.rubygems.ext_lock.synchronize do
    Dir.chdir dir, &blk
  end
end
default_bundle_dir() click to toggle source
# File lib/bundler/shared_helpers.rb, line 37
def default_bundle_dir
  bundle_dir = find_directory(".bundle")
  return nil unless bundle_dir

  global_bundle_dir = File.join(Bundler.rubygems.user_home, ".bundle")
  return nil if bundle_dir == global_bundle_dir

  Pathname.new(bundle_dir)
end
default_gemfile() click to toggle source
# File lib/bundler/shared_helpers.rb, line 22
def default_gemfile
  gemfile = find_gemfile
  raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
  Pathname.new(gemfile)
end
default_lockfile() click to toggle source
# File lib/bundler/shared_helpers.rb, line 28
def default_lockfile
  gemfile = default_gemfile

  case gemfile.basename.to_s
  when 'gems.rb' then Pathname.new(gemfile.sub(/.rb$/, '.locked'))
  else Pathname.new("#{gemfile}.lock")
  end
end
in_bundle?() click to toggle source
# File lib/bundler/shared_helpers.rb, line 47
def in_bundle?
  find_gemfile
end
pwd() click to toggle source
# File lib/bundler/shared_helpers.rb, line 57
def pwd
  Bundler.rubygems.ext_lock.synchronize do
    Dir.pwd
  end
end
set_bundle_environment() click to toggle source
# File lib/bundler/shared_helpers.rb, line 76
def set_bundle_environment
  # Set PATH
  paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
  paths.unshift "#{Bundler.bundle_path}/bin"
  ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)

  # Set RUBYOPT
  rubyopt = [ENV["RUBYOPT"]].compact
  if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/
    rubyopt.unshift %Q|-rbundler/setup|
    ENV["RUBYOPT"] = rubyopt.join(' ')
  end

  # Set RUBYLIB
  rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR)
  rubylib.unshift File.expand_path('../..', __FILE__)
  ENV["RUBYLIB"] = rubylib.uniq.join(File::PATH_SEPARATOR)
end
with_clean_git_env(&block) click to toggle source
# File lib/bundler/shared_helpers.rb, line 63
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