bundler 2.2.16 → 2.4.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (280) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +971 -7
  3. data/README.md +4 -7
  4. data/bundler.gemspec +10 -13
  5. data/exe/bundle +12 -24
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/cli/add.rb +1 -1
  10. data/lib/bundler/cli/binstubs.rb +6 -2
  11. data/lib/bundler/cli/cache.rb +1 -1
  12. data/lib/bundler/cli/check.rb +5 -3
  13. data/lib/bundler/cli/common.rb +6 -2
  14. data/lib/bundler/cli/config.rb +10 -1
  15. data/lib/bundler/cli/console.rb +2 -2
  16. data/lib/bundler/cli/doctor.rb +22 -5
  17. data/lib/bundler/cli/exec.rb +1 -6
  18. data/lib/bundler/cli/gem.rb +147 -35
  19. data/lib/bundler/cli/info.rb +28 -7
  20. data/lib/bundler/cli/init.rb +6 -2
  21. data/lib/bundler/cli/install.rb +26 -58
  22. data/lib/bundler/cli/issue.rb +4 -3
  23. data/lib/bundler/cli/list.rb +7 -1
  24. data/lib/bundler/cli/lock.rb +11 -4
  25. data/lib/bundler/cli/open.rb +7 -6
  26. data/lib/bundler/cli/outdated.rb +23 -17
  27. data/lib/bundler/cli/platform.rb +8 -6
  28. data/lib/bundler/cli/remove.rb +1 -2
  29. data/lib/bundler/cli/show.rb +1 -1
  30. data/lib/bundler/cli/update.rb +17 -8
  31. data/lib/bundler/cli/viz.rb +1 -1
  32. data/lib/bundler/cli.rb +95 -65
  33. data/lib/bundler/compact_index_client/cache.rb +1 -10
  34. data/lib/bundler/compact_index_client/updater.rb +56 -43
  35. data/lib/bundler/compact_index_client.rb +2 -8
  36. data/lib/bundler/constants.rb +1 -1
  37. data/lib/bundler/current_ruby.rb +19 -6
  38. data/lib/bundler/definition.rb +386 -419
  39. data/lib/bundler/dependency.rb +24 -71
  40. data/lib/bundler/digest.rb +71 -0
  41. data/lib/bundler/dsl.rb +48 -63
  42. data/lib/bundler/endpoint_specification.rb +15 -13
  43. data/lib/bundler/env.rb +3 -3
  44. data/lib/bundler/environment_preserver.rb +7 -3
  45. data/lib/bundler/errors.rb +30 -14
  46. data/lib/bundler/feature_flag.rb +0 -5
  47. data/lib/bundler/fetcher/base.rb +6 -8
  48. data/lib/bundler/fetcher/compact_index.rb +21 -28
  49. data/lib/bundler/fetcher/dependency.rb +2 -6
  50. data/lib/bundler/fetcher/downloader.rb +12 -10
  51. data/lib/bundler/fetcher/index.rb +1 -29
  52. data/lib/bundler/fetcher.rb +35 -30
  53. data/lib/bundler/force_platform.rb +18 -0
  54. data/lib/bundler/friendly_errors.rb +26 -39
  55. data/lib/bundler/gem_helper.rb +10 -22
  56. data/lib/bundler/gem_helpers.rb +9 -2
  57. data/lib/bundler/gem_version_promoter.rb +53 -98
  58. data/lib/bundler/graph.rb +3 -3
  59. data/lib/bundler/index.rb +14 -57
  60. data/lib/bundler/injector.rb +20 -6
  61. data/lib/bundler/inline.rb +10 -22
  62. data/lib/bundler/installer/gem_installer.rb +16 -21
  63. data/lib/bundler/installer/parallel_installer.rb +4 -34
  64. data/lib/bundler/installer/standalone.rb +53 -17
  65. data/lib/bundler/installer.rb +26 -58
  66. data/lib/bundler/lazy_specification.rb +72 -55
  67. data/lib/bundler/lockfile_generator.rb +3 -3
  68. data/lib/bundler/lockfile_parser.rb +31 -45
  69. data/lib/bundler/man/bundle-add.1 +21 -5
  70. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  71. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  72. data/lib/bundler/man/bundle-cache.1 +9 -3
  73. data/lib/bundler/man/bundle-cache.1.ronn +9 -2
  74. data/lib/bundler/man/bundle-check.1 +1 -1
  75. data/lib/bundler/man/bundle-clean.1 +2 -2
  76. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  77. data/lib/bundler/man/bundle-config.1 +50 -26
  78. data/lib/bundler/man/bundle-config.1.ronn +47 -32
  79. data/lib/bundler/man/bundle-console.1 +53 -0
  80. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  81. data/lib/bundler/man/bundle-doctor.1 +1 -1
  82. data/lib/bundler/man/bundle-exec.1 +6 -6
  83. data/lib/bundler/man/bundle-exec.1.ronn +6 -6
  84. data/lib/bundler/man/bundle-gem.1 +37 -34
  85. data/lib/bundler/man/bundle-gem.1.ronn +21 -5
  86. data/lib/bundler/man/bundle-help.1 +13 -0
  87. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  88. data/lib/bundler/man/bundle-info.1 +3 -3
  89. data/lib/bundler/man/bundle-info.1.ronn +3 -3
  90. data/lib/bundler/man/bundle-init.1 +5 -1
  91. data/lib/bundler/man/bundle-init.1.ronn +2 -0
  92. data/lib/bundler/man/bundle-inject.1 +5 -2
  93. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  94. data/lib/bundler/man/bundle-install.1 +6 -31
  95. data/lib/bundler/man/bundle-install.1.ronn +8 -31
  96. data/lib/bundler/man/bundle-list.1 +1 -1
  97. data/lib/bundler/man/bundle-lock.1 +1 -1
  98. data/lib/bundler/man/bundle-open.1 +22 -2
  99. data/lib/bundler/man/bundle-open.1.ronn +9 -1
  100. data/lib/bundler/man/bundle-outdated.1 +15 -18
  101. data/lib/bundler/man/bundle-outdated.1.ronn +13 -19
  102. data/lib/bundler/man/bundle-platform.1 +16 -6
  103. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  104. data/lib/bundler/man/bundle-plugin.1 +81 -0
  105. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  106. data/lib/bundler/man/bundle-pristine.1 +1 -1
  107. data/lib/bundler/man/bundle-remove.1 +1 -1
  108. data/lib/bundler/man/bundle-show.1 +1 -1
  109. data/lib/bundler/man/bundle-update.1 +5 -5
  110. data/lib/bundler/man/bundle-update.1.ronn +5 -4
  111. data/lib/bundler/man/bundle-version.1 +35 -0
  112. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  113. data/lib/bundler/man/bundle-viz.1 +4 -1
  114. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  115. data/lib/bundler/man/bundle.1 +15 -10
  116. data/lib/bundler/man/bundle.1.ronn +12 -7
  117. data/lib/bundler/man/gemfile.5 +131 -81
  118. data/lib/bundler/man/gemfile.5.ronn +111 -85
  119. data/lib/bundler/man/index.txt +4 -0
  120. data/lib/bundler/match_metadata.rb +13 -0
  121. data/lib/bundler/match_platform.rb +0 -1
  122. data/lib/bundler/match_remote_metadata.rb +29 -0
  123. data/lib/bundler/mirror.rb +5 -7
  124. data/lib/bundler/plugin/api/source.rb +17 -8
  125. data/lib/bundler/plugin/index.rb +9 -6
  126. data/lib/bundler/plugin/installer/git.rb +0 -4
  127. data/lib/bundler/plugin/installer/rubygems.rb +0 -8
  128. data/lib/bundler/plugin/installer.rb +9 -4
  129. data/lib/bundler/plugin.rb +30 -9
  130. data/lib/bundler/process_lock.rb +1 -1
  131. data/lib/bundler/remote_specification.rb +7 -5
  132. data/lib/bundler/resolver/base.rb +107 -0
  133. data/lib/bundler/resolver/candidate.rb +94 -0
  134. data/lib/bundler/resolver/incompatibility.rb +15 -0
  135. data/lib/bundler/resolver/package.rb +72 -0
  136. data/lib/bundler/resolver/root.rb +25 -0
  137. data/lib/bundler/resolver/spec_group.rb +42 -94
  138. data/lib/bundler/resolver.rb +331 -381
  139. data/lib/bundler/retry.rb +1 -1
  140. data/lib/bundler/ruby_dsl.rb +7 -1
  141. data/lib/bundler/ruby_version.rb +8 -21
  142. data/lib/bundler/rubygems_ext.rb +175 -34
  143. data/lib/bundler/rubygems_gem_installer.rb +46 -14
  144. data/lib/bundler/rubygems_integration.rb +57 -108
  145. data/lib/bundler/runtime.rb +20 -18
  146. data/lib/bundler/safe_marshal.rb +31 -0
  147. data/lib/bundler/self_manager.rb +168 -0
  148. data/lib/bundler/settings.rb +101 -30
  149. data/lib/bundler/setup.rb +5 -2
  150. data/lib/bundler/shared_helpers.rb +17 -32
  151. data/lib/bundler/source/git/git_proxy.rb +242 -77
  152. data/lib/bundler/source/git.rb +82 -41
  153. data/lib/bundler/source/metadata.rb +3 -4
  154. data/lib/bundler/source/path/installer.rb +1 -22
  155. data/lib/bundler/source/path.rb +7 -7
  156. data/lib/bundler/source/rubygems.rb +158 -212
  157. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  158. data/lib/bundler/source.rb +19 -5
  159. data/lib/bundler/source_list.rb +91 -52
  160. data/lib/bundler/source_map.rb +71 -0
  161. data/lib/bundler/spec_set.rb +69 -57
  162. data/lib/bundler/stub_specification.rb +5 -3
  163. data/lib/bundler/templates/Executable +3 -5
  164. data/lib/bundler/templates/Executable.bundler +11 -16
  165. data/lib/bundler/templates/Executable.standalone +4 -4
  166. data/lib/bundler/templates/Gemfile +0 -2
  167. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  168. data/lib/bundler/templates/newgem/Gemfile.tt +8 -2
  169. data/lib/bundler/templates/newgem/README.md.tt +7 -11
  170. data/lib/bundler/templates/newgem/Rakefile.tt +27 -3
  171. data/lib/bundler/templates/newgem/bin/console.tt +0 -4
  172. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  173. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  174. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  175. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  176. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  177. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  178. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +24 -3
  179. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  180. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
  181. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -18
  182. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  183. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  184. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  185. data/lib/bundler/ui/rg_proxy.rb +1 -1
  186. data/lib/bundler/ui/shell.rb +36 -13
  187. data/lib/bundler/ui/silent.rb +21 -5
  188. data/lib/bundler/uri_normalizer.rb +23 -0
  189. data/lib/bundler/vendor/.document +1 -0
  190. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  191. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  192. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  193. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  194. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +41 -74
  195. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  196. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1351 -409
  197. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  198. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  199. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  200. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  201. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  202. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  203. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  204. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  205. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  206. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  207. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  208. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  209. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  210. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  211. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  212. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  213. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  214. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  215. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  216. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  217. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +5 -5
  218. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  219. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  220. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  221. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  222. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  223. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +23 -5
  224. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  225. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  226. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  227. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  228. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  229. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  230. data/lib/bundler/vendor/uri/lib/uri/common.rb +76 -91
  231. data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
  232. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -2
  233. data/lib/bundler/vendor/uri/lib/uri/generic.rb +32 -13
  234. data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
  235. data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
  236. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
  237. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  238. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
  239. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -23
  240. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +12 -18
  241. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  242. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  243. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  244. data/lib/bundler/vendor/uri/lib/uri.rb +3 -3
  245. data/lib/bundler/vendored_persistent.rb +1 -33
  246. data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  247. data/lib/bundler/{vendored_tmpdir.rb → vendored_tsort.rb} +1 -1
  248. data/lib/bundler/version.rb +5 -1
  249. data/lib/bundler/worker.rb +24 -11
  250. data/lib/bundler.rb +66 -110
  251. metadata +70 -41
  252. data/lib/bundler/dep_proxy.rb +0 -55
  253. data/lib/bundler/gemdeps.rb +0 -29
  254. data/lib/bundler/psyched_yaml.rb +0 -22
  255. data/lib/bundler/templates/gems.rb +0 -8
  256. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
  257. data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  258. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  259. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  260. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  261. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  262. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  263. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  264. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  265. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  266. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  267. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  268. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  269. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  270. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  271. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  272. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  273. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  274. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  275. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  276. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  277. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  278. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  279. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  280. data/lib/bundler/version_ranges.rb +0 -122
