bundler 2.2.24 → 2.2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +149 -1
  3. data/README.md +1 -1
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli/cache.rb +1 -1
  6. data/lib/bundler/cli/doctor.rb +4 -3
  7. data/lib/bundler/cli/exec.rb +1 -6
  8. data/lib/bundler/cli/gem.rb +90 -10
  9. data/lib/bundler/cli/info.rb +16 -4
  10. data/lib/bundler/cli/install.rb +4 -17
  11. data/lib/bundler/cli/issue.rb +4 -3
  12. data/lib/bundler/cli/list.rb +7 -1
  13. data/lib/bundler/cli/open.rb +1 -2
  14. data/lib/bundler/cli/remove.rb +1 -2
  15. data/lib/bundler/cli/update.rb +3 -3
  16. data/lib/bundler/cli.rb +16 -10
  17. data/lib/bundler/compact_index_client/updater.rb +0 -5
  18. data/lib/bundler/compact_index_client.rb +2 -2
  19. data/lib/bundler/definition.rb +84 -150
  20. data/lib/bundler/digest.rb +71 -0
  21. data/lib/bundler/dsl.rb +32 -4
  22. data/lib/bundler/environment_preserver.rb +4 -1
  23. data/lib/bundler/errors.rb +19 -3
  24. data/lib/bundler/fetcher.rb +2 -1
  25. data/lib/bundler/friendly_errors.rb +5 -30
  26. data/lib/bundler/gem_helper.rb +6 -17
  27. data/lib/bundler/installer/gem_installer.rb +3 -16
  28. data/lib/bundler/installer/standalone.rb +13 -8
  29. data/lib/bundler/installer.rb +0 -1
  30. data/lib/bundler/lazy_specification.rb +17 -1
  31. data/lib/bundler/lockfile_parser.rb +2 -0
  32. data/lib/bundler/man/bundle-add.1 +1 -1
  33. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  34. data/lib/bundler/man/bundle-cache.1 +1 -1
  35. data/lib/bundler/man/bundle-check.1 +1 -1
  36. data/lib/bundler/man/bundle-clean.1 +1 -1
  37. data/lib/bundler/man/bundle-config.1 +3 -3
  38. data/lib/bundler/man/bundle-config.1.ronn +2 -2
  39. data/lib/bundler/man/bundle-doctor.1 +1 -1
  40. data/lib/bundler/man/bundle-exec.1 +1 -1
  41. data/lib/bundler/man/bundle-gem.1 +14 -1
  42. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  43. data/lib/bundler/man/bundle-info.1 +1 -1
  44. data/lib/bundler/man/bundle-init.1 +1 -1
  45. data/lib/bundler/man/bundle-inject.1 +1 -1
  46. data/lib/bundler/man/bundle-install.1 +1 -1
  47. data/lib/bundler/man/bundle-list.1 +1 -1
  48. data/lib/bundler/man/bundle-lock.1 +1 -1
  49. data/lib/bundler/man/bundle-open.1 +1 -1
  50. data/lib/bundler/man/bundle-outdated.1 +1 -1
  51. data/lib/bundler/man/bundle-platform.1 +1 -1
  52. data/lib/bundler/man/bundle-pristine.1 +1 -1
  53. data/lib/bundler/man/bundle-remove.1 +1 -1
  54. data/lib/bundler/man/bundle-show.1 +1 -1
  55. data/lib/bundler/man/bundle-update.1 +1 -1
  56. data/lib/bundler/man/bundle-viz.1 +1 -1
  57. data/lib/bundler/man/bundle.1 +1 -1
  58. data/lib/bundler/man/gemfile.5 +27 -1
  59. data/lib/bundler/man/gemfile.5.ronn +8 -0
  60. data/lib/bundler/plugin/api/source.rb +1 -0
  61. data/lib/bundler/plugin/installer.rb +2 -0
  62. data/lib/bundler/plugin.rb +23 -6
  63. data/lib/bundler/resolver.rb +8 -17
  64. data/lib/bundler/rubygems_ext.rb +4 -0
  65. data/lib/bundler/rubygems_gem_installer.rb +25 -5
  66. data/lib/bundler/rubygems_integration.rb +28 -9
  67. data/lib/bundler/runtime.rb +17 -8
  68. data/lib/bundler/settings.rb +13 -1
  69. data/lib/bundler/setup.rb +2 -2
  70. data/lib/bundler/shared_helpers.rb +2 -10
  71. data/lib/bundler/source/git/git_proxy.rb +8 -6
  72. data/lib/bundler/source/git.rb +22 -4
  73. data/lib/bundler/source/rubygems.rb +70 -81
  74. data/lib/bundler/source/rubygems_aggregate.rb +4 -0
  75. data/lib/bundler/source.rb +4 -0
  76. data/lib/bundler/source_list.rb +22 -31
  77. data/lib/bundler/spec_set.rb +14 -36
  78. data/lib/bundler/templates/Executable.bundler +6 -6
  79. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  80. data/lib/bundler/templates/newgem/Rakefile.tt +5 -1
  81. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +13 -2
  82. data/lib/bundler/templates/newgem/newgem.gemspec.tt +16 -14
  83. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  84. data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  85. data/lib/bundler/vendor/.document +1 -0
  86. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  87. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  88. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  89. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  90. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  91. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  92. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  93. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  94. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  95. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  96. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  97. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  98. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  99. data/lib/bundler/vendored_tsort.rb +4 -0
  100. data/lib/bundler/version.rb +1 -1
  101. data/lib/bundler/worker.rb +19 -4
  102. data/lib/bundler.rb +13 -22
  103. metadata +20 -7
  104. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -29,6 +29,7 @@ module Bundler
