bundler 2.7.1 → 4.0.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1001 -902
  3. data/README.md +4 -4
  4. data/bundler.gemspec +3 -3
  5. data/lib/bundler/build_metadata.rb +2 -2
  6. data/lib/bundler/capistrano.rb +1 -19
  7. data/lib/bundler/checksum.rb +6 -0
  8. data/lib/bundler/cli/cache.rb +1 -12
  9. data/lib/bundler/cli/common.rb +21 -4
  10. data/lib/bundler/cli/config.rb +1 -2
  11. data/lib/bundler/cli/console.rb +5 -0
  12. data/lib/bundler/cli/exec.rb +29 -4
  13. data/lib/bundler/cli/gem.rb +19 -33
  14. data/lib/bundler/cli/install.rb +7 -84
  15. data/lib/bundler/cli/issue.rb +2 -2
  16. data/lib/bundler/cli/list.rb +33 -2
  17. data/lib/bundler/cli/lock.rb +5 -5
  18. data/lib/bundler/cli/plugin.rb +5 -1
  19. data/lib/bundler/cli/show.rb +3 -7
  20. data/lib/bundler/cli/update.rb +3 -3
  21. data/lib/bundler/cli.rb +97 -95
  22. data/lib/bundler/compact_index_client.rb +0 -1
  23. data/lib/bundler/current_ruby.rb +3 -15
  24. data/lib/bundler/definition.rb +122 -95
  25. data/lib/bundler/deployment.rb +1 -64
  26. data/lib/bundler/digest.rb +1 -1
  27. data/lib/bundler/dsl.rb +14 -36
  28. data/lib/bundler/endpoint_specification.rb +0 -22
  29. data/lib/bundler/errors.rb +1 -5
  30. data/lib/bundler/feature_flag.rb +0 -33
  31. data/lib/bundler/fetcher/compact_index.rb +1 -1
  32. data/lib/bundler/friendly_errors.rb +2 -2
  33. data/lib/bundler/index.rb +0 -7
  34. data/lib/bundler/inline.rb +1 -1
  35. data/lib/bundler/installer/gem_installer.rb +0 -11
  36. data/lib/bundler/installer.rb +0 -6
  37. data/lib/bundler/lockfile_generator.rb +1 -1
  38. data/lib/bundler/lockfile_parser.rb +2 -12
  39. data/lib/bundler/man/bundle-add.1 +1 -1
  40. data/lib/bundler/man/bundle-binstubs.1 +3 -6
  41. data/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
  42. data/lib/bundler/man/bundle-cache.1 +2 -14
  43. data/lib/bundler/man/bundle-cache.1.ronn +1 -14
  44. data/lib/bundler/man/bundle-check.1 +2 -5
  45. data/lib/bundler/man/bundle-check.1.ronn +0 -5
  46. data/lib/bundler/man/bundle-clean.1 +1 -1
  47. data/lib/bundler/man/bundle-config.1 +36 -46
  48. data/lib/bundler/man/bundle-config.1.ronn +69 -75
  49. data/lib/bundler/man/bundle-console.1 +1 -1
  50. data/lib/bundler/man/bundle-doctor.1 +4 -4
  51. data/lib/bundler/man/bundle-doctor.1.ronn +4 -4
  52. data/lib/bundler/man/bundle-env.1 +1 -1
  53. data/lib/bundler/man/bundle-exec.1 +2 -5
  54. data/lib/bundler/man/bundle-exec.1.ronn +1 -5
  55. data/lib/bundler/man/bundle-fund.1 +1 -1
  56. data/lib/bundler/man/bundle-gem.1 +3 -6
  57. data/lib/bundler/man/bundle-gem.1.ronn +2 -5
  58. data/lib/bundler/man/bundle-help.1 +1 -1
  59. data/lib/bundler/man/bundle-info.1 +1 -1
  60. data/lib/bundler/man/bundle-init.1 +1 -1
  61. data/lib/bundler/man/bundle-install.1 +8 -59
  62. data/lib/bundler/man/bundle-install.1.ronn +12 -107
  63. data/lib/bundler/man/bundle-issue.1 +1 -1
  64. data/lib/bundler/man/bundle-licenses.1 +1 -1
  65. data/lib/bundler/man/bundle-list.1 +6 -1
  66. data/lib/bundler/man/bundle-list.1.ronn +5 -0
  67. data/lib/bundler/man/bundle-lock.1 +1 -1
  68. data/lib/bundler/man/bundle-open.1 +1 -1
  69. data/lib/bundler/man/bundle-outdated.1 +1 -1
  70. data/lib/bundler/man/bundle-platform.1 +1 -1
  71. data/lib/bundler/man/bundle-plugin.1 +33 -15
  72. data/lib/bundler/man/bundle-plugin.1.ronn +36 -15
  73. data/lib/bundler/man/bundle-pristine.1 +1 -1
  74. data/lib/bundler/man/bundle-remove.1 +2 -8
  75. data/lib/bundler/man/bundle-remove.1.ronn +1 -8
  76. data/lib/bundler/man/bundle-show.1 +2 -5
  77. data/lib/bundler/man/bundle-show.1.ronn +0 -4
  78. data/lib/bundler/man/bundle-update.1 +1 -1
  79. data/lib/bundler/man/bundle-version.1 +1 -1
  80. data/lib/bundler/man/bundle.1 +1 -10
  81. data/lib/bundler/man/bundle.1.ronn +0 -9
  82. data/lib/bundler/man/gemfile.5 +1 -1
  83. data/lib/bundler/man/index.txt +0 -2
  84. data/lib/bundler/materialization.rb +1 -1
  85. data/lib/bundler/plugin/installer.rb +0 -10
  86. data/lib/bundler/plugin/source_list.rb +1 -1
  87. data/lib/bundler/plugin.rb +1 -1
  88. data/lib/bundler/resolver/package.rb +1 -0
  89. data/lib/bundler/resolver.rb +1 -1
  90. data/lib/bundler/ruby_dsl.rb +2 -0
  91. data/lib/bundler/ruby_version.rb +1 -3
  92. data/lib/bundler/rubygems_ext.rb +1 -1
  93. data/lib/bundler/rubygems_gem_installer.rb +1 -1
  94. data/lib/bundler/rubygems_integration.rb +1 -5
  95. data/lib/bundler/self_manager.rb +1 -1
  96. data/lib/bundler/settings.rb +8 -27
  97. data/lib/bundler/shared_helpers.rb +8 -20
  98. data/lib/bundler/source/gemspec.rb +4 -0
  99. data/lib/bundler/source/git/git_proxy.rb +3 -11
  100. data/lib/bundler/source/git.rb +2 -3
  101. data/lib/bundler/source/path.rb +5 -7
  102. data/lib/bundler/source/rubygems.rb +11 -17
  103. data/lib/bundler/source.rb +1 -1
  104. data/lib/bundler/source_list.rb +4 -45
  105. data/lib/bundler/source_map.rb +2 -5
  106. data/lib/bundler/spec_set.rb +6 -15
  107. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
  108. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  109. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  110. data/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  111. data/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  112. data/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  113. data/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  114. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +6 -0
  115. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  116. data/lib/bundler/templates/newgem/newgem.gemspec.tt +7 -4
  117. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
  118. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  119. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
  120. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
  121. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +5 -2
  122. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +42 -6
  123. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +1 -1
  124. data/lib/bundler/vendor/thor/lib/thor/runner.rb +2 -2
  125. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +3 -7
  126. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  127. data/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
  128. data/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
  129. data/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
  130. data/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
  131. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  132. data/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
  133. data/lib/bundler/version.rb +1 -1
  134. data/lib/bundler/vlad.rb +1 -14
  135. data/lib/bundler.rb +6 -28
  136. metadata +9 -13
  137. data/lib/bundler/cli/inject.rb +0 -60
  138. data/lib/bundler/cli/viz.rb +0 -31
  139. data/lib/bundler/graph.rb +0 -152
  140. data/lib/bundler/man/bundle-inject.1 +0 -31
  141. data/lib/bundler/man/bundle-inject.1.ronn +0 -32
  142. data/lib/bundler/man/bundle-viz.1 +0 -30
  143. data/lib/bundler/man/bundle-viz.1.ronn +0 -36
  144. data/lib/bundler/similarity_detector.rb +0 -63