@@ -41,13 +41,13 @@ m = Module.new do
41
41
  gemfile = ENV["BUNDLE_GEMFILE"]
42
42
  return gemfile if gemfile && !gemfile.empty?
43
43
 
44
- File.expand_path("../<%= relative_gemfile_path %>", __FILE__)
44
+ File.expand_path("<%= relative_gemfile_path %>", __dir__)
45
45
  end
46
46
 
47
47
  def lockfile
48
48
  lockfile =
49
49
  case File.basename(gemfile)
50
- when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
51
51
  else "#{gemfile}.lock"
52
52
  end
53
53
  File.expand_path(lockfile)
@@ -60,24 +60,19 @@ m = Module.new do
60
60
  Regexp.last_match(1)
61
61
  end
62
62
 
63
- def bundler_version
64
- @bundler_version ||=
65
- env_var_version || cli_arg_version ||
66
- lockfile_version
67
- end
68
-
69
63
  def bundler_requirement
70
- return "#{Gem::Requirement.default}.a" unless bundler_version
71
-
72
- bundler_gem_version = Gem::Version.new(bundler_version)
73
-
74
- requirement = bundler_gem_version.approximate_recommendation
64
+ @bundler_requirement ||=
65
+ env_var_version ||
66
+ cli_arg_version ||
67
+ bundler_requirement_for(lockfile_version)
68
+ end
75
69
 
