Module: Bundler::SharedHelpers
- Extended by:
- SharedHelpers
- Included in:
- Runtime, SharedHelpers
- Defined in:
- lib/bundler/shared_helpers.rb
Instance Attribute Summary collapse
-
#gem_loaded ⇒ Object
Returns the value of attribute gem_loaded.
Instance Method Summary collapse
- #chdir(dir, &blk) ⇒ Object
- #chdir_monitor ⇒ Object
- #default_bundle_dir ⇒ Object
- #default_gemfile ⇒ Object
- #default_lockfile ⇒ Object
- #in_bundle? ⇒ Boolean
- #pwd ⇒ Object
- #set_bundle_environment ⇒ Object
- #with_clean_git_env(&block) ⇒ Object
Instance Attribute Details
#gem_loaded ⇒ Object
Returns the value of attribute gem_loaded.
20 21 22 |
# File 'lib/bundler/shared_helpers.rb', line 20 def gem_loaded @gem_loaded end |
Instance Method Details
#chdir(dir, &blk) ⇒ Object
56 57 58 59 60 |
# File 'lib/bundler/shared_helpers.rb', line 56 def chdir(dir, &blk) chdir_monitor.synchronize do Dir.chdir dir, &blk end end |
#chdir_monitor ⇒ Object
52 53 54 |
# File 'lib/bundler/shared_helpers.rb', line 52 def chdir_monitor Bundler.rubygems.ext_lock end |
#default_bundle_dir ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bundler/shared_helpers.rb', line 37 def default_bundle_dir global_bundle_dir = File.join(Bundler.rubygems.user_home, ".bundle") bundle_dir = find_directory(".bundle") if bundle_dir && bundle_dir != global_bundle_dir Pathname.new(bundle_dir) else nil end end |
#default_gemfile ⇒ Object
22 23 24 25 26 |
# 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 ⇒ Object
28 29 30 31 32 33 34 35 |
# 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? ⇒ Boolean
48 49 50 |
# File 'lib/bundler/shared_helpers.rb', line 48 def in_bundle? find_gemfile end |
#pwd ⇒ Object
62 63 64 65 66 |
# File 'lib/bundler/shared_helpers.rb', line 62 def pwd chdir_monitor.synchronize do Dir.pwd end end |
#set_bundle_environment ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/bundler/shared_helpers.rb', line 81 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 %|-rbundler/setup| ENV["RUBYOPT"] = rubyopt.join(' ') end # Set RUBYLIB rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR) rubylib.unshift File.('../..', __FILE__) ENV["RUBYLIB"] = rubylib.uniq.join(File::PATH_SEPARATOR) end |
#with_clean_git_env(&block) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/bundler/shared_helpers.rb', line 68 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 |