@@ -181,7 +181,7 @@ end
181
181
  #
182
182
  module Bundler::FileUtils
183
183
  # The version number.
184
- VERSION = "1.7.3"
184
+ VERSION = "1.8.0"
185
185
 
186
186
  def self.private_module_function(name) #:nodoc:
187
187
  module_function name
@@ -706,11 +706,12 @@ module Bundler::FileUtils
706
706
  #
707
707
  def ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
708
708
  if relative
709
- return ln_sr(src, dest, force: force, noop: noop, verbose: verbose)
709
+ return ln_sr(src, dest, force: force, target_directory: target_directory, noop: noop, verbose: verbose)
710
710
  end
711
- fu_output_message "ln -s#{force ? 'f' : ''} #{[src,dest].flatten.join ' '}" if verbose
711
+ fu_output_message "ln -s#{force ? 'f' : ''}#{
712
+ target_directory ? '' : 'T'} #{[src,dest].flatten.join ' '}" if verbose
712
713
  return if noop
713
- fu_each_src_dest0(src, dest) do |s,d|
714
+ fu_each_src_dest0(src, dest, target_directory) do |s,d|
714
715
  remove_file d, true if force
715
716
  File.symlink s, d
716
717
  end
@@ -730,42 +731,37 @@ module Bundler::FileUtils
730
731
  # Like Bundler::FileUtils.ln_s, but create links relative to +dest+.