29
29
  def local_only!
30
30
  @specs = nil
31
31
  @allow_local = true
32
+ @allow_cached = false
32
33
  @allow_remote = false
33
34
  end
34
35
 
@@ -50,6 +51,7 @@ module Bundler
50
51
  return if @allow_cached
51
52
 
52
53
  @specs = nil
54
+ @allow_local = true
53
55
  @allow_cached = true
54
56
  end
55
57
 
@@ -71,6 +73,10 @@ module Bundler
71
73
  @remotes.size > 1
72
74
  end
73
75
 
76
+ def no_remotes?
77
+ @remotes.size == 0
78
+ end
79
+
74
80
  def can_lock?(spec)
75
81
  return super unless multiple_remotes?
76
82
  include?(spec.source)
@@ -95,12 +101,27 @@ module Bundler
95
101
  def to_s
96
102
  if remotes.empty?
97
103
  "locally installed gems"
98
- else
99
- remote_names = remotes.map(&:to_s).join(", ")
104
+ elsif @allow_remote && @allow_cached && @allow_local
105
+ "rubygems repository #{remote_names}, cached gems or installed locally"
106
+ elsif @allow_remote && @allow_local
100
107
  "rubygems repository #{remote_names} or installed locally"
108
+ elsif @allow_remote
109
+ "rubygems repository #{remote_names}"
110
+ elsif @allow_cached && @allow_local
111
+ "cached gems or installed locally"
112
+ else
113
+ "locally installed gems"
114
+ end
115
+ end
116
+
117
+ def identifier
118
+ if remotes.empty?
119
+ "locally installed gems"
120
+ else
121
+ "rubygems repository #{remote_names}"
101
122
  end
102
123
  end
103
- alias_method :name, :to_s
124
+ alias_method :name, :identifier
104
125
 
105
126
  def specs
106
127
  @specs ||= begin
@@ -118,7 +139,7 @@ module Bundler
118
139
  force = opts[:force]
119
140
  ensure_builtin_gems_cached = opts[:ensure_builtin_gems_cached]
120
141
 
121
- if ensure_builtin_gems_cached && builtin_gem?(spec)
142
+ if ensure_builtin_gems_cached && spec.default_gem?
122
143
  if !cached_path(spec)
123
144
  cached_built_in_gem(spec) unless spec.remote
124
145
  force = true
@@ -127,7 +148,7 @@ module Bundler
127
148
  end
128
149
  end
129
150
 
130
- if (installed?(spec) || Plugin.installed?(spec.name)) && !force
151
+ if installed?(spec) && !force
131
152
  print_using_message "Using #{version_message(spec)}"
132
153
  return nil # no post-install message
133
154
  end
@@ -145,7 +166,7 @@ module Bundler
145
166
  begin
146
167
  s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
147
168
  spec.__swap__(s)
148
- rescue StandardError
169
+ rescue Gem::Package::FormatError
149
170
  Bundler.rm_rf(path)
