bundler 2.6.9 → 4.0.10

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 (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2212 -1879
  3. data/README.md +11 -11
  4. data/bundler.gemspec +5 -5
  5. data/lib/bundler/build_metadata.rb +10 -11
  6. data/lib/bundler/capistrano.rb +1 -19
  7. data/lib/bundler/checksum.rb +6 -0
  8. data/lib/bundler/cli/add.rb +10 -0
  9. data/lib/bundler/cli/cache.rb +1 -12
  10. data/lib/bundler/cli/common.rb +21 -4
  11. data/lib/bundler/cli/config.rb +1 -2
  12. data/lib/bundler/cli/console.rb +5 -0
  13. data/lib/bundler/cli/exec.rb +29 -4
  14. data/lib/bundler/cli/gem.rb +89 -63
  15. data/lib/bundler/cli/install.rb +15 -90
  16. data/lib/bundler/cli/issue.rb +2 -2
  17. data/lib/bundler/cli/list.rb +33 -2
  18. data/lib/bundler/cli/lock.rb +5 -5
  19. data/lib/bundler/cli/outdated.rb +1 -1
  20. data/lib/bundler/cli/plugin.rb +5 -1
  21. data/lib/bundler/cli/pristine.rb +5 -1
  22. data/lib/bundler/cli/show.rb +3 -7
  23. data/lib/bundler/cli/update.rb +5 -5
  24. data/lib/bundler/cli.rb +162 -127
  25. data/lib/bundler/compact_index_client.rb +1 -6
  26. data/lib/bundler/current_ruby.rb +17 -5
  27. data/lib/bundler/definition.rb +199 -117
  28. data/lib/bundler/dependency.rb +1 -1
  29. data/lib/bundler/deployment.rb +1 -64
  30. data/lib/bundler/digest.rb +1 -1
  31. data/lib/bundler/dsl.rb +48 -48
  32. data/lib/bundler/environment_preserver.rb +1 -0
  33. data/lib/bundler/errors.rb +1 -5
  34. data/lib/bundler/feature_flag.rb +5 -35
  35. data/lib/bundler/fetcher/compact_index.rb +1 -1
  36. data/lib/bundler/fetcher/dependency.rb +9 -2
  37. data/lib/bundler/fetcher/downloader.rb +33 -8
  38. data/lib/bundler/fetcher/gem_remote_fetcher.rb +6 -0
  39. data/lib/bundler/fetcher.rb +49 -19
  40. data/lib/bundler/friendly_errors.rb +4 -3
  41. data/lib/bundler/index.rb +7 -9
  42. data/lib/bundler/injector.rb +1 -2
  43. data/lib/bundler/inline.rb +9 -1
  44. data/lib/bundler/installer/gem_installer.rb +14 -11
  45. data/lib/bundler/installer/parallel_installer.rb +63 -17
  46. data/lib/bundler/installer.rb +6 -19
  47. data/lib/bundler/lazy_specification.rb +47 -20
  48. data/lib/bundler/lockfile_generator.rb +1 -1
  49. data/lib/bundler/lockfile_parser.rb +11 -5
  50. data/lib/bundler/man/bundle-add.1 +1 -1
  51. data/lib/bundler/man/bundle-binstubs.1 +3 -6
  52. data/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
  53. data/lib/bundler/man/bundle-cache.1 +2 -14
  54. data/lib/bundler/man/bundle-cache.1.ronn +1 -14
  55. data/lib/bundler/man/bundle-check.1 +2 -5
  56. data/lib/bundler/man/bundle-check.1.ronn +0 -5
  57. data/lib/bundler/man/bundle-clean.1 +1 -1
  58. data/lib/bundler/man/bundle-config.1 +206 -148
  59. data/lib/bundler/man/bundle-config.1.ronn +135 -118
  60. data/lib/bundler/man/bundle-console.1 +1 -1
  61. data/lib/bundler/man/bundle-doctor.1 +43 -4
  62. data/lib/bundler/man/bundle-doctor.1.ronn +48 -4
  63. data/lib/bundler/man/bundle-env.1 +1 -1
  64. data/lib/bundler/man/bundle-exec.1 +2 -5
  65. data/lib/bundler/man/bundle-exec.1.ronn +1 -5
  66. data/lib/bundler/man/bundle-fund.1 +1 -1
  67. data/lib/bundler/man/bundle-gem.1 +64 -44
  68. data/lib/bundler/man/bundle-gem.1.ronn +10 -9
  69. data/lib/bundler/man/bundle-help.1 +1 -1
  70. data/lib/bundler/man/bundle-info.1 +1 -1
  71. data/lib/bundler/man/bundle-init.1 +1 -1
  72. data/lib/bundler/man/bundle-install.1 +16 -59
  73. data/lib/bundler/man/bundle-install.1.ronn +27 -108
  74. data/lib/bundler/man/bundle-issue.1 +1 -1
  75. data/lib/bundler/man/bundle-licenses.1 +1 -1
  76. data/lib/bundler/man/bundle-list.1 +6 -1
  77. data/lib/bundler/man/bundle-list.1.ronn +5 -0
  78. data/lib/bundler/man/bundle-lock.1 +1 -1
  79. data/lib/bundler/man/bundle-open.1 +1 -1
  80. data/lib/bundler/man/bundle-outdated.1 +1 -1
  81. data/lib/bundler/man/bundle-platform.1 +1 -1
  82. data/lib/bundler/man/bundle-plugin.1 +33 -15
  83. data/lib/bundler/man/bundle-plugin.1.ronn +36 -15
  84. data/lib/bundler/man/bundle-pristine.1 +1 -1
  85. data/lib/bundler/man/bundle-remove.1 +2 -8
  86. data/lib/bundler/man/bundle-remove.1.ronn +1 -8
  87. data/lib/bundler/man/bundle-show.1 +2 -5
  88. data/lib/bundler/man/bundle-show.1.ronn +0 -4
  89. data/lib/bundler/man/bundle-update.1 +5 -5
  90. data/lib/bundler/man/bundle-update.1.ronn +4 -4
  91. data/lib/bundler/man/bundle-version.1 +1 -1
  92. data/lib/bundler/man/bundle.1 +1 -10
  93. data/lib/bundler/man/bundle.1.ronn +0 -9
  94. data/lib/bundler/man/gemfile.5 +32 -1
  95. data/lib/bundler/man/gemfile.5.ronn +28 -0
  96. data/lib/bundler/man/index.txt +0 -2
  97. data/lib/bundler/match_platform.rb +31 -12
  98. data/lib/bundler/materialization.rb +3 -3
  99. data/lib/bundler/plugin/api/source.rb +8 -0
  100. data/lib/bundler/plugin/index.rb +6 -0
  101. data/lib/bundler/plugin/installer.rb +2 -11
  102. data/lib/bundler/plugin/source_list.rb +1 -1
  103. data/lib/bundler/plugin.rb +7 -4
  104. data/lib/bundler/resolver/package.rb +2 -1
  105. data/lib/bundler/resolver/strategy.rb +6 -3
  106. data/lib/bundler/resolver.rb +20 -4
  107. data/lib/bundler/retry.rb +30 -4
  108. data/lib/bundler/ruby_dsl.rb +17 -12
  109. data/lib/bundler/ruby_version.rb +1 -3
  110. data/lib/bundler/rubygems_ext.rb +117 -121
  111. data/lib/bundler/rubygems_gem_installer.rb +5 -4
  112. data/lib/bundler/rubygems_integration.rb +13 -12
  113. data/lib/bundler/runtime.rb +14 -3
  114. data/lib/bundler/self_manager.rb +34 -43
  115. data/lib/bundler/settings/validator.rb +5 -21
  116. data/lib/bundler/settings.rb +17 -32
  117. data/lib/bundler/shared_helpers.rb +12 -18
  118. data/lib/bundler/source/gemspec.rb +4 -0
  119. data/lib/bundler/source/git/git_proxy.rb +55 -29
  120. data/lib/bundler/source/git.rb +2 -3
  121. data/lib/bundler/source/path.rb +12 -7
  122. data/lib/bundler/source/rubygems.rb +59 -43
  123. data/lib/bundler/source/rubygems_aggregate.rb +4 -1
  124. data/lib/bundler/source.rb +3 -1
  125. data/lib/bundler/source_list.rb +5 -50
  126. data/lib/bundler/source_map.rb +8 -7
  127. data/lib/bundler/spec_set.rb +9 -14
  128. data/lib/bundler/stub_specification.rb +1 -0
  129. data/lib/bundler/templates/Executable +0 -11
  130. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
  131. data/lib/bundler/templates/newgem/Cargo.toml.tt +6 -0
  132. data/lib/bundler/templates/newgem/Rakefile.tt +5 -0
  133. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  134. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +8 -1
  135. data/lib/bundler/templates/newgem/ext/newgem/build.rs.tt +5 -0
  136. data/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  137. data/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  138. data/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  139. data/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  140. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +13 -2
  141. data/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt +69 -0
  142. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +12 -1
  143. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  144. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -1
  145. data/lib/bundler/templates/newgem/newgem.gemspec.tt +10 -10
  146. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +8 -0
  147. data/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt +6 -0
  148. data/lib/bundler/ui/shell.rb +12 -8
  149. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
  150. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  151. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
  152. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
  153. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  154. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +2 -1
  155. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +84 -42
  156. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +42 -6
  157. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +1 -1
  158. data/lib/bundler/vendor/thor/lib/thor/runner.rb +2 -2
  159. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +3 -7
  160. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  161. data/lib/bundler/vendor/thor/lib/thor.rb +1 -1
  162. data/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
  163. data/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
  164. data/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
  165. data/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
  166. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  167. data/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
  168. data/lib/bundler/version.rb +10 -2
  169. data/lib/bundler/vlad.rb +1 -14
  170. data/lib/bundler/worker.rb +12 -4
  171. data/lib/bundler.rb +20 -40
  172. metadata +13 -25
  173. data/lib/bundler/cli/inject.rb +0 -60
  174. data/lib/bundler/cli/viz.rb +0 -31
  175. data/lib/bundler/gem_helpers.rb +0 -144
  176. data/lib/bundler/graph.rb +0 -152
  177. data/lib/bundler/man/bundle-inject.1 +0 -31
  178. data/lib/bundler/man/bundle-inject.1.ronn +0 -32
  179. data/lib/bundler/man/bundle-viz.1 +0 -30
  180. data/lib/bundler/man/bundle-viz.1.ronn +0 -36
  181. data/lib/bundler/similarity_detector.rb +0 -63
  182. data/lib/bundler/templates/Executable.bundler +0 -109
  183. data/lib/bundler/vendor/connection_pool/.document +0 -1
  184. data/lib/bundler/vendor/fileutils/.document +0 -1
  185. data/lib/bundler/vendor/net-http-persistent/.document +0 -1
  186. data/lib/bundler/vendor/pub_grub/.document +0 -1
  187. data/lib/bundler/vendor/securerandom/.document +0 -1
  188. data/lib/bundler/vendor/thor/.document +0 -1
  189. data/lib/bundler/vendor/tsort/.document +0 -1
  190. data/lib/bundler/vendor/uri/.document +0 -1
@@ -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,7 @@
1
1
  = net-http-persistent
2
2
 
3
3
  home :: https://github.com/drbrain/net-http-persistent
4
- rdoc :: https://rdoc.info/gems/net-http-persistent
4
+ rdoc :: https://rubydoc.info/gems/net-http-persistent
5
5
 
6
6
  == DESCRIPTION:
7
7
 
@@ -63,7 +63,8 @@ class Gem::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::Tim
63
63
  if @created >= @max && @enqueued >= 1
64
64
  oldest, = @lru.first
65
65
  @lru.delete oldest
66
- @ques[oldest].pop
66
+ connection = @ques[oldest].pop
67
+ connection.close if connection.respond_to?(:close)
67
68
 
68
69
  @created -= 1
69
70
  end
@@ -1,6 +1,10 @@
1
1
  require_relative '../../../../../vendored_net_http'
2
2
  require_relative '../../../../../vendored_uri'
3
- require 'cgi' # for escaping
3
+ begin
4
+ require 'cgi/escape'
5
+ rescue LoadError
6
+ require 'cgi/util' # for escaping
7
+ end
4
8
  require_relative '../../../../connection_pool/lib/connection_pool'
5
9
 
6
10
  autoload :OpenSSL, 'openssl'
@@ -42,9 +46,8 @@ autoload :OpenSSL, 'openssl'
42
46
  # # perform the POST, the Gem::URI is always required
43
47
  # response http.request post_uri, post
44
48
  #
45
- # Note that for GET, HEAD and other requests that do not have a body you want
46
- # to use Gem::URI#request_uri not Gem::URI#path. The request_uri contains the query
47
- # params which are sent in the body for other requests.
49
+ # Note that for GET, HEAD and other requests that do not have a body,
50
+ # it uses Gem::URI#request_uri as default to send query params
48
51
  #
49
52
  # == TLS/SSL
50
53
  #
@@ -60,6 +63,7 @@ autoload :OpenSSL, 'openssl'
60
63
  # #ca_path :: Directory with certificate-authorities
61
64
  # #cert_store :: An SSL certificate store
62
65
  # #ciphers :: List of SSl ciphers allowed
66
+ # #extra_chain_cert :: Extra certificates to be added to the certificate chain
63
67
  # #private_key :: The client's SSL private key
64
68
  # #reuse_ssl_sessions :: Reuse a previously opened SSL session for a new
65
69
  # connection
@@ -176,7 +180,7 @@ class Gem::Net::HTTP::Persistent
176
180
  ##
177
181
  # The version of Gem::Net::HTTP::Persistent you are using
178
182
 
179
- VERSION = '4.0.4'
183
+ VERSION = '4.0.6'
180
184
 
181
185
  ##
182
186
  # Error class for errors raised by Gem::Net::HTTP::Persistent. Various
@@ -267,6 +271,11 @@ class Gem::Net::HTTP::Persistent
267
271
 
268
272
  attr_reader :ciphers
269
273
 
274
+ ##
275
+ # Extra certificates to be added to the certificate chain
276
+
277
+ attr_reader :extra_chain_cert
278
+
270
279
  ##
271
280
  # Sends debug_output to this IO via Gem::Net::HTTP#set_debug_output.
272
281
  #
@@ -587,6 +596,21 @@ class Gem::Net::HTTP::Persistent
587
596
  reconnect_ssl
588
597
  end
589
598
 
599
+ if Gem::Net::HTTP.method_defined?(:extra_chain_cert=)
600
+ ##
601
+ # Extra certificates to be added to the certificate chain.
602
+ # It is only supported starting from Gem::Net::HTTP version 0.1.1
603
+ def extra_chain_cert= extra_chain_cert
604
+ @extra_chain_cert = extra_chain_cert
605
+
606
+ reconnect_ssl
607
+ end
608
+ else
609
+ def extra_chain_cert= _extra_chain_cert
610
+ raise "extra_chain_cert= is not supported by this version of Gem::Net::HTTP"
611
+ end
612
+ end
613
+
590
614
  ##
591
615
  # Creates a new connection for +uri+
592
616
 
@@ -605,47 +629,49 @@ class Gem::Net::HTTP::Persistent
605
629
 
606
630
  connection = @pool.checkout net_http_args
607
631
 
608
- http = connection.http
632
+ begin
633
+ http = connection.http
609
634
 
610
- connection.ressl @ssl_generation if
611
- connection.ssl_generation != @ssl_generation
635
+ connection.ressl @ssl_generation if
636
+ connection.ssl_generation != @ssl_generation
612
637
 
613
- if not http.started? then
614
- ssl http if use_ssl
615
- start http
616
- elsif expired? connection then
617
- reset connection
618
- end
638
+ if not http.started? then
639
+ ssl http if use_ssl
640
+ start http
641
+ elsif expired? connection then
642
+ reset connection
643
+ end
619
644
 
620
- http.keep_alive_timeout = @idle_timeout if @idle_timeout
621
- http.max_retries = @max_retries if http.respond_to?(:max_retries=)
622
- http.read_timeout = @read_timeout if @read_timeout
623
- http.write_timeout = @write_timeout if
624
- @write_timeout && http.respond_to?(:write_timeout=)
645
+ http.keep_alive_timeout = @idle_timeout if @idle_timeout
646
+ http.max_retries = @max_retries if http.respond_to?(:max_retries=)
647
+ http.read_timeout = @read_timeout if @read_timeout
648
+ http.write_timeout = @write_timeout if
649
+ @write_timeout && http.respond_to?(:write_timeout=)
650
+
651
+ return yield connection
652
+ rescue Errno::ECONNREFUSED
653
+ if http.proxy?
654
+ address = http.proxy_address
655
+ port = http.proxy_port
656
+ else
657
+ address = http.address
658
+ port = http.port
659
+ end
625
660
 
626
- return yield connection
627
- rescue Errno::ECONNREFUSED
628
- if http.proxy?
629
- address = http.proxy_address
630
- port = http.proxy_port
631
- else
632
- address = http.address
633
- port = http.port
634
- end
661
+ raise Error, "connection refused: #{address}:#{port}"
662
+ rescue Errno::EHOSTDOWN
663
+ if http.proxy?
664
+ address = http.proxy_address
665
+ port = http.proxy_port
666
+ else
667
+ address = http.address
668
+ port = http.port
669
+ end
635
670
 
636
- raise Error, "connection refused: #{address}:#{port}"
637
- rescue Errno::EHOSTDOWN
638
- if http.proxy?
639
- address = http.proxy_address
640
- port = http.proxy_port
641
- else
642
- address = http.address
643
- port = http.port
671
+ raise Error, "host down: #{address}:#{port}"
672
+ ensure
673
+ @pool.checkin net_http_args
644
674
  end
645
-
646
- raise Error, "host down: #{address}:#{port}"
647
- ensure
648
- @pool.checkin net_http_args
649
675
  end
650
676
 
651
677
  ##
@@ -782,7 +808,7 @@ class Gem::Net::HTTP::Persistent
782
808
  @proxy_connection_id = [nil, *@proxy_args].join ':'
783
809
 
784
810
  if @proxy_uri.query then
785
- @no_proxy = CGI.parse(@proxy_uri.query)['no_proxy'].join(',').downcase.split(',').map { |x| x.strip }.reject { |x| x.empty? }
811
+ @no_proxy = Gem::URI.decode_www_form(@proxy_uri.query).filter_map { |k, v| v if k == 'no_proxy' }.join(',').downcase.split(',').map { |x| x.strip }.reject { |x| x.empty? }
786
812
  end
787
813
  end
788
814
 
@@ -953,7 +979,8 @@ class Gem::Net::HTTP::Persistent
953
979
  end
954
980
 
955
981
  ##
956
- # Shuts down all connections
982
+ # Shuts down all connections. Attempting to checkout a connection after
983
+ # shutdown will raise an error.
957
984
  #
958
985
  # *NOTE*: Calling shutdown for can be dangerous!
959
986
  #
@@ -964,6 +991,17 @@ class Gem::Net::HTTP::Persistent
964
991
  @pool.shutdown { |http| http.finish }
965
992
  end
966
993
 
994
+ ##
995
+ # Discard all existing connections. Subsequent checkouts will create
996
+ # new connections as needed.
997
+ #
998
+ # If any thread is still using a connection it may cause an error! Call
999
+ # #reload when you are completely done making requests!
1000
+
1001
+ def reload
1002
+ @pool.reload { |http| http.finish }
1003
+ end
1004
+
967
1005
  ##
968
1006
  # Enables SSL on +connection+
969
1007
 
@@ -1021,6 +1059,10 @@ application:
1021
1059
  connection.key = @private_key
1022
1060
  end
1023
1061
 
1062
+ if defined?(@extra_chain_cert) and @extra_chain_cert
1063
+ connection.extra_chain_cert = @extra_chain_cert
1064
+ end
1065
+
1024
1066
  connection.cert_store = if @cert_store then
1025
1067
  @cert_store
1026
1068
  else
@@ -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
@@ -625,7 +625,7 @@ class Bundler::Thor
625
625
  # alias name.
626
626
  def find_command_possibilities(meth)
627
627
  len = meth.to_s.length
628
- possibilities = all_commands.merge(map).keys.select { |n| meth == n[0, len] }.sort
628
+ possibilities = all_commands.reject { |_k, c| c.hidden? }.merge(map).keys.select { |n| meth == n[0, len] }.sort
629
629
  unique_possibilities = possibilities.map { |k| map[k] || k }.uniq
630
630
 
631
631
  if possibilities.include?(meth)