731
732
  #
732
733
  def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)
733
- options = "#{force ? 'f' : ''}#{target_directory ? '' : 'T'}"
734
- dest = File.path(dest)
735
- srcs = Array(src)
736
- link = proc do |s, target_dir_p = true|
737
- s = File.path(s)
738
- if target_dir_p
739
- d = File.join(destdirs = dest, File.basename(s))
734
+ cmd = "ln -s#{force ? 'f' : ''}#{target_directory ? '' : 'T'}" if verbose
735
+ fu_each_src_dest0(src, dest, target_directory) do |s,d|
736
+ if target_directory
737
+ parent = File.dirname(d)
738
+ destdirs = fu_split_path(parent)
739
+ real_ddirs = fu_split_path(File.realpath(parent))
740
740
  else
741
- destdirs = File.dirname(d = dest)
741
+ destdirs ||= fu_split_path(dest)
742
+ real_ddirs ||= fu_split_path(File.realdirpath(dest))
742
743
  end
743
- destdirs = fu_split_path(File.realpath(destdirs))
744
- if fu_starting_path?(s)
745
- srcdirs = fu_split_path((File.realdirpath(s) rescue File.expand_path(s)))
746
- base = fu_relative_components_from(srcdirs, destdirs)
747
- s = File.join(*base)
744
+ srcdirs = fu_split_path(s)
745
+ i = fu_common_components(srcdirs, destdirs)
746
+ n = destdirs.size - i
747
+ n -= 1 unless target_directory
748
+ link1 = fu_clean_components(*Array.new([n, 0].max, '..'), *srcdirs[i..-1])
749
+ begin
750
+ real_sdirs = fu_split_path(File.realdirpath(s)) rescue nil
751
+ rescue
748
752
  else
749
- srcdirs = fu_clean_components(*fu_split_path(s))
750
- base = fu_relative_components_from(fu_split_path(Dir.pwd), destdirs)
751
- while srcdirs.first&. == ".." and base.last&.!=("..") and !fu_starting_path?(base.last)
752
- srcdirs.shift
753
- base.pop
754
- end
755
- s = File.join(*base, *srcdirs)
753
+ i = fu_common_components(real_sdirs, real_ddirs)
754
+ n = real_ddirs.size - i
755
+ n -= 1 unless target_directory
756
+ link2 = fu_clean_components(*Array.new([n, 0].max, '..'), *real_sdirs[i..-1])
757
+ link1 = link2 if link1.size > link2.size
756
758
  end
757
- fu_output_message "ln -s#{options} #{s} #{d}" if verbose
759
+ s = File.join(link1)
760
+ fu_output_message [cmd, s, d].flatten.join(' ') if verbose
758
761
  next if noop
