bundler 1.11.2 → 1.12.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +24 -0
  3. data/.gitignore +2 -2
  4. data/.rubocop.yml +17 -2
  5. data/.rubocop_todo.yml +145 -18
  6. data/.travis.yml +9 -2
  7. data/CHANGELOG.md +42 -0
  8. data/Rakefile +20 -13
  9. data/bin/rake +5 -0
  10. data/bin/rspec +5 -0
  11. data/bin/rubocop +7 -1
  12. data/bundler.gemspec +2 -1
  13. data/exe/bundle +10 -2
  14. data/exe/bundle_ruby +2 -1
  15. data/exe/bundler +3 -1
  16. data/lib/bundler.rb +54 -51
  17. data/lib/bundler/capistrano.rb +1 -0
  18. data/lib/bundler/cli.rb +26 -4
  19. data/lib/bundler/cli/binstubs.rb +1 -0
  20. data/lib/bundler/cli/cache.rb +1 -0
  21. data/lib/bundler/cli/check.rb +4 -1
  22. data/lib/bundler/cli/clean.rb +1 -0
  23. data/lib/bundler/cli/common.rb +1 -0
  24. data/lib/bundler/cli/config.rb +5 -5
  25. data/lib/bundler/cli/console.rb +1 -0
  26. data/lib/bundler/cli/exec.rb +4 -9
  27. data/lib/bundler/cli/gem.rb +12 -9
  28. data/lib/bundler/cli/init.rb +1 -0
  29. data/lib/bundler/cli/inject.rb +1 -0
  30. data/lib/bundler/cli/install.rb +8 -5
  31. data/lib/bundler/cli/lock.rb +2 -0
  32. data/lib/bundler/cli/open.rb +1 -0
  33. data/lib/bundler/cli/outdated.rb +36 -9
  34. data/lib/bundler/cli/package.rb +1 -0
  35. data/lib/bundler/cli/platform.rb +4 -1
  36. data/lib/bundler/cli/show.rb +1 -0
  37. data/lib/bundler/cli/update.rb +6 -6
  38. data/lib/bundler/cli/viz.rb +4 -6
  39. data/lib/bundler/constants.rb +1 -0
  40. data/lib/bundler/current_ruby.rb +34 -168
  41. data/lib/bundler/definition.rb +41 -15
  42. data/lib/bundler/dep_proxy.rb +1 -0
  43. data/lib/bundler/dependency.rb +10 -0
  44. data/lib/bundler/deployment.rb +1 -0
  45. data/lib/bundler/deprecate.rb +1 -0
  46. data/lib/bundler/dsl.rb +19 -9
  47. data/lib/bundler/endpoint_specification.rb +37 -8
  48. data/lib/bundler/env.rb +4 -3
  49. data/lib/bundler/environment.rb +1 -0
  50. data/lib/bundler/errors.rb +51 -32
  51. data/lib/bundler/fetcher.rb +44 -30
  52. data/lib/bundler/fetcher/base.rb +3 -2
  53. data/lib/bundler/fetcher/compact_index.rb +98 -0
  54. data/lib/bundler/fetcher/dependency.rb +36 -36
  55. data/lib/bundler/fetcher/downloader.rb +14 -8
  56. data/lib/bundler/fetcher/index.rb +28 -5
  57. data/lib/bundler/friendly_errors.rb +93 -85
  58. data/lib/bundler/gem_helper.rb +20 -21
  59. data/lib/bundler/gem_helpers.rb +9 -2
  60. data/lib/bundler/gem_remote_fetcher.rb +1 -0
  61. data/lib/bundler/gem_tasks.rb +1 -0
  62. data/lib/bundler/graph.rb +16 -17
  63. data/lib/bundler/index.rb +4 -6
  64. data/lib/bundler/injector.rb +1 -0
  65. data/lib/bundler/inline.rb +8 -2
  66. data/lib/bundler/installer.rb +4 -4
  67. data/lib/bundler/installer/gem_installer.rb +1 -0
  68. data/lib/bundler/installer/parallel_installer.rb +3 -2
  69. data/lib/bundler/installer/standalone.rb +5 -1
  70. data/lib/bundler/lazy_specification.rb +5 -2
  71. data/lib/bundler/lockfile_parser.rb +22 -15
  72. data/lib/bundler/match_platform.rb +1 -0
  73. data/lib/bundler/mirror.rb +218 -0
  74. data/lib/bundler/path_preserver.rb +12 -0
  75. data/lib/bundler/psyched_yaml.rb +1 -0
  76. data/lib/bundler/remote_specification.rb +4 -1
  77. data/lib/bundler/resolver.rb +17 -16
  78. data/lib/bundler/retry.rb +1 -0
  79. data/lib/bundler/ruby_dsl.rb +8 -2
  80. data/lib/bundler/ruby_version.rb +58 -61
  81. data/lib/bundler/rubygems_ext.rb +4 -3
  82. data/lib/bundler/rubygems_gem_installer.rb +1 -0
  83. data/lib/bundler/rubygems_integration.rb +9 -14
  84. data/lib/bundler/runtime.rb +17 -22
  85. data/lib/bundler/settings.rb +17 -21
  86. data/lib/bundler/setup.rb +1 -0
  87. data/lib/bundler/shared_helpers.rb +47 -17
  88. data/lib/bundler/similarity_detector.rb +1 -0
  89. data/lib/bundler/source.rb +2 -1
  90. data/lib/bundler/source/git.rb +2 -1
  91. data/lib/bundler/source/git/git_proxy.rb +33 -7
  92. data/lib/bundler/source/path.rb +17 -10
  93. data/lib/bundler/source/path/installer.rb +1 -0
  94. data/lib/bundler/source/rubygems.rb +4 -3
  95. data/lib/bundler/source/rubygems/remote.rb +16 -0
  96. data/lib/bundler/source_list.rb +1 -0
  97. data/lib/bundler/spec_set.rb +1 -0
  98. data/lib/bundler/ssl_certs/certificate_manager.rb +1 -0
  99. data/lib/bundler/stub_specification.rb +1 -0
  100. data/lib/bundler/templates/Executable +1 -0
  101. data/lib/bundler/templates/Gemfile +1 -0
  102. data/lib/bundler/templates/newgem/.travis.yml.tt +1 -0
  103. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -2
  104. data/lib/bundler/ui.rb +1 -0
  105. data/lib/bundler/ui/rg_proxy.rb +1 -0
  106. data/lib/bundler/ui/shell.rb +2 -1
  107. data/lib/bundler/ui/silent.rb +1 -0
  108. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +78 -0
  109. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +97 -0
  110. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +55 -0
  111. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +3 -0
  112. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +4 -0
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +13 -0
  114. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +5 -0
  115. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  116. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +2 -1
  117. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +37 -14
  118. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -1
  119. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +7 -7
  120. data/lib/bundler/vendored_molinillo.rb +1 -0
  121. data/lib/bundler/vendored_persistent.rb +1 -0
  122. data/lib/bundler/vendored_thor.rb +1 -0
  123. data/lib/bundler/version.rb +6 -1
  124. data/lib/bundler/vlad.rb +1 -0
  125. data/lib/bundler/worker.rb +12 -2
  126. data/man/bundle-config.ronn +6 -0
  127. data/man/bundle-gem.ronn +5 -5
  128. metadata +14 -6
  129. data/lib/bundler/gem_path_manipulation.rb +0 -8
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/lockfile_parser"
2
3
  require "digest/sha1"