76
- return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
70
+ def bundler_requirement_for(version)
71
+ return "#{Gem::Requirement.default}.a" unless version
77
72
 
78
- requirement += ".a" if bundler_gem_version.prerelease?
73
+ bundler_gem_version = Gem::Version.new(version)
79
74
 
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
  #
@@ -6,9 +8,7 @@
6
8
  # this file is here to facilitate running it.
7
9
  #
8
10
 
9
- require "pathname"
10
- path = Pathname.new(__FILE__)
11
- $:.unshift File.expand_path "../<%= standalone_path %>", path.realpath
11
+ $:.unshift File.expand_path "<%= standalone_path %>", __dir__
12
12
 
13
13
  require "bundler/setup"
14
- load File.expand_path "../<%= executable_path %>", path.realpath
14
+ load File.expand_path "<%= executable_path %>", __dir__
@@ -2,6 +2,4 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
-
7
5
  # gem "rails"
@@ -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 dependencies should be added to the Cargo.toml
3
+ # in the ext/ directory.
4
+
5
+ [workspace]
6
+ members = ["./ext/<%= config[:name] %>"]
7
+ resolver = "2"
@@ -9,12 +9,18 @@ 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", "~> 0.9.63"
14
+ <%- end -%>
12
15
  <%- end -%>