759
762
  remove_file d, true if force
760
763
  File.symlink s, d
761
764
  end
762
- case srcs.size
763
- when 0
764
- when 1
765
- link[srcs[0], target_directory && File.directory?(dest)]
766
- else
767
- srcs.each(&link)
768
- end
769
765
  end
770
766
  module_function :ln_sr
771
767
 
@@ -800,13 +796,13 @@ module Bundler::FileUtils
800
796
  # File.file?('dest1/dir1/t2.txt') # => true
801
797
  # File.file?('dest1/dir1/t3.txt') # => true
802
798
  #
803
- # Keyword arguments:
799
+ # Optional arguments:
804
800
  #
805
- # - <tt>dereference_root: true</tt> - dereferences +src+ if it is a symbolic link.
806
- # - <tt>remove_destination: true</tt> - removes +dest+ before creating links.
801
+ # - +dereference_root+ - dereferences +src+ if it is a symbolic link (+false+ by default).
802
+ # - +remove_destination+ - removes +dest+ before creating links (+false+ by default).
807
803
  #
808
804
  # Raises an exception if +dest+ is the path to an existing file or directory
809
- # and keyword argument <tt>remove_destination: true</tt> is not given.
805
+ # and optional argument +remove_destination+ is not given.
810
806
  #
811
807
  # Related: Bundler::FileUtils.ln (has different options).
812
808
  #
@@ -1029,12 +1025,12 @@ module Bundler::FileUtils
1029
1025
  # directories, and symbolic links;
1030
1026
  # other file types (FIFO streams, device files, etc.) are not supported.
1031
1027
  #
1032
- # Keyword arguments:
1028
+ # Optional arguments:
1033
1029
  #
1034
- # - <tt>dereference_root: true</tt> - if +src+ is a symbolic link,
1035
- # follows the link.
1036
- # - <tt>preserve: true</tt> - preserves file times.
1037
- # - <tt>remove_destination: true</tt> - removes +dest+ before copying files.
1030
+ # - +dereference_root+ - if +src+ is a symbolic link,
1031
+ # follows the link (+false+ by default).
1032
+ # - +preserve+ - preserves file times (+false+ by default).
1033
+ # - +remove_destination+ - removes +dest+ before copying files (+false+ by default).
1038
1034
  #
1039
1035
  # Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
1040
1036
  #
@@ -1065,12 +1061,12 @@ module Bundler::FileUtils
1065
1061
  # Bundler::FileUtils.copy_file('src0.txt', 'dest0.txt')
1066
1062
  # File.file?('dest0.txt') # => true
1067
1063
  #
1068
- # Keyword arguments:
1064
+ # Optional arguments:
1069
1065
  #
1070
- # - <tt>dereference: false</tt> - if +src+ is a symbolic link,
1071
- # does not follow the link.
1072
- # - <tt>preserve: true</tt> - preserves file times.
1073
- # - <tt>remove_destination: true</tt> - removes +dest+ before copying files.
1066
+ # - +dereference+ - if +src+ is a symbolic link,
1067
+ # follows the link (+true+ by default).
1068
+ # - +preserve+ - preserves file times (+false+ by default).
1069
+ # - +remove_destination+ - removes +dest+ before copying files (+false+ by default).
1074
1070
  #
1075
1071
  # Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
1076
1072
  #
@@ -1491,7 +1487,8 @@ module Bundler::FileUtils
1491
1487
  # Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
1492
1488
  #
1493
1489
  def remove_dir(path, force = false)
1494
- remove_entry path, force # FIXME?? check if it is a directory
1490
+ raise Errno::ENOTDIR, path unless force or File.directory?(path)
1491
+ remove_entry path, force
1495
1492
  end
1496
1493
  module_function :remove_dir
1497
1494
 
@@ -2475,6 +2472,10 @@ module Bundler::FileUtils
2475
2472
 
2476
2473
  def fu_each_src_dest0(src, dest, target_directory = true) #:nodoc:
2477
2474
  if tmp = Array.try_convert(src)
2475
+ unless target_directory or tmp.size <= 1
2476
+ tmp = tmp.map {|f| File.path(f)} # A workaround for RBS
2477
+ raise ArgumentError, "extra target #{tmp}"
2478
+ end
2478
2479
  tmp.each do |s|
