bundler 2.3.26 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +48 -0
  3. data/README.md +2 -2
  4. data/bundler.gemspec +2 -2
  5. data/exe/bundle +1 -4
  6. data/lib/bundler/build_metadata.rb +2 -2
  7. data/lib/bundler/cli/add.rb +1 -1
  8. data/lib/bundler/cli/check.rb +1 -1
  9. data/lib/bundler/cli/common.rb +1 -0
  10. data/lib/bundler/cli/console.rb +2 -2
  11. data/lib/bundler/cli/doctor.rb +4 -6
  12. data/lib/bundler/cli/gem.rb +62 -40
  13. data/lib/bundler/cli/install.rb +2 -3
  14. data/lib/bundler/cli/lock.rb +8 -5
  15. data/lib/bundler/cli/outdated.rb +1 -3
  16. data/lib/bundler/cli/viz.rb +1 -1
  17. data/lib/bundler/cli.rb +43 -2
  18. data/lib/bundler/compact_index_client/cache.rb +1 -1
  19. data/lib/bundler/compact_index_client/updater.rb +40 -39
  20. data/lib/bundler/constants.rb +1 -1
  21. data/lib/bundler/definition.rb +61 -31
  22. data/lib/bundler/dependency.rb +12 -11
  23. data/lib/bundler/digest.rb +1 -1
  24. data/lib/bundler/dsl.rb +1 -1
  25. data/lib/bundler/env.rb +1 -1
  26. data/lib/bundler/environment_preserver.rb +1 -0
  27. data/lib/bundler/errors.rb +1 -11
  28. data/lib/bundler/fetcher/compact_index.rb +9 -11
  29. data/lib/bundler/fetcher/dependency.rb +1 -1
  30. data/lib/bundler/fetcher/downloader.rb +2 -5
  31. data/lib/bundler/fetcher.rb +2 -6
  32. data/lib/bundler/force_platform.rb +18 -0
  33. data/lib/bundler/friendly_errors.rb +0 -3
  34. data/lib/bundler/gem_version_promoter.rb +52 -86
  35. data/lib/bundler/graph.rb +3 -3
  36. data/lib/bundler/index.rb +5 -13
  37. data/lib/bundler/injector.rb +1 -1
  38. data/lib/bundler/inline.rb +2 -2
  39. data/lib/bundler/installer/parallel_installer.rb +0 -31
  40. data/lib/bundler/installer.rb +6 -16
  41. data/lib/bundler/lazy_specification.rb +5 -1
  42. data/lib/bundler/lockfile_parser.rb +5 -5
  43. data/lib/bundler/man/bundle-add.1 +1 -1
  44. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  45. data/lib/bundler/man/bundle-cache.1 +1 -1
  46. data/lib/bundler/man/bundle-check.1 +1 -1
  47. data/lib/bundler/man/bundle-clean.1 +1 -1
  48. data/lib/bundler/man/bundle-config.1 +1 -1
  49. data/lib/bundler/man/bundle-console.1 +1 -1
  50. data/lib/bundler/man/bundle-doctor.1 +1 -1
  51. data/lib/bundler/man/bundle-exec.1 +1 -1
  52. data/lib/bundler/man/bundle-gem.1 +27 -37
  53. data/lib/bundler/man/bundle-gem.1.ronn +5 -5
  54. data/lib/bundler/man/bundle-help.1 +1 -1
  55. data/lib/bundler/man/bundle-info.1 +1 -1
  56. data/lib/bundler/man/bundle-init.1 +1 -1
  57. data/lib/bundler/man/bundle-inject.1 +1 -1
  58. data/lib/bundler/man/bundle-install.1 +1 -30
  59. data/lib/bundler/man/bundle-install.1.ronn +0 -29
  60. data/lib/bundler/man/bundle-list.1 +1 -1
  61. data/lib/bundler/man/bundle-lock.1 +1 -1
  62. data/lib/bundler/man/bundle-open.1 +1 -1
  63. data/lib/bundler/man/bundle-outdated.1 +1 -1
  64. data/lib/bundler/man/bundle-platform.1 +2 -2
  65. data/lib/bundler/man/bundle-platform.1.ronn +1 -1
  66. data/lib/bundler/man/bundle-plugin.1 +1 -1
  67. data/lib/bundler/man/bundle-pristine.1 +1 -1
  68. data/lib/bundler/man/bundle-remove.1 +1 -1
  69. data/lib/bundler/man/bundle-show.1 +1 -1
  70. data/lib/bundler/man/bundle-update.1 +1 -1
  71. data/lib/bundler/man/bundle-version.1 +1 -1
  72. data/lib/bundler/man/bundle-viz.1 +1 -1
  73. data/lib/bundler/man/bundle.1 +1 -1
  74. data/lib/bundler/man/gemfile.5 +1 -1
  75. data/lib/bundler/mirror.rb +5 -7
  76. data/lib/bundler/plugin/index.rb +4 -4
  77. data/lib/bundler/plugin/installer/rubygems.rb +0 -4
  78. data/lib/bundler/resolver/base.rb +7 -11
  79. data/lib/bundler/resolver/candidate.rb +92 -0
  80. data/lib/bundler/resolver/incompatibility.rb +15 -0
  81. data/lib/bundler/resolver/package.rb +63 -0
  82. data/lib/bundler/resolver/root.rb +25 -0
  83. data/lib/bundler/resolver/spec_group.rb +26 -36
  84. data/lib/bundler/resolver.rb +285 -277
  85. data/lib/bundler/rubygems_ext.rb +11 -6
  86. data/lib/bundler/rubygems_gem_installer.rb +4 -2
  87. data/lib/bundler/rubygems_integration.rb +1 -9
  88. data/lib/bundler/runtime.rb +1 -5
  89. data/lib/bundler/settings.rb +0 -6
  90. data/lib/bundler/shared_helpers.rb +1 -0
  91. data/lib/bundler/source/git/git_proxy.rb +190 -67
  92. data/lib/bundler/source/git.rb +15 -17
  93. data/lib/bundler/source/metadata.rb +0 -1
  94. data/lib/bundler/source/path/installer.rb +1 -22
  95. data/lib/bundler/source/path.rb +5 -5
  96. data/lib/bundler/source/rubygems.rb +13 -67
  97. data/lib/bundler/source_list.rb +8 -2
  98. data/lib/bundler/spec_set.rb +7 -9
  99. data/lib/bundler/templates/Executable +1 -1
  100. data/lib/bundler/templates/Executable.bundler +4 -9
  101. data/lib/bundler/templates/Executable.standalone +2 -0
  102. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  103. data/lib/bundler/templates/newgem/Gemfile.tt +3 -0
  104. data/lib/bundler/templates/newgem/README.md.tt +6 -4
  105. data/lib/bundler/templates/newgem/Rakefile.tt +2 -1
  106. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  107. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  108. data/lib/bundler/templates/newgem/ext/newgem/{extconf.rb.tt → extconf-c.rb.tt} +0 -0
  109. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  110. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  111. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +10 -0
  112. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  113. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +8 -0
  114. data/lib/bundler/templates/newgem/newgem.gemspec.tt +8 -2
  115. data/lib/bundler/ui/shell.rb +35 -12
  116. data/lib/bundler/ui/silent.rb +21 -5
  117. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +3 -3
  118. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +0 -1
  119. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +3 -1
  120. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1350 -408
  121. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  122. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  123. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  124. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  125. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  126. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  127. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +151 -0
  128. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  129. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  130. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  131. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  132. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +53 -0
  133. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  134. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  135. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +124 -0
  136. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +409 -0
  137. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +240 -0
  138. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  139. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  140. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +1 -1
  141. data/lib/bundler/vendor/uri/lib/uri/common.rb +64 -16
  142. data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
  143. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -1
  144. data/lib/bundler/vendor/uri/lib/uri/generic.rb +27 -7
  145. data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -2
  146. data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -1
  147. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  148. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  149. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -2
  150. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +13 -7
  151. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +10 -5
  152. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  153. data/lib/bundler/vendor/uri/lib/uri/ws.rb +1 -2
  154. data/lib/bundler/vendor/uri/lib/uri/wss.rb +2 -1
  155. data/lib/bundler/vendor/uri/lib/uri.rb +3 -2
  156. data/lib/bundler/vendored_persistent.rb +1 -33
  157. data/lib/bundler/{vendored_tmpdir.rb → vendored_pub_grub.rb} +1 -1
  158. data/lib/bundler/version.rb +5 -1
  159. data/lib/bundler/worker.rb +5 -7
  160. data/lib/bundler.rb +20 -64
  161. metadata +33 -32
  162. data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  163. data/lib/bundler/vendor/molinillo/LICENSE +0 -9
  164. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  165. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  166. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  167. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  168. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  169. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  170. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  171. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  172. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  173. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  174. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  175. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  176. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -149
  177. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  178. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  179. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  180. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  181. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  182. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  183. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  184. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  185. data/lib/bundler/vendored_molinillo.rb +0 -4
  186. data/lib/bundler/version_ranges.rb +0 -122