3
4
  require "set"
@@ -53,14 +54,16 @@ module Bundler
53
54
  @specs = nil
54
55
  @ruby_version = ruby_version
55
56
 
56
- @lockfile_contents = ""
57
+ @lockfile_contents = String.new
57
58
  @locked_bundler_version = nil
59
+ @locked_ruby_version = nil
58
60
 
59
61
  if lockfile && File.exist?(lockfile)
60
62
  @lockfile_contents = Bundler.read_file(lockfile)
61
63
  locked = LockfileParser.new(@lockfile_contents)
62
64
  @platforms = locked.platforms
63
65
  @locked_bundler_version = locked.bundler_version
66
+ @locked_ruby_version = locked.ruby_version
64
67
 
65
68
  if unlock != true
66
69
  @locked_deps = locked.dependencies
@@ -194,8 +197,7 @@ module Bundler
194
197
  last_resolve
195
198
  else
196
199
  # Run a resolve against the locally available gems
197
- requested_ruby_version = ruby_version.version if ruby_version
198
- last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, requested_ruby_version)
200
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, ruby_version)
199
201
  end
200
202
  end
201
203
  end
@@ -269,9 +271,7 @@ module Bundler
269
271
  end
270
272
  end
271
273
 
272
- # Returns the version of Bundler that is creating or has created
273
- # Gemfile.lock. Used in #to_lock.
274
- def lock_version
274
+ def locked_bundler_version
275
275
  if @locked_bundler_version && @locked_bundler_version < Gem::Version.new(Bundler::VERSION)