2479
2480
  s = File.path(s)
2480
2481
  yield s, (target_directory ? File.join(dest, File.basename(s)) : dest)
@@ -2509,7 +2510,11 @@ module Bundler::FileUtils
2509
2510
  path = File.path(path)
2510
2511
  list = []
2511
2512
  until (parent, base = File.split(path); parent == path or parent == ".")
2512
- list << base
2513
+ if base != '..' and list.last == '..' and !(fu_have_symlink? && File.symlink?(path))
2514
+ list.pop
2515
+ else
2516
+ list << base
2517
+ end
2513
2518
  path = parent
2514
2519
  end
2515
2520
  list << path
@@ -2517,14 +2522,14 @@ module Bundler::FileUtils
2517
2522
  end
2518
2523
  private_module_function :fu_split_path
2519
2524
 
2520
- def fu_relative_components_from(target, base) #:nodoc:
2525
+ def fu_common_components(target, base) #:nodoc:
2521
2526
  i = 0
2522
2527
  while target[i]&.== base[i]
2523
2528
  i += 1
2524
2529
  end
2525
- Array.new(base.size-i, '..').concat(target[i..-1])
2530
+ i
2526
2531
  end
2527
- private_module_function :fu_relative_components_from
2532
+ private_module_function :fu_common_components
2528
2533
 
2529
2534
  def fu_clean_components(*comp) #:nodoc:
2530
2535
  comp.shift while comp.first == "."
@@ -2534,7 +2539,7 @@ module Bundler::FileUtils
2534
2539
  while c = comp.shift
2535
2540
  if c == ".." and clean.last != ".." and !(fu_have_symlink? && File.symlink?(path))
2536
2541
  clean.pop
2537
- path.chomp!(%r((?<=\A|/)[^/]+/\z), "")
2542
+ path.sub!(%r((?<=\A|/)[^/]+/\z), "")
2538
2543
  else
2539
2544
  clean << c
2540
2545
  path << c << "/"
@@ -1,7 +1,10 @@
1
1
  require_relative '../../../../../vendored_net_http'
2
2
  require_relative '../../../../../vendored_uri'
3
- require 'cgi/escape'
4
- require 'cgi/util' unless defined?(CGI::EscapeExt)
3
+ begin
4
+ require 'cgi/escape'
5
+ rescue LoadError
6
+ require 'cgi/util' # for escaping
7
+ end
5
8
  require_relative '../../../../connection_pool/lib/connection_pool'
6
9
 
7
10
  autoload :OpenSSL, 'openssl'
@@ -242,6 +242,35 @@ class Bundler::Thor
242
242
  insert_into_file(path, *(args << config), &block)
243
243
  end
244
244
 
245
+ # Run a regular expression replacement on a file, raising an error if the
246
+ # contents of the file are not changed.
247
+ #
248
+ # ==== Parameters
249
+ # path<String>:: path of the file to be changed
250
+ # flag<Regexp|String>:: the regexp or string to be replaced
251
+ # replacement<String>:: the replacement, can be also given as a block
252
+ # config<Hash>:: give :verbose => false to not log the status, and
253
+ # :force => true, to force the replacement regardless of runner behavior.
254
+ #
255
+ # ==== Example
256
+ #
257
+ # gsub_file! 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
258
+ #
259
+ # gsub_file! 'README', /rake/, :green do |match|
260
+ # match << " no more. Use thor!"
261
+ # end
262
+ #
263
+ def gsub_file!(path, flag, *args, &block)
264
+ config = args.last.is_a?(Hash) ? args.pop : {}
265
+
266
+ return unless behavior == :invoke || config.fetch(:force, false)
267
+
268
+ path = File.expand_path(path, destination_root)
269
+ say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
270
+
271
+ actually_gsub_file(path, flag, args, true, &block) unless options[:pretend]
272
+ end
273
+
245
274
  # Run a regular expression replacement on a file.
246
275
  #
247
276
  # ==== Parameters
@@ -267,11 +296,7 @@ class Bundler::Thor
267
296
  path = File.expand_path(path, destination_root)