150
171
  raise
151
172
  end
@@ -157,6 +178,7 @@ module Bundler
157
178
  Bundler.ui.confirm message
158
179
 
159
180
  path = cached_gem(spec)
181
+ raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
160
182
  if requires_sudo?
161
183
  install_path = Bundler.tmp(spec.full_name)
162
184
  bin_path = install_path.join("bin")
@@ -216,12 +238,8 @@ module Bundler
216
238
  end
217
239
 
218
240
  def cache(spec, custom_path = nil)
219
- if builtin_gem?(spec)
220
- cached_path = cached_built_in_gem(spec)
221
- else
222
- cached_path = cached_gem(spec)
223
- end
224
- raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path
241
+ cached_path = cached_gem(spec)
242
+ raise GemNotFound, "Missing gem file '#{spec.file_name}'." unless cached_path
225
243
  return if File.dirname(cached_path) == Bundler.app_cache.to_s
226
244
  Bundler.ui.info " * #{File.basename(cached_path)}"
227
245
  FileUtils.cp(cached_path, Bundler.app_cache(custom_path))
@@ -248,10 +266,6 @@ module Bundler
248
266
  @remotes.unshift(uri) unless @remotes.include?(uri)
249
267
  end
250
268
 
251
- def equivalent_remotes?(other_remotes)
252
- other_remotes.map(&method(:remove_auth)) == @remotes.map(&method(:remove_auth))
253
- end
254
-
255
269
  def spec_names
256
270
  if @allow_remote && dependency_api_available?
257
271
  remote_specs.spec_names
@@ -315,8 +329,16 @@ module Bundler
315
329
 
316
330
  protected
317
331
 
332
+ def remote_names
333
+ remotes.map(&:to_s).join(", ")
334
+ end
335
+
318
336
  def credless_remotes
319
- remotes.map(&method(:suppress_configured_credentials))
337
+ if Bundler.settings[:allow_deployment_source_credential_changes]
338
+ remotes.map(&method(:remove_auth))
339
+ else
340
+ remotes.map(&method(:suppress_configured_credentials))
341
+ end
320
342
  end
321
343
 
322
344
  def remotes_for_spec(spec)
@@ -331,14 +353,17 @@ module Bundler
331
353
  end
332
354
 
333
355
  def cached_gem(spec)
334
- cached_gem = cached_path(spec)
335
- unless cached_gem
336
- raise Bundler::GemNotFound, "Could not find #{spec.file_name} for installation"
356
+ if spec.default_gem?
357
+ cached_built_in_gem(spec)
358
+ else
359
+ cached_path(spec)
337
360
  end
338
- cached_gem
339
361
  end
340
362
 
341
363
  def cached_path(spec)
364
+ global_cache_path = download_cache_path(spec)
365
+ @caches << global_cache_path if global_cache_path
366
+
342
367
  possibilities = @caches.map {|p| "#{p}/#{spec.file_name}" }
343
368
  possibilities.find {|p| File.exist?(p) }
344
369
  end
@@ -438,19 +463,26 @@ module Bundler
438
463
 
439
464
  spec.fetch_platform
440
465
 
441
- download_path = requires_sudo? ? Bundler.tmp(spec.full_name) : rubygems_dir
442
- gem_path = "#{rubygems_dir}/cache/#{spec.full_name}.gem"
466
+ cache_path = download_cache_path(spec) || default_cache_path_for(rubygems_dir)
467
+ gem_path = "#{cache_path}/#{spec.file_name}"
468
+
469
+ if requires_sudo?
470
+ download_path = Bundler.tmp(spec.full_name)
471
+ download_cache_path = default_cache_path_for(download_path)
472
+ else
473
+ download_cache_path = cache_path
474
+ end
443
475
 
444
- SharedHelpers.filesystem_access("#{download_path}/cache") do |p|
476
+ SharedHelpers.filesystem_access(download_cache_path) do |p|
445
477
  FileUtils.mkdir_p(p)
446
478
  end
447
- download_gem(spec, download_path)
479
+ download_gem(spec, download_cache_path)
448
480
 
449
481
  if requires_sudo?
450
- SharedHelpers.filesystem_access("#{rubygems_dir}/cache") do |p|
482
+ SharedHelpers.filesystem_access(cache_path) do |p|
451
483
  Bundler.mkdir_p(p)