276
276
  new_version = Bundler::VERSION
277
277
  end
@@ -279,8 +279,28 @@ module Bundler
279
279
  new_version || @locked_bundler_version || Bundler::VERSION
280
280
  end
281
281
 
282
+ def locked_ruby_version
283
+ if @unlock[:ruby]
284
+ if ruby_version && !@locked_ruby_version
285
+ return Bundler::RubyVersion.system
286
+ elsif ruby_version && @locked_ruby_version
287
+ return Bundler::RubyVersion.system
288
+ elsif !ruby_version && @locked_ruby_version
289
+ return nil
290
+ end
291
+ else
292
+ if ruby_version && !@locked_ruby_version
293
+ return Bundler::RubyVersion.system
294
+ elsif ruby_version && @locked_ruby_version
295
+ return @locked_ruby_version
296
+ elsif !ruby_version && @locked_ruby_version
297
+ return @locked_ruby_version
298
+ end
299
+ end
300
+ end
301
+
282
302
  def to_lock
283
- out = ""
303
+ out = String.new
284
304
 
285
305
  sources.lock_sources.each do |source|
286
306
  # Add the source header
@@ -315,20 +335,26 @@ module Bundler
315
335
  handled << dep.name
316
336
  end
317
337
 
338
+ if locked_ruby_version
339
+ out << "\nRUBY VERSION\n"
340
+ out << " #{locked_ruby_version}\n"
341
+ end
342
+
318
343
  # Record the version of Bundler that was used to create the lockfile
319
344
  out << "\nBUNDLED WITH\n"
320
- out << " #{lock_version}\n"
345
+ out << " #{locked_bundler_version}\n"
321
346
 
322
347
  out
323
348
  end
324
349
 
325
350
  def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
326
- msg = "You are trying to install in deployment mode after changing\n" \
327
- "your Gemfile. Run `bundle install` elsewhere and add the\n" \
328
- "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
351
+ msg = String.new
352
+ msg << "You are trying to install in deployment mode after changing\n" \
353
+ "your Gemfile. Run `bundle install` elsewhere and add the\n" \
354
+ "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
329
355
 
330
356
  unless explicit_flag
331
- msg += "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
357
+ msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
332
358
  "freeze \nby running `bundle install --no-deployment`."
333
359
  end
334
360
 
@@ -381,7 +407,7 @@ module Bundler
381
407
  def validate_ruby!
382
408
  return unless ruby_version
383
409
 
384
- if diff = ruby_version.diff(Bundler.ruby_version)
410
+ if diff = ruby_version.diff(Bundler::RubyVersion.system)
385
411
  problem, expected, actual = diff
386
412
 
387
413
  msg = case problem
@@ -390,7 +416,7 @@ module Bundler
390
416
  when :version
391
417
  "Your Ruby version is #{actual}, but your Gemfile specified #{expected}"
392
418
  when :engine_version
393
- "Your #{Bundler.ruby_version.engine} version is #{actual}, but your Gemfile specified #{ruby_version.engine} #{expected}"
419
+ "Your #{Bundler::RubyVersion.system.engine} version is #{actual}, but your Gemfile specified #{ruby_version.engine} #{expected}"
394
420
  when :patchlevel
395
421
  if !expected.is_a?(String)
396
422
  "The Ruby patchlevel in your Gemfile must be a string"
@@ -612,7 +638,7 @@ module Bundler
612
638
  dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
613
639
  next unless remote || dep.current_platform?
614
640
  dep.gem_platforms(@platforms).each do |p|
615
- deps << DepProxy.new(dep, p) if remote || p == generic(Gem::Platform.local)
641
+ deps << DepProxy.new(dep, p) if remote || p == generic_local_platform
616
642
  end
617
643
  end
618
644
  deps
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class DepProxy
3
4
  attr_reader :__platform, :dep
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "rubygems/dependency"
2
3
  require "bundler/shared_helpers"
3
4
  require "bundler/rubygems_ext"
@@ -54,6 +55,15 @@ module Bundler
54
55
  :x64_mingw_23 => Gem::Platform::X64_MINGW
55
56
  }.freeze
56
57
 