268
297
  say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
269
298
 
270
- unless options[:pretend]
271
- content = File.binread(path)
272
- content.gsub!(flag, *args, &block)
273
- File.open(path, "wb") { |file| file.write(content) }
274
- end
299
+ actually_gsub_file(path, flag, args, false, &block) unless options[:pretend]
275
300
  end
276
301
 
277
302
  # Uncomment all lines matching a given regex. Preserves indentation before
@@ -348,7 +373,7 @@ class Bundler::Thor
348
373
  end
349
374
 
350
375
  def with_output_buffer(buf = "".dup) #:nodoc:
351
- raise ArgumentError, "Buffer can not be a frozen object" if buf.frozen?
376
+ raise ArgumentError, "Buffer cannot be a frozen object" if buf.frozen?
352
377
  old_buffer = output_buffer
353
378
  self.output_buffer = buf
354
379
  yield
@@ -357,6 +382,17 @@ class Bundler::Thor
357
382
  self.output_buffer = old_buffer
358
383
  end
359
384
 
385
+ def actually_gsub_file(path, flag, args, error_on_no_change, &block)
386
+ content = File.binread(path)
387
+ success = content.gsub!(flag, *args, &block)
388
+
389
+ if success.nil? && error_on_no_change
390
+ raise Bundler::Thor::Error, "The content of #{path} did not change"
391
+ end
392
+
393
+ File.open(path, "wb") { |file| file.write(content) }
394
+ end
395
+
360
396
  # Bundler::Thor::Actions#capture depends on what kind of buffer is used in ERB.
361
397
  # Thus CapturableERB fixes ERB to use String buffer.
362
398
  class CapturableERB < ERB
@@ -144,7 +144,7 @@ class Bundler::Thor
144
144
  def check_exclusive!
145
145
  opts = @assigns.keys
146
146
  # When option A and B are exclusive, if A and B are given at the same time,
147
- # the diffrence of argument array size will decrease.
147
+ # the difference of argument array size will decrease.
148
148
  found = @exclusives.find{ |ex| (ex - opts).size < ex.size - 1 }
149
149
  if found
150
150
  names = names_to_switch_names(found & opts).map{|n| "'#{n}'"}
@@ -1,9 +1,8 @@
1
1
  require_relative "../thor"
2
2
  require_relative "group"
3
3
 
4
- require "yaml"
5
4
  require "digest/sha2"
6
- require "pathname"
5
+ require "pathname" unless defined?(Pathname)
7
6
 
8
7
  class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
9
8
  map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
@@ -195,6 +194,7 @@ private
195
194
  def thor_yaml
196
195
  @thor_yaml ||= begin
197
196
  yaml_file = File.join(thor_root, "thor.yml")
197
+ require "yaml"
198
198
  yaml = YAML.load_file(yaml_file) if File.exist?(yaml_file)
199
199
  yaml || {}
200
200
  end
@@ -314,7 +314,7 @@ class Bundler::Thor
314
314
  diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u"
315
315
 
316
316
  require "tempfile"
317
- Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
317
+ Tempfile.open(File.basename(destination), File.dirname(destination), binmode: true) do |temp|
318
318
  temp.write content
319
319
  temp.rewind