452
484
  end
453
- Bundler.sudo "mv #{download_path}/cache/#{spec.full_name}.gem #{gem_path}"
485
+ Bundler.sudo "mv #{download_cache_path}/#{spec.file_name} #{gem_path}"
454
486
  end
455
487
 
456
488
  gem_path
@@ -458,16 +490,8 @@ module Bundler
458
490
  Bundler.rm_rf(download_path) if requires_sudo?
459
491
  end
460
492
 
461
- def builtin_gem?(spec)
462
- # Ruby 2.1, where all included gems have this summary
463
- return true if spec.summary =~ /is bundled with Ruby/
464
-
465
- # Ruby 2.0, where gemspecs are stored in specifications/default/
466
- spec.loaded_from && spec.loaded_from.include?("specifications/default/")
467
- end
468
-
469
493
  def installed?(spec)
470
- installed_specs[spec].any?
494
+ installed_specs[spec].any? && !spec.deleted_gem?
471
495
  end
472
496
 
473
497
  def requires_sudo?
@@ -478,6 +502,10 @@ module Bundler
478
502
  Bundler.rubygems.gem_dir
479
503
  end
480
504
 
505
+ def default_cache_path_for(dir)
506
+ "#{dir}/cache"
507
+ end
508
+
481
509
  def cache_path
482
510
  Bundler.app_cache
483
511
  end
@@ -490,52 +518,13 @@ module Bundler
490
518
  # @param [Specification] spec
491
519
  # the spec we want to download or retrieve from the cache.
492
520
  #
493
- # @param [String] download_path
521
+ # @param [String] download_cache_path
494
522
  # the local directory the .gem will end up in.
495
523
  #
