bundler 2.2.33 → 2.4.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +682 -1
  3. data/README.md +3 -6
  4. data/bundler.gemspec +8 -10
  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 +5 -1
  11. data/lib/bundler/cli/check.rb +1 -1
  12. data/lib/bundler/cli/common.rb +4 -2
  13. data/lib/bundler/cli/config.rb +10 -1
  14. data/lib/bundler/cli/console.rb +2 -2
  15. data/lib/bundler/cli/doctor.rb +7 -1
  16. data/lib/bundler/cli/gem.rb +73 -41
  17. data/lib/bundler/cli/info.rb +11 -2
  18. data/lib/bundler/cli/init.rb +6 -2
  19. data/lib/bundler/cli/install.rb +15 -33
  20. data/lib/bundler/cli/lock.rb +8 -5
  21. data/lib/bundler/cli/open.rb +6 -4
  22. data/lib/bundler/cli/outdated.rb +13 -6
  23. data/lib/bundler/cli/platform.rb +2 -2
  24. data/lib/bundler/cli/show.rb +1 -1
  25. data/lib/bundler/cli/update.rb +6 -2
  26. data/lib/bundler/cli/viz.rb +1 -1
  27. data/lib/bundler/cli.rb +63 -20
  28. data/lib/bundler/compact_index_client/cache.rb +1 -10
  29. data/lib/bundler/compact_index_client/updater.rb +53 -39
  30. data/lib/bundler/compact_index_client.rb +0 -6
  31. data/lib/bundler/constants.rb +1 -1
  32. data/lib/bundler/current_ruby.rb +18 -6
  33. data/lib/bundler/definition.rb +289 -165
  34. data/lib/bundler/dependency.rb +24 -71
  35. data/lib/bundler/digest.rb +1 -1
  36. data/lib/bundler/dsl.rb +13 -45
  37. data/lib/bundler/endpoint_specification.rb +15 -13
  38. data/lib/bundler/env.rb +2 -2
  39. data/lib/bundler/environment_preserver.rb +3 -2
  40. data/lib/bundler/errors.rb +15 -15
  41. data/lib/bundler/feature_flag.rb +0 -2
  42. data/lib/bundler/fetcher/base.rb +6 -8
  43. data/lib/bundler/fetcher/compact_index.rb +18 -25
  44. data/lib/bundler/fetcher/dependency.rb +2 -6
  45. data/lib/bundler/fetcher/downloader.rb +2 -5
  46. data/lib/bundler/fetcher/index.rb +0 -26
  47. data/lib/bundler/fetcher.rb +22 -29
  48. data/lib/bundler/force_platform.rb +18 -0
  49. data/lib/bundler/friendly_errors.rb +21 -7
  50. data/lib/bundler/gem_helper.rb +2 -2
  51. data/lib/bundler/gem_helpers.rb +9 -2
  52. data/lib/bundler/gem_version_promoter.rb +53 -98
  53. data/lib/bundler/graph.rb +3 -3
  54. data/lib/bundler/index.rb +13 -51
  55. data/lib/bundler/injector.rb +18 -4
  56. data/lib/bundler/inline.rb +9 -21
  57. data/lib/bundler/installer/gem_installer.rb +13 -5
  58. data/lib/bundler/installer/parallel_installer.rb +3 -33
  59. data/lib/bundler/installer/standalone.rb +42 -11
  60. data/lib/bundler/installer.rb +21 -45
  61. data/lib/bundler/lazy_specification.rb +55 -54
  62. data/lib/bundler/lockfile_generator.rb +3 -3
  63. data/lib/bundler/lockfile_parser.rb +29 -27
  64. data/lib/bundler/man/bundle-add.1 +21 -5
  65. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  66. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  67. data/lib/bundler/man/bundle-cache.1 +9 -3
  68. data/lib/bundler/man/bundle-cache.1.ronn +9 -2
  69. data/lib/bundler/man/bundle-check.1 +1 -1
  70. data/lib/bundler/man/bundle-clean.1 +2 -2
  71. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  72. data/lib/bundler/man/bundle-config.1 +32 -16
  73. data/lib/bundler/man/bundle-config.1.ronn +29 -20
  74. data/lib/bundler/man/bundle-console.1 +53 -0
  75. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  76. data/lib/bundler/man/bundle-doctor.1 +1 -1
  77. data/lib/bundler/man/bundle-exec.1 +6 -6
  78. data/lib/bundler/man/bundle-exec.1.ronn +6 -6
  79. data/lib/bundler/man/bundle-gem.1 +27 -37
  80. data/lib/bundler/man/bundle-gem.1.ronn +5 -5
  81. data/lib/bundler/man/bundle-help.1 +13 -0
  82. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  83. data/lib/bundler/man/bundle-info.1 +1 -1
  84. data/lib/bundler/man/bundle-init.1 +5 -1
  85. data/lib/bundler/man/bundle-init.1.ronn +2 -0
  86. data/lib/bundler/man/bundle-inject.1 +5 -2
  87. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  88. data/lib/bundler/man/bundle-install.1 +6 -31
  89. data/lib/bundler/man/bundle-install.1.ronn +8 -31
  90. data/lib/bundler/man/bundle-list.1 +1 -1
  91. data/lib/bundler/man/bundle-lock.1 +1 -1
  92. data/lib/bundler/man/bundle-open.1 +22 -2
  93. data/lib/bundler/man/bundle-open.1.ronn +9 -1
  94. data/lib/bundler/man/bundle-outdated.1 +15 -18
  95. data/lib/bundler/man/bundle-outdated.1.ronn +13 -19
  96. data/lib/bundler/man/bundle-platform.1 +16 -6
  97. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  98. data/lib/bundler/man/bundle-plugin.1 +81 -0
  99. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  100. data/lib/bundler/man/bundle-pristine.1 +1 -1
  101. data/lib/bundler/man/bundle-remove.1 +1 -1
  102. data/lib/bundler/man/bundle-show.1 +1 -1
  103. data/lib/bundler/man/bundle-update.1 +2 -2
  104. data/lib/bundler/man/bundle-update.1.ronn +2 -1
  105. data/lib/bundler/man/bundle-version.1 +35 -0
  106. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  107. data/lib/bundler/man/bundle-viz.1 +4 -1
  108. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  109. data/lib/bundler/man/bundle.1 +15 -10
  110. data/lib/bundler/man/bundle.1.ronn +12 -7
  111. data/lib/bundler/man/gemfile.5 +94 -83
  112. data/lib/bundler/man/gemfile.5.ronn +100 -87
  113. data/lib/bundler/man/index.txt +4 -0
  114. data/lib/bundler/match_metadata.rb +13 -0
  115. data/lib/bundler/match_platform.rb +0 -1
  116. data/lib/bundler/match_remote_metadata.rb +29 -0
  117. data/lib/bundler/mirror.rb +5 -7
  118. data/lib/bundler/plugin/api/source.rb +3 -9
  119. data/lib/bundler/plugin/index.rb +4 -4
  120. data/lib/bundler/plugin/installer/git.rb +0 -4
  121. data/lib/bundler/plugin/installer/rubygems.rb +0 -8
  122. data/lib/bundler/plugin/installer.rb +6 -3
  123. data/lib/bundler/plugin.rb +3 -1
  124. data/lib/bundler/process_lock.rb +1 -1
  125. data/lib/bundler/remote_specification.rb +7 -5
  126. data/lib/bundler/resolver/base.rb +107 -0
  127. data/lib/bundler/resolver/candidate.rb +94 -0
  128. data/lib/bundler/resolver/incompatibility.rb +15 -0
  129. data/lib/bundler/resolver/package.rb +72 -0
  130. data/lib/bundler/resolver/root.rb +25 -0
  131. data/lib/bundler/resolver/spec_group.rb +43 -71
  132. data/lib/bundler/resolver.rb +342 -302
  133. data/lib/bundler/ruby_dsl.rb +1 -1
  134. data/lib/bundler/ruby_version.rb +6 -19
  135. data/lib/bundler/rubygems_ext.rb +149 -28
  136. data/lib/bundler/rubygems_gem_installer.rb +32 -20
  137. data/lib/bundler/rubygems_integration.rb +24 -95
  138. data/lib/bundler/runtime.rb +2 -7
  139. data/lib/bundler/safe_marshal.rb +31 -0
  140. data/lib/bundler/self_manager.rb +168 -0
  141. data/lib/bundler/settings.rb +7 -12
  142. data/lib/bundler/setup.rb +4 -1
  143. data/lib/bundler/shared_helpers.rb +15 -22
  144. data/lib/bundler/source/git/git_proxy.rb +237 -74
  145. data/lib/bundler/source/git.rb +54 -38
  146. data/lib/bundler/source/metadata.rb +3 -4
  147. data/lib/bundler/source/path/installer.rb +1 -22
  148. data/lib/bundler/source/path.rb +7 -7
  149. data/lib/bundler/source/rubygems.rb +85 -128
  150. data/lib/bundler/source.rb +4 -5
  151. data/lib/bundler/source_list.rb +12 -2
  152. data/lib/bundler/source_map.rb +15 -2
  153. data/lib/bundler/spec_set.rb +62 -34
  154. data/lib/bundler/stub_specification.rb +5 -3
  155. data/lib/bundler/templates/Executable +3 -5
  156. data/lib/bundler/templates/Executable.bundler +6 -11
  157. data/lib/bundler/templates/Executable.standalone +4 -4
  158. data/lib/bundler/templates/Gemfile +0 -2
  159. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  160. data/lib/bundler/templates/newgem/Gemfile.tt +3 -0
  161. data/lib/bundler/templates/newgem/README.md.tt +7 -11
  162. data/lib/bundler/templates/newgem/Rakefile.tt +22 -2
  163. data/lib/bundler/templates/newgem/bin/console.tt +0 -4
  164. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  165. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  166. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  167. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  168. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  169. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  170. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +11 -1
  171. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  172. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
  173. data/lib/bundler/templates/newgem/newgem.gemspec.tt +11 -4
  174. data/lib/bundler/templates/newgem/standard.yml.tt +1 -0
  175. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  176. data/lib/bundler/ui/shell.rb +36 -13
  177. data/lib/bundler/ui/silent.rb +21 -5
  178. data/lib/bundler/uri_normalizer.rb +23 -0
  179. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +3 -3
  180. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +0 -1
  181. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +3 -1
  182. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1351 -409
  183. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  184. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  185. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  186. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  187. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  188. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  189. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  190. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  191. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  192. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  193. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  194. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  195. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  196. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  197. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  198. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  199. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  200. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  201. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  202. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  203. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  204. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  205. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  206. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  207. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  208. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +23 -5
  209. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  210. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  211. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  212. data/lib/bundler/vendor/tsort/lib/tsort.rb +318 -319
  213. data/lib/bundler/vendor/uri/lib/uri/common.rb +76 -91
  214. data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
  215. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -2
  216. data/lib/bundler/vendor/uri/lib/uri/generic.rb +32 -13
  217. data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
  218. data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
  219. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
  220. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  221. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
  222. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -23
  223. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +12 -18
  224. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  225. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  226. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  227. data/lib/bundler/vendor/uri/lib/uri.rb +3 -3
  228. data/lib/bundler/vendored_persistent.rb +1 -33
  229. data/lib/bundler/{vendored_tmpdir.rb → vendored_pub_grub.rb} +1 -1
  230. data/lib/bundler/version.rb +5 -1
  231. data/lib/bundler/worker.rb +5 -7
  232. data/lib/bundler.rb +47 -82
  233. metadata +52 -38
  234. data/lib/bundler/dep_proxy.rb +0 -55
  235. data/lib/bundler/gemdeps.rb +0 -29
  236. data/lib/bundler/psyched_yaml.rb +0 -22
  237. data/lib/bundler/templates/gems.rb +0 -8
  238. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
  239. data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  240. data/lib/bundler/vendor/molinillo/LICENSE +0 -9
  241. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  242. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  243. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  244. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  245. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  246. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  247. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  248. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  249. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  250. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  251. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  252. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  253. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  254. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  255. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  256. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  257. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  258. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  259. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  260. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  261. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  262. data/lib/bundler/vendored_molinillo.rb +0 -4
  263. data/lib/bundler/version_ranges.rb +0 -122