13
16
  <%- if config[:test] -%>
14
17
 
15
18
  gem "<%= config[:test] %>", "~> <%= config[:test_framework_version] %>"
16
19
  <%- end -%>
17
- <%- if config[:rubocop] -%>
20
+ <%- if config[:linter] == "rubocop" -%>
21
+
22
+ gem "rubocop", "~> <%= config[:linter_version] %>"
23
+ <%- elsif config[:linter] == "standard" -%>
18
24
 
19
- gem "rubocop", "~> <%= config[:rubocop_version] %>"
25
+ gem "standard", "~> <%= config[:linter_version] %>"
20
26
  <%- end -%>
@@ -1,24 +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
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem '<%= config[:name] %>'
13
- ```
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.
14
10
 
15
- And then execute:
11
+ Install the gem and add to the application's Gemfile by executing:
16
12
 
17
- $ bundle install
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
14
 
19
- Or install it yourself as:
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
20
16
 
21
- $ gem install <%= config[:name] %>
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
22
18
 
23
19
  ## Usage
24
20
 
@@ -3,7 +3,16 @@
3
3
  require "bundler/gem_tasks"
4
4
  <% default_task_names = [config[:test_task]].compact -%>
5
5
  <% case config[:test] -%>
6
- <% when "minitest", "test-unit" -%>
6
+ <% when "minitest" -%>
7
+ require "rake/testtask"
8
+
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << "test"
11
+ t.libs << "lib"
12
+ t.test_files = FileList["test/**/test_*.rb"]
13
+ end
14
+
15
+ <% when "test-unit" -%>
7
16
  require "rake/testtask"
8
17
 
9
18
  Rake::TestTask.new(:test) do |t|
@@ -18,15 +27,29 @@ require "rspec/core/rake_task"
18
27
  RSpec::Core::RakeTask.new(:spec)
19
28
 
20
29
  <% end -%>
21
- <% if config[:rubocop] -%>
30
+ <% if config[:linter] == "rubocop" -%>
22
31
  <% default_task_names << :rubocop -%>
23
32
  require "rubocop/rake_task"
24
33
 
25
34
  RuboCop::RakeTask.new
26
35
 
36
+ <% elsif config[:linter] == "standard" -%>
37
+ <% default_task_names << :standard -%>
38
+ require "standard/rake"
39
+
27
40
  <% end -%>
28
41
  <% if config[:ext] -%>
29
- <% default_task_names.unshift(:clobber, :compile) -%>
42
+ <% default_task_names.unshift(:compile) -%>
43
+ <% default_task_names.unshift(:clobber) unless config[:ext] == 'rust' -%>
44
+ <% if config[:ext] == 'rust' -%>
45
+ require "rb_sys/extensiontask"
46
+
47
+ task build: :compile
48
+
49
+ RbSys::ExtensionTask.new(<%= config[:name].inspect %>) do |ext|
50
+ ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
51
+ end
52
+ <% else -%>
30
53
  require "rake/extensiontask"
31
54
 
32
55
  task build: :compile
@@ -34,6 +57,7 @@ task build: :compile
34
57
  Rake::ExtensionTask.new("<%= config[:underscored_name] %>") do |ext|
35
58
  ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
36
59
  end
60
+ <% end -%>
37
61
 
38
62
  <% end -%>
39
63
  <% if default_task_names.size == 1 -%>
@@ -7,9 +7,5 @@ require "<%= config[:namespaced_path] %>"
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
9
9
 
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
10
  require "irb"
15
11
  IRB.start(__FILE__)
@@ -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.6" }
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+
5
+ # Makes all symbols private by default to avoid unintended conflict
6
+ # with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
7
+ # selectively, or entirely remove this flag.
8
+ append_cflags("-fvisibility=hidden")
9
+
10
+ create_makefile(<%= config[:makefile_path].inspect %>)
@@ -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 %>)
@@ -2,7 +2,7 @@
2
2
 
3
3
  VALUE rb_m<%= config[:constant_array].join %>;
4
4
 
5
- void
5
+ RUBY_FUNC_EXPORTED void
6
6
  Init_<%= config[:underscored_name] %>(void)
7
7
  {
8
8
  rb_m<%= config[:constant_array].join %> = rb_define_module(<%= config[:constant_name].inspect %>);
@@ -0,0 +1,12 @@
1
+ use magnus::{function, prelude::*, Error, Ruby};
2
+
3
+ fn hello(subject: String) -> String {
4
+ format!("Hello from Rust, {subject}!")
5
+ }
6
+
7
+ #[magnus::init]
8
+ fn init(ruby: &Ruby) -> Result<(), Error> {
9
+ let module = ruby.<%= config[:constant_array].map {|c| "define_module(#{c.dump})?"}.join(".") %>;
10
+ module.define_singleton_method("hello", function!(hello, 1))?;
11
+ Ok(())
12
+ }
@@ -1,16 +1,37 @@
1
1
  name: Ruby
2
2
 
3
- on: [push,pull_request]
3
+ on:
4
+ push:
5
+ branches:
6
+ - <%= config[:git_default_branch] %>
7
+
8
+ pull_request:
4
9
 
5
10
  jobs:
6
11
  build:
7
12
  runs-on: ubuntu-latest
13
+ name: Ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ matrix:
16
+ ruby:
17
+ - '<%= RUBY_VERSION %>'
18
+
8
19
  steps:
9
- - uses: actions/checkout@v2
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@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+ bundler-cache: true
27
+ cargo-cache: true
28
+ rubygems: '<%= ::Gem.rubygems_version %>'
29
+ <%- else -%>
10
30
  - name: Set up Ruby
11
31
  uses: ruby/setup-ruby@v1
12
32
  with:
13
- ruby-version: <%= RUBY_VERSION %>
33
+ ruby-version: ${{ matrix.ruby }}
14
34
  bundler-cache: true
35
+ <%- end -%>
15
36
  - name: Run the default task
16
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
 
@@ -1,9 +1,18 @@
1
- image: ruby:<%= RUBY_VERSION %>
1
+ default:
2
+ image: ruby:<%= RUBY_VERSION %>
2
3
 
3
- before_script:
4
- - gem install bundler -v <%= Bundler::VERSION %>
5
- - bundle install
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 -%>
9
+ - gem install bundler -v <%= Bundler::VERSION %>
10
+ - bundle install
6
11
 
7
12
  example_job:
13
+ <%- if config[:ext] == 'rust' -%>
14
+ variables:
15
+ RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
16
+ <%- end -%>
8
17
  script:
9
18
  - bundle exec rake
@@ -3,20 +3,23 @@
3
3
  require_relative "lib/<%=config[:namespaced_path]%>/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = <%= config[:name].inspect %>
7
- spec.version = <%= config[:constant_name] %>::VERSION
8
- spec.authors = [<%= config[:author].inspect %>]
9
- spec.email = [<%= config[:email].inspect %>]
10
-
11
- spec.summary = "TODO: Write a short summary, because RubyGems requires one."
12
- spec.description = "TODO: Write a longer description or delete this line."
13
- spec.homepage = "TODO: Put your gem's website or public repo URL here."
6
+ spec.name = <%= config[:name].inspect %>
7
+ spec.version = <%= config[:constant_name] %>::VERSION
8
+ spec.authors = [<%= config[:author].inspect %>]
9
+ spec.email = [<%= config[:email].inspect %>]
10
+
11
+ spec.summary = "TODO: Write a short summary, because RubyGems requires one."
12
+ spec.description = "TODO: Write a longer description or delete this line."
13
+ spec.homepage = "TODO: Put your gem's website or public repo URL here."
14
14
  <%- if config[:mit] -%>
15
- spec.license = "MIT"
15
+ spec.license = "MIT"
16
+ <%- end -%>
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] %>"
16
20
  <%- end -%>
17
- spec.required_ruby_version = Gem::Requirement.new(">= <%= config[:required_ruby_version] %>")
18
21
 
19
- spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
22
+ spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
20
23
 
21
24
  spec.metadata["homepage_uri"] = spec.homepage
22
25
  spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
@@ -24,19 +27,25 @@ Gem::Specification.new do |spec|
24
27
 
25
28
  # Specify which files should be added to the gem when it is released.
26
29
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
30
+ spec.files = Dir.chdir(__dir__) do
31
+ `git ls-files -z`.split("\x0").reject do |f|
32
+ (File.expand_path(f) == __FILE__) ||
33
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
34
+ end
29
35
  end
30
- spec.bindir = "exe"
31
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
36
+ spec.bindir = "exe"
37
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
38
  spec.require_paths = ["lib"]
33
- <%- if config[:ext] -%>
34
- spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
39
+ <%- if config[:ext] == 'c' -%>
40
+ spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
41
+ <%- end -%>
42
+ <%- if config[:ext] == 'rust' -%>
43
+ spec.extensions = ["ext/<%= config[:underscored_name] %>/Cargo.toml"]
35
44
  <%- end -%>
36
45
 
37
46
  # Uncomment to register a new dependency of your gem
38
47
  # spec.add_dependency "example-gem", "~> 1.0"
39
48
 
40
- # For more information and examples about making a new gem, checkout our
49
+ # For more information and examples about making a new gem, check out our
41
50
  # guide at: https://bundler.io/guides/creating_gem.html
42
51
  end
@@ -0,0 +1,8 @@
1
+ <%- config[:constant_array].each_with_index do |c, i| -%>
2
+ <%= " " * i %>module <%= c %>
3
+ <%- end -%>
4
+ <%= " " * config[:constant_array].size %>VERSION: String
5
+ <%= " " * config[:constant_array].size %># See the writing guide of rbs: https://github.com/ruby/rbs#guides
6
+ <%- (config[:constant_array].size-1).downto(0) do |i| -%>
7
+ <%= " " * i %>end
8
+ <%- end -%>
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: <%= ::Gem::Version.new(config[:required_ruby_version]).segments[0..1].join(".") %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "test_helper"
4
4
 
5
- class <%= config[:constant_name] %>Test < Minitest::Test
5
+ class <%= config[:minitest_constant_name] %> < Minitest::Test
6
6
  def test_that_it_has_a_version_number
7
7
  refute_nil ::<%= config[:constant_name] %>::VERSION
8
8
  end
@@ -12,7 +12,7 @@ module Bundler
12
12
  end
13
13
 
14
14
  def say(message)
15
- @ui && @ui.debug(message)
15
+ @ui&.debug(message)
16
16
  end
17
17
  end
18
18
  end
@@ -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?
@@ -81,7 +104,7 @@ module Bundler
81
104
  def trace(e, newline = nil, force = false)
82
105
  return unless debug? || force
83
106
  msg = "#{e.class}: #{e.message}\n#{e.backtrace.join("\n ")}"
84
- tell_me(msg, nil, newline)
107
+ tell_err(msg, nil, newline)
85
108
  end
86
109
 
87
110
  def silence(&blk)
@@ -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
 
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ module URINormalizer
5
+ module_function
6
+
7
+ # Normalizes uri to a consistent version, either with or without trailing
8
+ # slash.
9
+ #
10
+ # TODO: Currently gem sources are locked with a trailing slash, while git
11
+ # sources are locked without a trailing slash. This should be normalized but
12
+ # the inconsistency is there for now to avoid changing all lockfiles
13
+ # including GIT sources. We could normalize this on the next major.
14
+ #
15
+ def normalize_suffix(uri, trailing_slash: true)
16
+ if trailing_slash
17
+ uri.end_with?("/") ? uri : "#{uri}/"
18
+ else
19
+ uri.end_with?("/") ? uri.delete_suffix("/") : uri
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1 @@
1
+ # Vendored files do not need to be documented
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Mike Perham
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.