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
- #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
51 52 53 54 55 |
# 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 ⇒ Object
37 38 39 40 41 42 43 44 45 |
# 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 ⇒ 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
47 48 49 |
# File 'lib/bundler/shared_helpers.rb', line 47 def in_bundle? find_gemfile end |
#pwd ⇒ Object
57 58 59 60 61 |
# File 'lib/bundler/shared_helpers.rb', line 57 def pwd Bundler.rubygems.ext_lock.synchronize do Dir.pwd end end |
#set_bundle_environment ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# 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 %|-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
63 64 65 66 67 68 69 70 71 72 73 74 |
# 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 |