@@ -145,7 +145,7 @@ module Bundler
145
145
  end
146
146
 
147
147
  if installed?(spec) && !force
148
- print_using_message "Using #{version_message(spec)}"
148
+ print_using_message "Using #{version_message(spec, options[:previous_spec])}"
149
149
  return nil # no post-install message
150
150
  end
151
151
 
@@ -160,27 +160,20 @@ module Bundler
160
160
 
161
161
  return if Bundler.settings[:no_install]
162
162
 
163
- if requires_sudo?
164
- install_path = Bundler.tmp(spec.full_name)
165
- bin_path = install_path.join("bin")
166
- else
167
- install_path = rubygems_dir
168
- bin_path = Bundler.system_bindir
169
- end
170
-
171
- Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
163
+ install_path = rubygems_dir
164
+ bin_path = Bundler.system_bindir
172
165
 
173
166
  require_relative "../rubygems_gem_installer"
174
167
 
175
168
  installer = Bundler::RubyGemsGemInstaller.at(
176
169
  path,
177
- :security_policy => Bundler.rubygems.security_policies[Bundler.settings["trust-policy"]],
178
- :install_dir => install_path.to_s,
179
- :bin_dir => bin_path.to_s,
170
+ :security_policy => Bundler.rubygems.security_policies[Bundler.settings["trust-policy"]],
171
+ :install_dir => install_path.to_s,
172
+ :bin_dir => bin_path.to_s,
180
173
  :ignore_dependencies => true,
181
- :wrappers => true,
182
- :env_shebang => true,
183
- :build_args => options[:build_args],
174
+ :wrappers => true,
175
+ :env_shebang => true,
176
+ :build_args => options[:build_args],
184
177
  :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
185
178
  :bundler_extension_cache_path => extension_cache_path(spec)
186
179
  )