58
+ REVERSE_PLATFORM_MAP = {}.tap do |reverse_platform_map|
59
+ PLATFORM_MAP.each do |key, value|
60
+ reverse_platform_map[value] ||= []
61
+ reverse_platform_map[value] << key
62
+ end
63
+
64
+ reverse_platform_map.each {|_, platforms| platforms.freeze }
65
+ end.freeze
66
+
57
67
  def initialize(name, version, options = {}, &blk)
58
68
  type = options["type"] || :runtime
59
69
  super(name, version, type)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class Deployment
3
4
  def self.define_task(context, task_method = :task, opts = {})
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  if defined? ::Deprecate
3
4
  Deprecate = ::Deprecate
data/lib/bundler/dsl.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/dependency"
2
3
  require "bundler/ruby_dsl"
3
4
 
@@ -28,10 +29,12 @@ module Bundler
28
29
  @env = nil
29
30
  @ruby_version = nil
30
31
  @gemspecs = []
32
+ @gemfile = nil
31
33
  add_git_sources
32
34
  end
33
35
 
34
36
  def eval_gemfile(gemfile, contents = nil)
37
+ @gemfile = Pathname.new(gemfile)
35
38
  contents ||= Bundler.read_file(gemfile.to_s)
36
39
  instance_eval(contents, gemfile.to_s, 1)
37
40
  rescue Exception => e
@@ -47,7 +50,7 @@ module Bundler
47
50
  glob = opts && opts[:glob]
48
51
  name = opts && opts[:name] || "{,*}"
49
52
  development_group = opts && opts[:development_group] || :development
50
- expanded_path = File.expand_path(path, Bundler.default_gemfile.dirname)
53
+ expanded_path = gemfile_root.join(path)
51
54
 
52
55
  gemspecs = Dir[File.join(expanded_path, "#{name}.gemspec")]
53
56
 
@@ -60,7 +63,8 @@ module Bundler
60
63
  "#{file}. Make sure you can build the gem, then try again"
61
64
  end
62
65
 
63
- gem spec.name, :path => path, :glob => glob
66
+ gem_platforms = Bundler::Dependency::REVERSE_PLATFORM_MAP[Bundler::GemHelpers.generic_local_platform]
67
+ gem spec.name, :path => path, :glob => glob, :platforms => gem_platforms
64
68
 
65
69
  group(development_group) do
66
70
  spec.development_dependencies.each do |dep|
@@ -90,9 +94,8 @@ module Bundler
90
94
  if current.requirement != dep.requirement
91
95
  if current.type == :development
92
96
  @dependencies.delete current
93
- elsif dep.type == :development
94
- return
95
97
  else
98
+ return if dep.type == :development
96
99
  raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
97
100
  "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})"
98
101
  end
@@ -106,9 +109,8 @@ module Bundler
106
109
  if current.source != dep.source
107
110
  if current.type == :development
108
111
  @dependencies.delete current
109
- elsif dep.type == :development
110
- return
111
112
  else
113
+ return if dep.type == :development
112
114
  raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
113
115
  "You specified that #{dep.name} (#{dep.requirement}) should come from " \
114
116
  "#{current.source || "an unspecified source"} and #{dep.source}\n"
@@ -143,7 +145,9 @@ module Bundler
143
145
  end
144
146
 
145
147
  def path(path, options = {}, &blk)
146
- with_source(@sources.add_path_source(normalize_hash(options).merge("path" => Pathname.new(path))), &blk)
148
+ source_options = normalize_hash(options).merge("path" => Pathname.new(path), "root_path" => gemfile_root)
149
+ source = @sources.add_path_source(source_options)
150
+ with_source(source, &blk)
147
151
  end
148
152
 
149
153
  def git(uri, options = {}, &blk)
@@ -342,7 +346,8 @@ module Bundler
342
346
  def validate_keys(command, opts, valid_keys)
343
347
  invalid_keys = opts.keys - valid_keys
344
348
  if invalid_keys.any?
345
- message = "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} "
349
+ message = String.new
350
+ message << "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} "
346
351
  message << if invalid_keys.size > 1
347
352
  "as options for #{command}, but they are invalid."
348
353
  else
@@ -447,7 +452,7 @@ module Bundler
447
452
  @to_s ||= begin
448
453
  trace_line, description = parse_line_number_from_description
449
454
 
450
- m = "\n[!] "
455
+ m = String.new("\n[!] ")
451
456
  m << description
452
457
  m << ". Bundler cannot continue.\n"
453
458
 
@@ -486,5 +491,10 @@ module Bundler
486
491
  [trace_line, description]
487
492
  end
488
493
  end