320
320
  system %(#{diff_cmd} "#{destination}" "#{temp.path}")
@@ -372,16 +372,12 @@ class Bundler::Thor
372
372
  Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
373
373
  temp.write content
374
374
  temp.rewind
375
- system %(#{merge_tool} "#{temp.path}" "#{destination}")
375
+ system(merge_tool, temp.path, destination)
376
376
  end
377
377
  end
378
378
 
379
379
  def merge_tool #:nodoc:
380
- @merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
381
- end
382
-
383
- def git_merge_tool #:nodoc:
384
- `git config merge.tool`.rstrip rescue ""
380
+ @merge_tool ||= ENV["THOR_MERGE"] || "git difftool --no-index"
385
381
  end
386
382
  end
387
383
  end
@@ -1,3 +1,3 @@
1
1
  class Bundler::Thor
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -30,6 +30,9 @@ module Bundler::URI
30
30
  remove_const(:Parser) if defined?(::Bundler::URI::Parser)
31
31
  const_set("Parser", parser.class)
32
32
 
33
+ remove_const(:PARSER) if defined?(::Bundler::URI::PARSER)
34
+ const_set("PARSER", parser)
35
+
33
36
  remove_const(:REGEXP) if defined?(::Bundler::URI::REGEXP)
34
37
  remove_const(:PATTERN) if defined?(::Bundler::URI::PATTERN)
35
38
  if Parser == RFC2396_Parser
@@ -49,10 +52,10 @@ module Bundler::URI
49
52
  warn "Bundler::URI::REGEXP is obsolete. Use Bundler::URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
50
53
  Bundler::URI::RFC2396_REGEXP
51
54
  elsif value = RFC2396_PARSER.regexp[const]
52
- warn "Bundler::URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
55
+ warn "Bundler::URI::#{const} is obsolete. Use Bundler::URI::RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
53
56
  value
54
57
  elsif value = RFC2396_Parser.const_get(const)
55
- warn "Bundler::URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
58
+ warn "Bundler::URI::#{const} is obsolete. Use Bundler::URI::RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
56
59
  value
57
60
  else
58
61
  super
@@ -92,6 +95,40 @@ module Bundler::URI
92
95
  end
93
96
 
94
97
  module Schemes # :nodoc:
98
+ class << self
99
+ ReservedChars = ".+-"
100
+ EscapedChars = "\u01C0\u01C1\u01C2"
101
+ # Use Lo category chars as escaped chars for TruffleRuby, which
102
+ # does not allow Symbol categories as identifiers.
103
+
104
+ def escape(name)
105
+ unless name and name.ascii_only?
106
+ return nil
107
+ end
108
+ name.upcase.tr(ReservedChars, EscapedChars)
109
+ end
110
+
111
+ def unescape(name)
112
+ name.tr(EscapedChars, ReservedChars).encode(Encoding::US_ASCII).upcase
113
+ end
114
+
115
+ def find(name)
116
+ const_get(name, false) if name and const_defined?(name, false)
117
+ end
118
+
119
+ def register(name, klass)
120
+ unless scheme = escape(name)
121
+ raise ArgumentError, "invalid character as scheme - #{name}"
122
+ end
123
+ const_set(scheme, klass)
124
+ end
125
+
126
+ def list
127
+ constants.map { |name|
128
+ [unescape(name.to_s), const_get(name)]
129
+ }.to_h
130
+ end
131
+ end
95
132
  end
96
133
  private_constant :Schemes
97
134
 
@@ -104,7 +141,7 @@ module Bundler::URI
104
141
  # Note that after calling String#upcase on +scheme+, it must be a valid
105
142
  # constant name.
106
143
  def self.register_scheme(scheme, klass)
107
- Schemes.const_set(scheme.to_s.upcase, klass)
144
+ Schemes.register(scheme, klass)
108
145
  end
109
146
 
110
147
  # Returns a hash of the defined schemes:
@@ -122,14 +159,14 @@ module Bundler::URI
122
159
  #
123
160
  # Related: Bundler::URI.register_scheme.
124
161
  def self.scheme_list
125
- Schemes.constants.map { |name|
126
- [name.to_s.upcase, Schemes.const_get(name)]
127
- }.to_h
162
+ Schemes.list
128
163
  end
129
164
 
165
+ # :stopdoc:
130
166
  INITIAL_SCHEMES = scheme_list
131
167
  private_constant :INITIAL_SCHEMES
132
168
  Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
169
+ # :startdoc:
133
170
 
134
171
  # Returns a new object constructed from the given +scheme+, +arguments+,
135
172
  # and +default+:
@@ -148,12 +185,10 @@ module Bundler::URI
148
185
  # # => #<Bundler::URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
149
186
  #
150
187
  def self.for(scheme, *arguments, default: Generic)
151
- const_name = scheme.to_s.upcase
188
+ const_name = Schemes.escape(scheme)
152
189
 
153
190
  uri_class = INITIAL_SCHEMES[const_name]
154
- uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
155
- Schemes.const_get(const_name, false)
156
- end
191
+ uri_class ||= Schemes.find(const_name)
157
192
  uri_class ||= default
158
193
 
159
194
  return uri_class.new(scheme, *arguments)
@@ -195,7 +230,7 @@ module Bundler::URI
195
230
  # ["fragment", "top"]]
196
231
  #
197
232
  def self.split(uri)
198
- DEFAULT_PARSER.split(uri)
233
+ PARSER.split(uri)
199
234
  end
200
235
 
201
236
  # Returns a new \Bundler::URI object constructed from the given string +uri+:
@@ -205,11 +240,11 @@ module Bundler::URI
205
240
  # Bundler::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
206
241
  # # => #<Bundler::URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
207
242
  #
208
- # It's recommended to first ::escape string +uri+
243
+ # It's recommended to first Bundler::URI::RFC2396_PARSER.escape string +uri+
209
244
  # if it may contain invalid Bundler::URI characters.
210
245
  #
211
246
  def self.parse(uri)
212
- DEFAULT_PARSER.parse(uri)
247
+ PARSER.parse(uri)
213
248
  end
214
249
 
215
250
  # Merges the given Bundler::URI strings +str+
@@ -265,7 +300,7 @@ module Bundler::URI
265
300
  #
266
301
  def self.extract(str, schemes = nil, &block) # :nodoc:
267
302
  warn "Bundler::URI.extract is obsolete", uplevel: 1 if $VERBOSE
268
- DEFAULT_PARSER.extract(str, schemes, &block)
303
+ PARSER.extract(str, schemes, &block)
269
304
  end
270
305
 
271
306
  #
@@ -302,7 +337,7 @@ module Bundler::URI
302
337
  #
303
338
  def self.regexp(schemes = nil)# :nodoc:
304
339
  warn "Bundler::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
305
- DEFAULT_PARSER.make_regexp(schemes)
340
+ PARSER.make_regexp(schemes)
306
341
  end
307
342
 
308
343
  TBLENCWWWCOMP_ = {} # :nodoc:
@@ -407,6 +442,8 @@ module Bundler::URI
407
442
  _decode_uri_component(/%\h\h/, str, enc)
408
443
  end
409
444
 
445
+ # Returns a string derived from the given string +str+ with
446
+ # Bundler::URI-encoded characters matching +regexp+ according to +table+.
410
447
  def self._encode_uri_component(regexp, table, str, enc)
411
448
  str = str.to_s.dup
412
449
  if str.encoding != Encoding::ASCII_8BIT
@@ -421,6 +458,8 @@ module Bundler::URI
421
458
  end
422
459
  private_class_method :_encode_uri_component
423
460
 
461
+ # Returns a string decoding characters matching +regexp+ from the
462
+ # given \URL-encoded string +str+.
424
463
  def self._decode_uri_component(regexp, str, enc)
425
464
  raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
426
465
  str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
@@ -859,6 +898,7 @@ module Bundler
859
898
  # Returns a \Bundler::URI object derived from the given +uri+,
860
899
  # which may be a \Bundler::URI string or an existing \Bundler::URI object:
861
900
  #
901
+ # require 'bundler/vendor/uri/lib/uri'
862
902
  # # Returns a new Bundler::URI.
863
903
  # uri = Bundler::URI('http://github.com/ruby/ruby')
864
904
  # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
@@ -866,6 +906,8 @@ module Bundler
866
906
  # Bundler::URI(uri)
867
907
  # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
868
908
  #
909
+ # You must require 'bundler/vendor/uri/lib/uri' to use this method.
910
+ #
869
911
  def URI(uri)
870
912
  if uri.is_a?(Bundler::URI::Generic)
871
913
  uri
@@ -47,7 +47,7 @@ module Bundler::URI
47
47
  # :path => '/ruby/src'})
48
48
  # uri2.to_s # => "file://host.example.com/ruby/src"
49
49
  #
50
- # uri3 = Bundler::URI::File.build({:path => Bundler::URI::escape('/path/my file.txt')})
50
+ # uri3 = Bundler::URI::File.build({:path => Bundler::URI::RFC2396_PARSER.escape('/path/my file.txt')})
51
51
  # uri3.to_s # => "file:///path/my%20file.txt"
52
52
  #
53
53
  def self.build(args)