@@ -209,34 +202,7 @@ module Bundler
209
202
  spec.full_gem_path = installed_spec.full_gem_path
210
203
  spec.loaded_from = installed_spec.loaded_from
211
204
 
212
- # SUDO HAX
213
- if requires_sudo?
214
- Bundler.rubygems.repository_subdirectories.each do |name|
215
- src = File.join(install_path, name, "*")
216
- dst = File.join(rubygems_dir, name)
217
- if name == "extensions" && Dir.glob(src).any?
218
- src = File.join(src, "*/*")
219
- ext_src = Dir.glob(src).first
220
- ext_src.gsub!(src[0..-6], "")
221
- dst = File.dirname(File.join(dst, ext_src))
222
- end
223
- SharedHelpers.filesystem_access(dst) do |p|
224
- Bundler.mkdir_p(p)
225
- end
226
- Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
227
- end
228
-
229
- spec.executables.each do |exe|
230
- SharedHelpers.filesystem_access(Bundler.system_bindir) do |p|
231
- Bundler.mkdir_p(p)
232
- end
233
- Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/"
234
- end
235
- end
236
-
237
205
  spec.post_install_message
238
- ensure
239
- Bundler.rm_rf(install_path) if requires_sudo?
240
206
  end
241
207
 
242
208
  def cache(spec, custom_path = nil)