496
- def download_gem(spec, download_path)
497
- local_path = File.join(download_path, "cache/#{spec.full_name}.gem")
498
-
499
- if (cache_path = download_cache_path(spec)) && cache_path.file?
500
- SharedHelpers.filesystem_access(local_path) do
501
- FileUtils.cp(cache_path, local_path)
502
- end
503
- else
504
- uri = spec.remote.uri
505
- Bundler.ui.confirm("Fetching #{version_message(spec)}")
506
- rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, download_path)
507
-
508
- # older rubygems return varying file:// variants depending on version
509
- rubygems_local_path = rubygems_local_path.gsub(/\Afile:/, "") unless Bundler.rubygems.provides?(">= 3.2.0.rc.2")
510
- rubygems_local_path = rubygems_local_path.gsub(%r{\A//}, "") if Bundler.rubygems.provides?("< 3.1.0")
511
-
512
- if rubygems_local_path != local_path
513
- SharedHelpers.filesystem_access(local_path) do
514
- FileUtils.mv(rubygems_local_path, local_path)
515
- end
516
- end
517
- cache_globally(spec, local_path)
518
- end
519
- end
520
-
521
- # Checks if the requested spec exists in the global cache. If it does
522
- # not, we create the relevant global cache subdirectory if it does not
523
- # exist and copy the spec from the local cache to the global cache.
524
- #
525
- # @param [Specification] spec
526
- # the spec we want to copy to the global cache.
527
- #
528
- # @param [String] local_cache_path
529
- # the local directory from which we want to copy the .gem.
530
- #
531
- def cache_globally(spec, local_cache_path)
532
- return unless cache_path = download_cache_path(spec)
533
- return if cache_path.exist?
534
-
535
- SharedHelpers.filesystem_access(cache_path.dirname, &:mkpath)
536
- SharedHelpers.filesystem_access(cache_path) do
537
- FileUtils.cp(local_cache_path, cache_path)
538
- end
524
+ def download_gem(spec, download_cache_path)
525
+ uri = spec.remote.uri
526
+ Bundler.ui.confirm("Fetching #{version_message(spec)}")
527
+ Bundler.rubygems.download_gem(spec, uri, download_cache_path)
539
528
  end
540
529
 
541
530
  # Returns the global cache path of the calling Rubygems::Source object.
@@ -554,7 +543,7 @@ module Bundler
554
543
  return unless remote = spec.remote
555
544
  return unless cache_slug = remote.cache_slug
556
545
 
557
- Bundler.user_cache.join("gems", cache_slug, spec.file_name)
546
+ Bundler.user_cache.join("gems", cache_slug)
558
547
  end
559
548
 
560
549
  def extension_cache_slug(spec)
@@ -16,6 +16,10 @@ module Bundler
16
16
  @index
17
17
  end
18
18
 
19
+ def identifier
20
+ to_s
21
+ end
22
+
19
23
  def to_s
20
24
  "any of the sources"
21
25
  end
@@ -67,6 +67,10 @@ module Bundler
67
67
  "#<#{self.class}:0x#{object_id} #{self}>"
68
68
  end
69
69
 
70
+ def identifier
71
+ to_s
72
+ end
73
+
70
74
  def path?
71
75
  instance_of?(Bundler::Source::Path)
72
76
  end
@@ -37,6 +37,10 @@ module Bundler
37
37
  global_rubygems_source.multiple_remotes?
38
38
  end
39
39
 
40
+ def implicit_global_source?
41
+ global_rubygems_source.no_remotes?
42
+ end
43
+
40
44
  def add_path_source(options = {})
41
45
  if options["gemspec"]
42
46
  add_source_to_list Source::Gemspec.new(options), path_sources
@@ -94,7 +98,7 @@ module Bundler
94
98
  end
95
99
 
96
100
  def get(source)
97
- source_list_for(source).find {|s| equal_source?(source, s) || equivalent_source?(source, s) }
101
+ source_list_for(source).find {|s| equivalent_source?(source, s) }
98
102
  end
99
103
 
100
104
  def lock_sources
@@ -102,14 +106,14 @@ module Bundler
102
106
  end
103
107
 
104
108
  def lock_other_sources
105
- (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
109
+ (path_sources + git_sources + plugin_sources).sort_by(&:identifier)
106
110
  end
107
111
 
108
112
  def lock_rubygems_sources
109
113
  if merged_gem_lockfile_sections?
110
114
  [combine_rubygems_sources]
111
115
  else
112
- rubygems_sources.sort_by(&:to_s)
116
+ rubygems_sources.sort_by(&:identifier)
113
117
  end
114
118
  end
115
119
 
@@ -117,7 +121,8 @@ module Bundler
117
121
  def replace_sources!(replacement_sources)
118
122
  return false if replacement_sources.empty?
119
123
 
120
- @path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
124
+ @rubygems_sources, @path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
125
+ @global_rubygems_source = global_replacement_source(replacement_sources)
121
126
 
122
127
  different_sources?(lock_sources, replacement_sources)
123
128
  end
@@ -152,15 +157,23 @@ module Bundler
152
157
  end
153
158
 
154
159
  def map_sources(replacement_sources)
155
- [path_sources, git_sources, plugin_sources].map do |sources|
160
+ [@rubygems_sources, @path_sources, @git_sources, @plugin_sources].map do |sources|
156
161
  sources.map do |source|
157
162
  replacement_sources.find {|s| s == source } || source
158
163
  end
159
164
  end
160
165
  end
161
166
 
167
+ def global_replacement_source(replacement_sources)
168
+ replacement_source = replacement_sources.find {|s| s == global_rubygems_source }
169
+ return global_rubygems_source unless replacement_source
170
+
171
+ replacement_source.local!
172
+ replacement_source
173
+ end
174
+
162
175
  def different_sources?(lock_sources, replacement_sources)
163
- !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
176
+ !equivalent_sources?(lock_sources, replacement_sources)
164
177
  end
165
178
 
166
179
  def rubygems_aggregate_class
@@ -197,34 +210,12 @@ module Bundler
197
210
  end
198
211
  end
199
212
 
200
- def equal_sources?(lock_sources, replacement_sources)
201
- lock_sources.sort_by(&:to_s) == replacement_sources.sort_by(&:to_s)
202
- end
203
-
204
- def equal_source?(source, other_source)
205
- return source.include?(other_source) if source.is_a?(Source::Rubygems) && other_source.is_a?(Source::Rubygems) && !merged_gem_lockfile_sections?
206
-
207
- source == other_source
208
- end
209
-
210
- def equivalent_source?(source, other_source)
211
- return false unless Bundler.settings[:allow_deployment_source_credential_changes] && source.is_a?(Source::Rubygems)
212
-
213
- equivalent_rubygems_sources?([source], [other_source])
214
- end
215
-
216
213
  def equivalent_sources?(lock_sources, replacement_sources)
217
- return false unless Bundler.settings[:allow_deployment_source_credential_changes]
218
-
219
- lock_rubygems_sources, lock_other_sources = lock_sources.partition {|s| s.is_a?(Source::Rubygems) }
220
- replacement_rubygems_sources, replacement_other_sources = replacement_sources.partition {|s| s.is_a?(Source::Rubygems) }
221
-
222
- equivalent_rubygems_sources?(lock_rubygems_sources, replacement_rubygems_sources) && equal_sources?(lock_other_sources, replacement_other_sources)
214
+ lock_sources.sort_by(&:identifier) == replacement_sources.sort_by(&:identifier)
223
215
  end
224
216
 
225
- def equivalent_rubygems_sources?(lock_sources, replacement_sources)
226
- actual_remotes = replacement_sources.map(&:remotes).flatten.uniq
227
- lock_sources.all? {|s| s.equivalent_remotes?(actual_remotes) }
217
+ def equivalent_source?(source, other_source)
218
+ source == other_source
228
219
  end
229
220
  end
230
221
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "tsort"
3
+ require_relative "vendored_tsort"
4
4
 
5
5
  module Bundler
6
6
  class SpecSet
@@ -11,7 +11,7 @@ module Bundler
11
11
  @specs = specs
12
12
  end
13
13
 
14
- def for(dependencies, check = false, match_current_platform = false, raise_on_missing = true)
14
+ def for(dependencies, check = false, match_current_platform = false)
15
15
  handled = []
16
16
  deps = dependencies.dup
17
17
  specs = []
@@ -24,7 +24,7 @@ module Bundler
24
24
 
25
25
  specs_for_dep = spec_for_dependency(dep, match_current_platform)
26
26
  if specs_for_dep.any?
27
- specs += specs_for_dep
27
+ match_current_platform ? specs += specs_for_dep : specs |= specs_for_dep
28
28
 
29
29
  specs_for_dep.first.dependencies.each do |d|
30
30
  next if d.type == :development
@@ -33,11 +33,6 @@ module Bundler
33
33
  end
34
34
  elsif check
35
35
  return false
36
- elsif raise_on_missing
37
- others = lookup[dep.name] if match_current_platform
38
- message = "Unable to find a spec satisfying #{dep} in the set. Perhaps the lockfile is corrupted?"
39
- message += " Found #{others.join(", ")} that did not match the current platform." if others && !others.empty?
40
- raise GemNotFound, message
41
36
  end
42
37
  end
43
38
 
@@ -71,52 +66,35 @@ module Bundler
71
66
  lookup.dup
72
67
  end
73
68
 
74
- def materialize(deps, missing_specs = nil)
75
- materialized = self.for(deps, false, true, !missing_specs)
76
-
77
- materialized.group_by(&:source).each do |source, specs|
78
- next unless specs.any?{|s| s.is_a?(LazySpecification) }
79
-
80
- source.local!
81
- names = -> { specs.map(&:name).uniq }
82
- source.double_check_for(names)
83
- end
69
+ def materialize(deps)
70
+ materialized = self.for(deps, false, true)
84
71
 
85
72
  materialized.map! do |s|
86
73
  next s unless s.is_a?(LazySpecification)
87
- spec = s.__materialize__
88
- unless spec
89
- unless missing_specs
90
- raise GemNotFound, "Could not find #{s.full_name} in any of the sources"
91
- end
92
- missing_specs << s
93
- end
94
- spec
74
+ s.source.local!
75
+ s.__materialize__ || s
95
76
  end
96
- SpecSet.new(missing_specs ? materialized.compact : materialized)
77
+ SpecSet.new(materialized)
97
78
  end
98
79
 
99
80
  # Materialize for all the specs in the spec set, regardless of what platform they're for
100
81
  # This is in contrast to how for does platform filtering (and specifically different from how `materialize` calls `for` only for the current platform)
101
82
  # @return [Array<Gem::Specification>]
102
83
  def materialized_for_all_platforms
103
- @specs.group_by(&:source).each do |source, specs|
104
- next unless specs.any?{|s| s.is_a?(LazySpecification) }
105
-
106
- source.local!
107
- source.remote!
108
- names = -> { specs.map(&:name).uniq }
109
- source.double_check_for(names)
110
- end
111
-
112
84
  @specs.map do |s|
113
85
  next s unless s.is_a?(LazySpecification)
86
+ s.source.local!
87
+ s.source.remote!
114
88
  spec = s.__materialize__
115
89
  raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
116
90
  spec
117
91
  end
118
92
  end
119
93
 
94
+ def missing_specs
95
+ @specs.select {|s| s.is_a?(LazySpecification) }
96
+ end
97
+
120
98
  def merge(set)
121
99
  arr = sorted.dup
122
100
  set.each do |set_spec|
@@ -60,16 +60,16 @@ m = Module.new do
60
60
  Regexp.last_match(1)
61
61
  end
62
62
 
63
- def bundler_version
64
- @bundler_version ||=
63
+ def bundler_requirement
64
+ @bundler_requirement ||=
65
65
  env_var_version || cli_arg_version ||
66
- lockfile_version
66
+ bundler_requirement_for(lockfile_version)
67
67
  end
68
68
 
69
- def bundler_requirement
70
- return "#{Gem::Requirement.default}.a" unless bundler_version
69
+ def bundler_requirement_for(version)
70
+ return "#{Gem::Requirement.default}.a" unless version
71
71
 
72
- bundler_gem_version = Gem::Version.new(bundler_version)
72
+ bundler_gem_version = Gem::Version.new(version)
73
73
 
74
74
  requirement = bundler_gem_version.approximate_recommendation
75
75
 
@@ -14,7 +14,10 @@ gem "rake-compiler"
14
14
 
15
15
  gem "<%= config[:test] %>", "~> <%= config[:test_framework_version] %>"
16
16
  <%- end -%>
17
- <%- if config[:rubocop] -%>
17
+ <%- if config[:linter] == "rubocop" -%>
18
18
 
19
- gem "rubocop", "~> <%= config[:rubocop_version] %>"
19
+ gem "rubocop", "~> <%= config[:linter_version] %>"
20
+ <%- elsif config[:linter] == "standard" -%>
21
+
22
+ gem "standard", "~> <%= config[:linter_version] %>"
20
23
  <%- end -%>
@@ -18,12 +18,16 @@ require "rspec/core/rake_task"
18
18
  RSpec::Core::RakeTask.new(:spec)
19
19
 
20
20
  <% end -%>
21
- <% if config[:rubocop] -%>
21
+ <% if config[:linter] == "rubocop" -%>
22
22
  <% default_task_names << :rubocop -%>
23
23
  require "rubocop/rake_task"
24
24
 
25
25
  RuboCop::RakeTask.new
26
26
 
27
+ <% elsif config[:linter] == "standard" -%>
28
+ <% default_task_names << :standard -%>
29
+ require "standard/rake"
30
+
27
31
  <% end -%>
28
32
  <% if config[:ext] -%>
29
33
  <% default_task_names.unshift(:clobber, :compile) -%>
@@ -1,16 +1,27 @@
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
20
  - uses: actions/checkout@v2
10
21
  - name: Set up Ruby
11
22
  uses: ruby/setup-ruby@v1
12
23
  with:
13
- ruby-version: <%= RUBY_VERSION %>
24
+ ruby-version: ${{ matrix.ruby }}
14
25
  bundler-cache: true
15
26
  - name: Run the default task
16
27
  run: bundle exec rake
@@ -3,20 +3,20 @@
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
16
  <%- end -%>
17
17
  spec.required_ruby_version = ">= <%= config[:required_ruby_version] %>"
18
18
 
19
- spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
19
+ spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
20
20
 
21
21
  spec.metadata["homepage_uri"] = spec.homepage
22
22
  spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
@@ -25,13 +25,15 @@ Gem::Specification.new do |spec|
25
25
  # Specify which files should be added to the gem when it is released.
26
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
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)/}) }
28
+ `git ls-files -z`.split("\x0").reject do |f|
29
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
30
+ end
29
31
  end
30
- spec.bindir = "exe"
31
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
34
  spec.require_paths = ["lib"]
33
35
  <%- if config[:ext] -%>
34
- spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
36
+ spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
35
37
  <%- end -%>
36
38
 
37
39
  # Uncomment to register a new dependency of your gem
@@ -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,2 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
@@ -0,0 +1 @@
1
+ # Vendored files do not need to be documented