@@ -7,40 +7,49 @@ module Bundler
7
7
  include Enumerable
8
8
  include TSort
9
9
 
10
- def initialize(specs)
10
+ attr_reader :incomplete_specs
11
+
12
+ def initialize(specs, incomplete_specs = [])
11
13
  @specs = specs
14
+ @incomplete_specs = incomplete_specs
12
15
  end
13
16
 
14
- def for(dependencies, check = false, match_current_platform = false)
15
- handled = []
16
- deps = dependencies.dup
17
+ def for(dependencies, check = false, platforms = [nil])
18
+ handled = ["bundler"].product(platforms).map {|k| [k, true] }.to_h
19
+ deps = dependencies.product(platforms)
17
20
  specs = []
18
21
 
19
22
  loop do
20
23
  break unless dep = deps.shift
21
- next if handled.any?{|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
22
24
 
23
- handled << dep
25
+ name = dep[0].name
26
+ platform = dep[1]
27
+ incomplete = false
28
+
29
+ key = [name, platform]
30
+ next if handled.key?(key)
31
+
32
+ handled[key] = true
24
33
 
25
- specs_for_dep = spec_for_dependency(dep, match_current_platform)
34
+ specs_for_dep = specs_for_dependency(*dep)
26
35
  if specs_for_dep.any?
27
- match_current_platform ? specs += specs_for_dep : specs |= specs_for_dep
36
+ specs.concat(specs_for_dep)
28
37
 
29
38
  specs_for_dep.first.dependencies.each do |d|
30
39
  next if d.type == :development
31
- d = DepProxy.get_proxy(d, dep.__platform) unless match_current_platform
32
- deps << d
40
+ incomplete = true if d.name != "bundler" && lookup[d.name].empty?
41
+ deps << [d, dep[1]]
33
42
  end
34
- elsif check
35
- return false
43
+ else
44
+ incomplete = true
36
45
  end
37
- end
38
46
 
39
- if spec = lookup["bundler"].first
40
- specs << spec
47
+ if incomplete && check
48
+ @incomplete_specs += lookup[name].any? ? lookup[name] : [LazySpecification.new(name, nil, nil)]
49
+ end
41
50
  end
42
51
 
43
- check ? true : specs
52
+ specs.uniq
44
53
  end
45
54
 
46
55
  def [](key)
@@ -54,6 +63,12 @@ module Bundler
54
63
  @sorted = nil
55
64
  end
56
65
 
66
+ def delete(specs)
67
+ specs.each {|spec| @specs.delete(spec) }
68
+ @lookup = nil
69
+ @sorted = nil
70
+ end
71
+
57
72
  def sort!
58
73
  self
59
74
  end
@@ -67,14 +82,9 @@ module Bundler
67
82
  end
68
83
 
69
84
  def materialize(deps)
70
- materialized = self.for(deps, false, true)
85
+ materialized = self.for(deps, true)
71
86
 
72
- materialized.map! do |s|
73
- next s unless s.is_a?(LazySpecification)
74
- s.source.local!
75
- s.__materialize__ || s
76
- end
77
- SpecSet.new(materialized)
87
+ SpecSet.new(materialized, incomplete_specs)
78
88
  end
79
89
 
80
90
  # Materialize for all the specs in the spec set, regardless of what platform they're for
@@ -83,14 +93,23 @@ module Bundler
83
93
  def materialized_for_all_platforms
84
94
  @specs.map do |s|
85
95
  next s unless s.is_a?(LazySpecification)
86
- s.source.local!
87
96
  s.source.remote!
88
- spec = s.__materialize__
97
+ spec = s.materialize_for_installation
89
98
  raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
90
99
  spec
91
100
  end
92
101
  end
93
102
 
103
+ def incomplete_ruby_specs?(deps)
104
+ return false if @specs.empty?
105
+
106
+ @incomplete_specs = []
107
+
108
+ self.for(deps, true, [Gem::Platform::RUBY])
109
+
110
+ @incomplete_specs.any?
111
+ end
112
+
94
113
  def missing_specs
95
114
  @specs.select {|s| s.is_a?(LazySpecification) }
96
115
  end
@@ -105,10 +124,20 @@ module Bundler
105
124
  SpecSet.new(arr)
106
125
  end
107
126
 
127
+ def -(other)
128
+ SpecSet.new(to_a - other.to_a)
129
+ end
130
+
108
131
  def find_by_name_and_platform(name, platform)
109
132
  @specs.detect {|spec| spec.name == name && spec.match_platform(platform) }
110
133
  end
111
134
 
135
+ def delete_by_name(name)
136
+ @specs.reject! {|spec| spec.name == name }
137
+ @lookup = nil
138
+ @sorted = nil
139
+ end
140
+
112
141
  def what_required(spec)
113
142
  unless req = find {|s| s.dependencies.any? {|d| d.type == :runtime && d.name == spec.name } }
114
143
  return [spec]
@@ -146,7 +175,7 @@ module Bundler
146
175
  cgems = extract_circular_gems(error)
147
176
  raise CyclicDependencyError, "Your bundle requires gems that depend" \
148
177
  " on each other, creating an infinite loop. Please remove either" \
149
- " gem '#{cgems[1]}' or gem '#{cgems[0]}' and try again."
178
+ " gem '#{cgems[0]}' or gem '#{cgems[1]}' and try again."
150
179
  end
151
180
  end
152
181
 
@@ -157,7 +186,7 @@ module Bundler
157
186
  def lookup
158
187
  @lookup ||= begin
159
188
  lookup = Hash.new {|h, k| h[k] = [] }
160
- Index.sort_specs(@specs).reverse_each do |s|
189
+ @specs.each do |s|
161
190
  lookup[s.name] << s
162
191
  end
163
192
  lookup
@@ -169,13 +198,12 @@ module Bundler
169
198
  @specs.sort_by(&:name).each {|s| yield s }
170
199
  end
171
200
 
172
- def spec_for_dependency(dep, match_current_platform)
173
- specs_for_platforms = lookup[dep.name]
174
- if match_current_platform
175
- GemHelpers.select_best_platform_match(specs_for_platforms.select{|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
176
- else
177
- GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
178
- end
201
+ def specs_for_dependency(dep, platform)
202
+ specs_for_name = lookup[dep.name]
203
+ target_platform = dep.force_ruby_platform ? Gem::Platform::RUBY : (platform || Bundler.local_platform)
204
+ matching_specs = GemHelpers.select_best_platform_match(specs_for_name, target_platform)
205
+ matching_specs.map!(&:materialize_for_installation).compact! if platform.nil?
206
+ matching_specs
179
207
  end
180
208
 
181
209
  def tsort_each_child(s)
@@ -64,9 +64,11 @@ module Bundler
64
64
  end
65
65
 
66
66
  def full_gem_path
67
- # deleted gems can have their stubs return nil, so in that case grab the
68
- # expired path from the full spec
69
- stub.full_gem_path || method_missing(:full_gem_path)
67
+ stub.full_gem_path
68
+ end
69
+
70
+ def full_gem_path=(path)
71
+ stub.full_gem_path = path
70
72
  end
71
73
 
72
74
  def full_require_paths
@@ -8,14 +8,12 @@
8
8
  # this file is here to facilitate running it.
9
9
  #
10
10
 
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../<%= relative_gemfile_path %>",
13
- Pathname.new(__FILE__).realpath)
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("<%= relative_gemfile_path %>", __dir__)
14
12
 
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
16
14
 
17
15
  if File.file?(bundle_binstub)
18
- 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")
19
17
  load(bundle_binstub)
20
18
  else
21
19
  abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
@@ -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)
@@ -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::Version.new(Gem::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
  #
@@ -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,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", "~> 0.9.63"
14
+ <%- end -%>
12
15
  <%- end -%>
13
16
  <%- if config[:test] -%>
14
17
 
@@ -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|
@@ -30,7 +39,17 @@ require "standard/rake"
30
39
 
31
40
  <% end -%>
32
41
  <% if config[:ext] -%>
33
- <% 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 -%>
34
53
  require "rake/extensiontask"
35
54
 
36
55
  task build: :compile
@@ -38,6 +57,7 @@ task build: :compile
38
57
  Rake::ExtensionTask.new("<%= config[:underscored_name] %>") do |ext|
39
58
  ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
40
59
  end
60
+ <% end -%>
41
61
 
42
62
  <% end -%>
43
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
+ }
@@ -17,11 +17,21 @@ jobs:
17
17
  - '<%= RUBY_VERSION %>'
18
18
 
19
19
  steps:
20
- - 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 -%>
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
 
@@ -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
@@ -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
 
@@ -24,21 +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
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(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
32
+ (File.expand_path(f) == __FILE__) ||
33
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
30
34
  end
31
35
  end
32
36
  spec.bindir = "exe"
33
37
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
38
  spec.require_paths = ["lib"]
35
- <%- if config[:ext] -%>
39
+ <%- if config[:ext] == 'c' -%>
36
40
  spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
37
41
  <%- end -%>
42
+ <%- if config[:ext] == 'rust' -%>
43
+ spec.extensions = ["ext/<%= config[:underscored_name] %>/Cargo.toml"]
44
+ <%- end -%>
38
45
 
39
46
  # Uncomment to register a new dependency of your gem
40
47
  # spec.add_dependency "example-gem", "~> 1.0"
41
48
 
42
- # 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
43
50
  # guide at: https://bundler.io/guides/creating_gem.html
44
51
  end
@@ -1,2 +1,3 @@
1
1
  # For available configuration options, see:
2
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
@@ -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)