@@ -372,7 +338,7 @@ module Bundler
372
338
 
373
339
  def normalize_uri(uri)
374
340
  uri = uri.to_s
375
- uri = "#{uri}/" unless uri =~ %r{/$}
341
+ uri = "#{uri}/" unless %r{/$}.match?(uri)
376
342
  require_relative "../vendored_uri"
377
343
  uri = Bundler::URI(uri)
378
344
  raise ArgumentError, "The source must be an absolute URI. For example:\n" \
@@ -415,7 +381,7 @@ module Bundler
415
381
  idx = @allow_local ? installed_specs.dup : Index.new
416
382
 
417
383
  Dir["#{cache_path}/*.gem"].each do |gemfile|
418
- next if gemfile =~ /^bundler\-[\d\.]+?\.gem/
384
+ next if /^bundler\-[\d\.]+?\.gem/.match?(gemfile)
419
385
  s ||= Bundler.rubygems.spec_from_gem(gemfile)
420
386
  s.source = self
421
387
  idx << s
@@ -475,38 +441,18 @@ module Bundler
475
441
  gem_path = package_path(cache_path, spec)
476
442
  return gem_path if File.exist?(gem_path)
477
443
 
478
- if requires_sudo?
479
- download_path = Bundler.tmp(spec.full_name)
480
- download_cache_path = default_cache_path_for(download_path)
481
- else
482
- download_cache_path = cache_path
483
- end
484
-
485
- SharedHelpers.filesystem_access(download_cache_path) do |p|
444
+ SharedHelpers.filesystem_access(cache_path) do |p|
486
445
  FileUtils.mkdir_p(p)
487
446
  end
488
- download_gem(spec, download_cache_path, previous_spec)
489
-
490
- if requires_sudo?
491
- SharedHelpers.filesystem_access(cache_path) do |p|
492
- Bundler.mkdir_p(p)
493
- end
494
- Bundler.sudo "mv #{package_path(download_cache_path, spec)} #{gem_path}"
495
- end
447
+ download_gem(spec, cache_path, previous_spec)
496
448
 
497
449
  gem_path
498
- ensure
499
- Bundler.rm_rf(download_path) if requires_sudo?
500
450
  end
501
451
 
502
452
  def installed?(spec)
503
453
  installed_specs[spec].any? && !spec.deleted_gem?
504
454
  end
505
455
 
506
- def requires_sudo?
507
- Bundler.requires_sudo?
508
- end
509
-
510
456
  def rubygems_dir
511
457
  Bundler.bundle_path
512
458
  end
@@ -161,11 +161,17 @@ module Bundler
161
161
  end
162
162
 
163
163
  def map_sources(replacement_sources)
164
- [@rubygems_sources, @path_sources, @git_sources, @plugin_sources].map do |sources|
164
+ rubygems, git, plugin = [@rubygems_sources, @git_sources, @plugin_sources].map do |sources|
165
165
  sources.map do |source|
166
166
  replacement_sources.find {|s| s == source } || source
167
167
  end
168
168
  end
169
+
170
+ path = @path_sources.map do |source|
171
+ replacement_sources.find {|s| s == (source.is_a?(Source::Gemspec) ? source.as_path_source : source) } || source
172
+ end
173
+
174
+ [rubygems, path, git, plugin]
169
175
  end
170
176
 
171
177
  def global_replacement_source(replacement_sources)
@@ -206,7 +212,7 @@ module Bundler
206
212
  def warn_on_git_protocol(source)
207
213
  return if Bundler.settings["git.allow_insecure"]
208
214
 
209
- if source.uri =~ /^git\:/
215
+ if /^git\:/.match?(source.uri)
210
216
  Bundler.ui.warn "The git source `#{source.uri}` uses the `git` protocol, " \