494
+
495
+ def gemfile_root
496
+ @gemfile ||= Bundler.default_gemfile
497
+ @gemfile.dirname
498
+ end
489
499
  end
490
500
  end
@@ -1,16 +1,20 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  # used for Creating Specifications from the Gemcutter Endpoint
3
4
  class EndpointSpecification < Gem::Specification
5
+ ILLFORMED_MESSAGE = 'Ill-formed requirement ["#<YAML::Syck::DefaultKey'.freeze
4
6
  include MatchPlatform
5
7
 
6
- attr_reader :name, :version, :platform, :dependencies
8
+ attr_reader :name, :version, :platform, :dependencies, :required_rubygems_version, :required_ruby_version, :checksum
7
9
  attr_accessor :source, :remote
8
10
 
9
- def initialize(name, version, platform, dependencies)
11
+ def initialize(name, version, platform, dependencies, metadata = nil)
10
12
  @name = name
11
- @version = version
13
+ @version = Gem::Version.create version
12
14
  @platform = platform
13
- @dependencies = dependencies
15
+ @dependencies = dependencies.map {|dep, reqs| build_dependency(dep, reqs) }
16
+
17
+ parse_metadata(metadata)
14
18
  end
15
19
 
16
20
  def fetch_platform
@@ -80,10 +84,9 @@ module Bundler
80
84
  end
81
85
 
82
86
  def _local_specification
83
- if @loaded_from && File.exist?(local_specification_path)
84
- eval(File.read(local_specification_path)).tap do |spec|
85
- spec.loaded_from = @loaded_from
86
- end
87
+ return unless @loaded_from && File.exist?(local_specification_path)
88
+ eval(File.read(local_specification_path)).tap do |spec|
89
+ spec.loaded_from = @loaded_from
87
90
  end
88
91
  end
89
92
 
@@ -96,5 +99,31 @@ module Bundler
96
99
  def local_specification_path
97
100
  "#{base_dir}/specifications/#{full_name}.gemspec"
98
101
  end
102
+
103
+ def parse_metadata(data)
104
+ return unless data
105
+ data.each do |k, v|
106
+ next unless v
107
+ case k.to_s
108
+ when "checksum"
109
+ @checksum = v.last
110
+ when "rubygems"
111
+ @required_rubygems_version = Gem::Requirement.new(v)
112
+ when "ruby"
113
+ @required_ruby_version = Gem::Requirement.new(v)
114
+ end
115
+ end
116
+ end
117
+
118
+ def build_dependency(name, *requirements)
119
+ Gem::Dependency.new(name, *requirements)
120
+ rescue ArgumentError => e
121
+ raise unless e.message.include?(ILLFORMED_MESSAGE)
122
+ puts # we shouldn't print the error message on the "fetching info" status line
123
+ raise GemspecError,
124
+ "Unfortunately, the gem #{name} (#{version}) has an invalid " \
125
+ "gemspec.\nPlease ask the gem author to yank the bad version to fix " \
126
+ "this issue. For more information, see http://bit.ly/syck-defaultkey."
127
+ end
99
128
  end
100
129
  end
data/lib/bundler/env.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/rubygems_integration"
2
3
  require "bundler/source/git/git_proxy"
3
4
 
@@ -11,7 +12,7 @@ module Bundler
11
12
  print_gemfile = options.delete(:print_gemfile)
12
13
  print_gemspecs = options.delete(:print_gemspecs)
13
14
 
14
- out = "Environment\n\n"
15
+ out = String.new("Environment\n\n")
15
16
  out << " Bundler #{Bundler::VERSION}\n"
16
17
  out << " Rubygems #{Gem::VERSION}\n"
17
18
  out << " Ruby #{ruby_version}"
@@ -43,7 +44,7 @@ module Bundler
43
44
  if print_gemspecs
44
45
  dsl = Dsl.new.tap {|d| d.eval_gemfile(Bundler.default_gemfile) }
45
46
  dsl.gemspecs.each do |gs|
46
- out << "\n#{Pathname.new(gs).basename}:"
47
+ out << "\n#{Pathname.new(gs).basename}"
47
48
  out << "\n\n " << read_file(gs).gsub(/\n/, "\n ") << "\n"
48
49
  end
49
50
  end
@@ -62,7 +63,7 @@ module Bundler
62
63
  end
63
64
 
64
65
  def ruby_version
65
- str = "#{RUBY_VERSION}"
66
+ str = String.new("#{RUBY_VERSION}")
66
67
  if RUBY_VERSION < "1.9"
