Class: Bundler::Settings::Path

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#explicit_pathObject

Returns the value of attribute explicit_path

Returns:

  • (Object)

    the current value of explicit_path



266
267
268
# File 'lib/bundler/settings.rb', line 266

def explicit_path
  @explicit_path
end

#system_pathObject

Returns the value of attribute system_path

Returns:

  • (Object)

    the current value of system_path



266
267
268
# File 'lib/bundler/settings.rb', line 266

def system_path
  @system_path
end

Instance Method Details

#base_pathObject



279
280
281
282
283
284
# File 'lib/bundler/settings.rb', line 279

def base_path
  path = explicit_path
  path ||= ".bundle" unless use_system_gems?
  path ||= Bundler.rubygems.gem_dir
  path
end

#base_path_relative_to_pwdObject



286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/bundler/settings.rb', line 286

def base_path_relative_to_pwd
  base_path = Pathname.new(self.base_path)
  expanded_base_path = base_path.expand_path(Bundler.root)
  relative_path = expanded_base_path.relative_path_from(Pathname.pwd)
  if relative_path.to_s.start_with?("..")
    relative_path = base_path if base_path.absolute?
  else
    relative_path = Pathname.new(File.join(".", relative_path))
  end
  relative_path
rescue ArgumentError
  expanded_base_path
end

#pathObject



267
268
269
270
271
# File 'lib/bundler/settings.rb', line 267

def path
  path = base_path
  path = File.join(path, Bundler.ruby_scope) unless use_system_gems?
  path
end

#use_system_gems?Boolean

Returns:

  • (Boolean)


273
274
275
276
277
# File 'lib/bundler/settings.rb', line 273

def use_system_gems?
  return true if system_path
  return false if explicit_path
  !Bundler.feature_flag.default_install_uses_path?
end

#validate!Object

Raises:



300
301
302
303
304
305
306
307
308
309
310
# File 'lib/bundler/settings.rb', line 300

def validate!
  return unless explicit_path && system_path
  path = Bundler.settings.pretty_values_for(:path)
  path.unshift(nil, "path:") unless path.empty?
  system_path = Bundler.settings.pretty_values_for("path.system")
  system_path.unshift(nil, "path.system:") unless system_path.empty?
  disable_shared_gems = Bundler.settings.pretty_values_for(:disable_shared_gems)
  disable_shared_gems.unshift(nil, "disable_shared_gems:") unless disable_shared_gems.empty?
  raise InvalidOption,
    "Using a custom path while using system gems is unsupported.\n#{path.join("\n")}\n#{system_path.join("\n")}\n#{disable_shared_gems.join("\n")}"
end