211
217
  "which transmits data without encryption. Disable this warning with " \
212
218
  "`bundle config set --local git.allow_insecure true`, or switch to the `https` " \
@@ -122,8 +122,8 @@ module Bundler
122
122
  @specs.detect {|spec| spec.name == name && spec.match_platform(platform) }
123
123
  end
124
124
 
125
- def delete_by_name_and_version(name, version)
126
- @specs.reject! {|spec| spec.name == name && spec.version == version }
125
+ def delete_by_name(name)
126
+ @specs.reject! {|spec| spec.name == name }
127
127
  @lookup = nil
128
128
  @sorted = nil
129
129
  end
@@ -165,7 +165,7 @@ module Bundler
165
165
  cgems = extract_circular_gems(error)
166
166
  raise CyclicDependencyError, "Your bundle requires gems that depend" \
167
167
  " on each other, creating an infinite loop. Please remove either" \
168
- " gem '#{cgems[1]}' or gem '#{cgems[0]}' and try again."
168
+ " gem '#{cgems[0]}' or gem '#{cgems[1]}' and try again."
169
169
  end
170
170
  end
171
171
 
@@ -190,12 +190,10 @@ module Bundler
190
190
 
191
191
  def specs_for_dependency(dep, platform)
192
192
  specs_for_name = lookup[dep.name]
193
- if platform.nil?
194
- matching_specs = specs_for_name.map {|s| s.materialize_for_installation if Gem::Platform.match_spec?(s) }.compact
195
- GemHelpers.sort_best_platform_match(matching_specs, Bundler.local_platform)
196
- else
197
- GemHelpers.select_best_platform_match(specs_for_name, dep.force_ruby_platform ? Gem::Platform::RUBY : platform)
198
- end
193
+ target_platform = dep.force_ruby_platform ? Gem::Platform::RUBY : (platform || Bundler.local_platform)
194
+ matching_specs = GemHelpers.select_best_platform_match(specs_for_name, target_platform)
195
+ matching_specs.map!(&:materialize_for_installation).compact! if platform.nil?
196
+ matching_specs
199
197
  end
200
198
 