67
68
  str << " (#{RUBY_RELEASE_DATE}"
68
69
  str << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class Environment
3
4
  attr_reader :root
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundler
2
3
  class BundlerError < StandardError
3
4
  def self.status_code(code)
@@ -5,14 +6,27 @@ module Bundler
5
6
  end
6
7
  end
7
8
 
8
- class GemfileNotFound < BundlerError; status_code(10); end
9
- class GemNotFound < BundlerError; status_code(7); end
10
9
  class GemfileError < BundlerError; status_code(4); end
11
10
  class InstallError < BundlerError; status_code(5); end
11
+
12
+ # Internal error, should be rescued
13
+ class VersionConflict < BundlerError
14
+ attr_reader :conflicts
15
+
16
+ def initialize(conflicts, msg = nil)
17
+ super(msg)
18
+ @conflicts = conflicts
19
+ end
20
+
21
+ status_code(6)
22
+ end
23
+
24
+ class GemNotFound < BundlerError; status_code(7); end
12
25
  class InstallHookError < BundlerError; status_code(8); end
13
- class PathError < BundlerError; status_code(13); end
26
+ class GemfileNotFound < BundlerError; status_code(10); end
14
27
  class GitError < BundlerError; status_code(11); end
15
28
  class DeprecatedError < BundlerError; status_code(12); end
29
+ class PathError < BundlerError; status_code(13); end
16
30
  class GemspecError < BundlerError; status_code(14); end
17
31
  class InvalidOption < BundlerError; status_code(15); end
18
32
  class ProductionError < BundlerError; status_code(16); end
@@ -25,42 +39,22 @@ module Bundler
25
39
  class GemfileEvalError < GemfileError; end
26
40
  class MarshalError < StandardError; end
27
41
 
28
- # Internal errors, should be rescued
29
- class VersionConflict < BundlerError
30
- attr_reader :conflicts
31
-
32
- def initialize(conflicts, msg = nil)
33
- super(msg)
34
- @conflicts = conflicts
35
- end
36
-
37
- status_code(6)
38
- end
39
-
40
- class GemRequireError < BundlerError
41
- attr_reader :orig_exception
42
-
43
- def initialize(orig_exception, msg)
44
- super(msg)
45
- @orig_exception = orig_exception
46
- end
47
-
48
- status_code(24)
49
- end
50
-
51
42
  class PermissionError < BundlerError
52
43
  def initialize(path, permission_type = :write)
53
44
  @path = path
54
45
  @permission_type = permission_type
55
46
  end
56
47
 
57
- def message
58
- action = case @permission_type
59
- when :read then "read from"
60
- when :write then "write to"
61
- when :executable, :exec then "execute"
62
- else @permission_type.to_s
48
+ def action
49
+ case @permission_type
50
+ when :read then "read from"
51
+ when :write then "write to"
52
+ when :executable, :exec then "execute"
53
+ else @permission_type.to_s
63
54
  end
55
+ end
56
+
57
+ def message
64
58
  "There was an error while trying to #{action} `#{@path}`. " \
65
59
  "It is likely that you need to grant #{@permission_type} permissions " \
66
60
  "for that path."
@@ -69,6 +63,21 @@ module Bundler
69
63
  status_code(23)
70
64
  end
71
65
 
66
+ class GemRequireError < BundlerError
67
+ attr_reader :orig_exception
68
+
69
+ def initialize(orig_exception, msg)
70
+ full_message = msg + "\nGem Load Error is: #{orig_exception.message}\n"\
71
+ "Backtrace for gem load error is:\n"\
72
+ "#{orig_exception.backtrace.join("\n")}\n"\
73
+ "Bundler Error Backtrace:\n"
74
+ super(full_message)
75
+ @orig_exception = orig_exception
76
+ end
77
+
78
+ status_code(24)
79
+ end
80
+
72
81
  class YamlSyntaxError < BundlerError
73
82
  attr_reader :orig_exception
74
83
 
@@ -79,4 +88,14 @@ module Bundler
79
88
 
80
89
  status_code(25)
81
90
  end
91
+
92
+ class TemporaryResourceError < PermissionError
93
+ def message
94
+ "There was an error while trying to #{action} `#{@path}`. " \
95
+ "Some resource was temporarily unavailable. It's suggested that you try" \
96
+ "the operation again."
97
+ end
98
+
99
+ status_code(26)
100
+ end
82
101
  end