201
199
  def tsort_each_child(s)
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("<%= relative_gemfile_path %>", __dir
13
13
  bundle_binstub = File.expand_path("bundle", __dir__)
14
14
 
15
15
  if File.file?(bundle_binstub)
16
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
17
  load(bundle_binstub)
18
18
  else
19
19
  abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
@@ -62,8 +62,9 @@ m = Module.new do
62
62
 
63
63
  def bundler_requirement
64
64
  @bundler_requirement ||=
65
- env_var_version || cli_arg_version ||
66
- bundler_requirement_for(lockfile_version)
65
+ env_var_version ||
66
+ cli_arg_version ||
67
+ bundler_requirement_for(lockfile_version)
67
68
  end
68
69
 
69
70
  def bundler_requirement_for(version)
@@ -71,13 +72,7 @@ m = Module.new do
71
72
 
72
73
  bundler_gem_version = Gem::Version.new(version)
73
74
 
74
- requirement = bundler_gem_version.approximate_recommendation
75
-
76
- return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
77
-
78
- requirement += ".a" if bundler_gem_version.prerelease?
79
-
80
- requirement
75
+ bundler_gem_version.approximate_recommendation
81
76
  end
82
77
 
83
78
  def load_bundler!
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # This file was generated by Bundler.
4
6
  #
@@ -0,0 +1,7 @@
1
+ # This Cargo.toml is here to let externals tools (IDEs, etc.) know that this is
2
+ # a Rust project. Your extensions depedencies should be added to the Cargo.toml
3
+ # in the ext/ directory.
4
+
5
+ [workspace]
6
+ members = ["./ext/<%= config[:name] %>"]
7
+ resolver = "2"
@@ -9,6 +9,9 @@ gem "rake", "~> 13.0"
9
9
  <%- if config[:ext] -%>
10
10
 
11
11
  gem "rake-compiler"
12
+ <%- if config[:ext] == 'rust' -%>
13
+ gem "rb_sys"
14
+ <%- end -%>
12
15
  <%- end -%>
13
16
  <%- if config[:test] -%>
14
17
 
@@ -1,18 +1,20 @@
1
1
  # <%= config[:constant_name] %>
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/<%= config[:namespaced_path] %>`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ TODO: Delete this and the text below, and describe your gem
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/<%= config[:namespaced_path] %>`. To experiment with that code, run `bin/console` for an interactive prompt.
6
6
 
7
7
  ## Installation
8
8
 
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
9
11
  Install the gem and add to the application's Gemfile by executing:
10
12
 
11
- $ bundle add <%= config[:name] %>
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
12
14
 
13
15
  If bundler is not being used to manage dependencies, install the gem by executing:
14
16
 
15
- $ gem install <%= config[:name] %>
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
16
18
 
17
19
  ## Usage
18
20
 
@@ -39,7 +39,8 @@ require "standard/rake"
39
39
 
40
40
  <% end -%>
41
41
  <% if config[:ext] -%>
42
- <% default_task_names.unshift(:clobber, :compile) -%>
42
+ <% default_task_names.unshift(:compile) -%>
43
+ <% default_task_names.unshift(:clobber) unless config[:ext] == 'rust' -%>
43
44
  require "rake/extensiontask"
44
45
 
45
46
  task build: :compile
@@ -3,8 +3,20 @@ jobs:
3
3
  build:
4
4
  docker:
5
5
  - image: ruby:<%= RUBY_VERSION %>
6
+ <%- if config[:ext] == 'rust' -%>
7
+ environment:
8
+ RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
9
+ <%- end -%>
6
10
  steps:
7
11
  - checkout
12
+ <%- if config[:ext] == 'rust' -%>
13
+ - run:
14
+ name: Install Rust/Cargo dependencies
15
+ command: apt-get update && apt-get install -y clang
16
+ - run:
17
+ name: Install a RubyGems version that can compile rust extensions
18
+ command: gem update --system '<%= ::Gem.rubygems_version %>'
19
+ <%- end -%>
8
20
  - run:
9
21
  name: Run the default task
10
22
  command: |
@@ -0,0 +1,15 @@
1
+ [package]
2
+ name = <%= config[:name].inspect %>
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ authors = ["<%= config[:author] %> <<%= config[:email] %>>"]
6
+ <%- if config[:mit] -%>
7
+ license = "MIT"
8
+ <%- end -%>
9
+ publish = false
10
+
11
+ [lib]
12
+ crate-type = ["cdylib"]
13
+
14
+ [dependencies]
15
+ magnus = { version = "0.4" }
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "rb_sys/mkmf"
5
+
6
+ create_rust_makefile(<%= config[:makefile_path].inspect %>)
@@ -0,0 +1,12 @@
1
+ use magnus::{define_module, function, prelude::*, Error};
2
+
3
+ fn hello(subject: String) -> String {
4
+ format!("Hello from Rust, {}!", subject)
5
+ }
6
+
7
+ #[magnus::init]
8
+ fn init() -> Result<(), Error> {
9
+ let module = <%= config[:constant_array].map {|c| "define_module(#{c.dump})?"}.join(".") %>;
10
+ module.define_singleton_method("hello", function!(hello, 1))?;
11
+ Ok(())
12
+ }
@@ -18,10 +18,20 @@ jobs:
18
18
 
19
19
  steps:
20
20
  - uses: actions/checkout@v3
21
+ <%- if config[:ext] == 'rust' -%>
22
+ - name: Set up Ruby & Rust
23
+ uses: oxidize-rb/actions/setup-ruby-and-rust@main
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+ bundler-cache: true
27
+ cargo-cache: true
28
+ rubygems: '<%= ::Gem.rubygems_version %>'
29
+ <%- else -%>
21
30
  - name: Set up Ruby
22
31
  uses: ruby/setup-ruby@v1
23
32
  with:
24
33
  ruby-version: ${{ matrix.ruby }}
25
34
  bundler-cache: true
35
+ <%- end -%>
26
36
  - name: Run the default task
27
37
  run: bundle exec rake
@@ -12,6 +12,9 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ <%- if config[:ext] == 'rust' -%>
16
+ target/
17
+ <%- end -%>
15
18
  <%- end -%>
16
19
  <%- if config[:test] == "rspec" -%>
17
20
 
@@ -2,9 +2,17 @@ default:
2
2
  image: ruby:<%= RUBY_VERSION %>
3
3
 
4
4
  before_script:
5
+ <%- if config[:ext] == 'rust' -%>
6
+ - apt-get update && apt-get install -y clang
7
+ - gem update --system '<%= ::Gem.rubygems_version %>'
8
+ <%- end -%>
5
9
  - gem install bundler -v <%= Bundler::VERSION %>
6
10
  - bundle install
7
11
 
8
12
  example_job:
13
+ <%- if config[:ext] == 'rust' -%>
14
+ variables:
15
+ RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
16
+ <%- end -%>
9
17
  script:
10
18
  - bundle exec rake
@@ -15,6 +15,9 @@ Gem::Specification.new do |spec|
15
15
  spec.license = "MIT"
16
16
  <%- end -%>
17
17
  spec.required_ruby_version = ">= <%= config[:required_ruby_version] %>"
18
+ <%- if config[:ext] == 'rust' -%>
19
+ spec.required_rubygems_version = ">= <%= config[:rust_builder_required_rubygems_version] %>"
20
+ <%- end -%>
18
21
 
19
22
  spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
20
23
 
@@ -26,15 +29,18 @@ Gem::Specification.new do |spec|
26
29
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
30
  spec.files = Dir.chdir(__dir__) do
28
31
  `git ls-files -z`.split("\x0").reject do |f|
29
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
32
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
30
33
  end
31
34
  end
32
35
  spec.bindir = "exe"
33
36
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
37
  spec.require_paths = ["lib"]
35
- <%- if config[:ext] -%>
38
+ <%- if config[:ext] == 'c' -%>
36
39
  spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
37
40
  <%- end -%>
41
+ <%- if config[:ext] == 'rust' -%>
42
+ spec.extensions = ["ext/<%= config[:underscored_name] %>/Cargo.toml"]
43
+ <%- end -%>
38
44
 
39
45
  # Uncomment to register a new dependency of your gem
40
46
  # spec.add_dependency "example-gem", "~> 1.0"
@@ -20,29 +20,52 @@ module Bundler
20
20
  @shell.set_color(string, *color)
21
21
  end
22
22
 
23
- def info(msg, newline = nil)
24
- tell_me(msg, nil, newline) if level("info")
23
+ def info(msg = nil, newline = nil)
24
+ return unless info?
25
+
26
+ tell_me(msg || yield, nil, newline)
25
27
  end
26
28
 
27
- def confirm(msg, newline = nil)
28
- tell_me(msg, :green, newline) if level("confirm")
29
+ def confirm(msg = nil, newline = nil)
30
+ return unless confirm?
31
+
32
+ tell_me(msg || yield, :green, newline)
29
33
  end
30
34
 
31
- def warn(msg, newline = nil, color = :yellow)
32
- return unless level("warn")
35
+ def warn(msg = nil, newline = nil, color = :yellow)
36
+ return unless warn?
33
37
  return if @warning_history.include? msg
34
38
  @warning_history << msg
35
39
 
36
- tell_err(msg, color, newline)
40
+ tell_err(msg || yield, color, newline)
41
+ end
42
+
43
+ def error(msg = nil, newline = nil, color = :red)
44
+ return unless error?
45
+
46
+ tell_err(msg || yield, color, newline)
47
+ end
48
+
49
+ def debug(msg = nil, newline = nil)
50
+ return unless debug?
51
+
52
+ tell_me(msg || yield, nil, newline)
53
+ end
54
+
55
+ def info?
56
+ level("info")
57
+ end
58
+
59
+ def confirm?
60
+ level("confirm")
37
61
  end
38
62
 
39
- def error(msg, newline = nil, color = :red)
40
- return unless level("error")
41
- tell_err(msg, color, newline)
63
+ def warn?
64
+ level("warn")
42
65
  end
43
66
 
44
- def debug(msg, newline = nil)
45
- tell_me(msg, nil, newline) if debug?
67
+ def error?
68
+ level("error")
46
69
  end
47
70
 
48
71
  def debug?
@@ -13,30 +13,46 @@ module Bundler
13
13
  string
14
14
  end
15
15
 
16
- def info(message, newline = nil)
16
+ def info(message = nil, newline = nil)
17
17
  end
18
18
 
19
- def confirm(message, newline = nil)
19
+ def confirm(message = nil, newline = nil)
20
20
  end
21
21
 
22
- def warn(message, newline = nil)
22
+ def warn(message = nil, newline = nil)
23
23
  @warnings |= [message]
24
24
  end
25
25
 
26
- def error(message, newline = nil)
26
+ def error(message = nil, newline = nil)
27
27
  end
28
28
 
29
- def debug(message, newline = nil)
29
+ def debug(message = nil, newline = nil)
30
+ end
31
+
32
+ def confirm?
33
+ false
34
+ end
35
+
36
+ def error?
37
+ false
30
38
  end
31
39
 
32
40
  def debug?
33
41
  false
34
42
  end
35
43
 
44
+ def info?
45
+ false
46
+ end
47
+
36
48
  def quiet?
37
49
  false
38
50
  end
39
51
 
52
+ def warn?
53
+ false
54
+ end
55
+
40
56
  def ask(message)
41
57
  end
42
58
 
@@ -49,7 +49,7 @@ class Bundler::ConnectionPool::TimedStack
49
49
  @resource.broadcast
50
50
  end
51
51
  end
52
- alias << push
52
+ alias_method :<<, :push
53
53
 
54
54
  ##
55
55
  # Retrieves a connection from the stack. If a connection is available it is
@@ -74,7 +74,7 @@ class Bundler::ConnectionPool::TimedStack
74
74
  return connection if connection
75
75
 
76
76
  to_wait = deadline - current_time
77
- raise Bundler::ConnectionPool::TimeoutError, "Waited #{timeout} sec" if to_wait <= 0
77
+ raise Bundler::ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available" if to_wait <= 0
78
78
  @resource.wait(@mutex, to_wait)
79
79
  end
80
80
  end
@@ -87,7 +87,7 @@ class Bundler::ConnectionPool::TimedStack
87
87
  # +:reload+ is +true+.
88
88
 
89
89
  def shutdown(reload: false, &block)
90
- raise ArgumentError, "shutdown must receive a block" unless block_given?
90
+ raise ArgumentError, "shutdown must receive a block" unless block
91
91
 
92
92
  @mutex.synchronize do
93
93
  @shutdown_block = block
@@ -30,7 +30,6 @@ class Bundler::ConnectionPool
30
30
  METHODS.include?(id) || with { |c| c.respond_to?(id, *args) }
31
31
  end
32
32
 
33
- # rubocop:disable Style/MethodMissingSuper
34
33
  # rubocop:disable Style/MissingRespondToMissing
35
34
  if ::RUBY_VERSION >= "3.0.0"
36
35
  def method_missing(name, *args, **kwargs, &block)
@@ -3,7 +3,9 @@ require_relative "connection_pool/version"
3
3
 
4
4
  class Bundler::ConnectionPool
5
5
  class Error < ::RuntimeError; end
6
+
6
7
  class PoolShuttingDownError < ::Bundler::ConnectionPool::Error; end
8
+
7
9
  class TimeoutError < ::Timeout::Error; end
8
10
  end
9
11
 
@@ -67,7 +69,7 @@ class Bundler::ConnectionPool
67
69
  end
68
70
  end
69
71
  end
70
- alias then with
72
+ alias_method :then, :with
71
73
 
72
74
  def checkout(options = {})
73
75
  if ::Thread.current[@key]