spoom 1.7.9 → 1.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24a0283b0a0b16cef6e3547725768b9d3d63673efec428dee7859e6bb398add0
4
- data.tar.gz: 2e3037e4cf693ac776412e9817d2a1309a39b50bc58bff639dccce5fc9790a9e
3
+ metadata.gz: 82dc04cf069a738410f097150bff4d94af38dc6f7eefca31c368596eaf138da0
4
+ data.tar.gz: ea4046ff175a5c05eb85dc8cc22b6cb88f294d63b378b88a790f6bd4d92bfaff
5
5
  SHA512:
6
- metadata.gz: 1168d181aa2f2d7512dfae7f01b8845a247bfecc5b8ea85441c9377a7bd33e51ab288d4078f3b86bbceef129c81721ba68a386095dd8feb215d0afea93bb1788
7
- data.tar.gz: f9e7e65da944d81186ca772535b84befff429ce4c0cb9406ce2d0f6b9f0b5b46ba2efc67ab942782e635dd339139f9d902e71092a86c1ea28f221a0e219af0be
6
+ metadata.gz: a6c72f54e3398d0d599b92d5c266bdea3db2ee78b10151bf9a5644f2679d0778ecef4cfce105bb8dd284947e6c737ff194599c2e72ab7894dd0122466034c553
7
+ data.tar.gz: ed0df1194a93939bbb4117efbc3218d9f18d079cd2dd6b704579ba8e4c78f6f5f8a58b02072dc99bd19870eeaed0bc449ee70ea5c965e152685239b801d97c99
@@ -0,0 +1,33 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Spoom
5
+ module BundlerHelper
6
+ extend T::Sig
7
+
8
+ class << self
9
+ # Generate a gem requirement for the given gem name, using that gem's version in the "real" current bundle.
10
+ #
11
+ # This ensures that any child Spoom::Contexts use predictable gem versions,
12
+ # without having to manually specify them and bump them to stay in sync with Spoom's real Gemfile.
13
+ #
14
+ # Given `"foo"`, returns a string like 'gem "foo", "= 1.2.3"', suitable for inserting into a Gemfile.
15
+ #: (String) -> String
16
+ def gem_requirement_from_real_bundle(gem_name)
17
+ specs = Bundler.load.gems[gem_name]
18
+
19
+ if specs.nil? || specs.empty?
20
+ raise "Did not find gem #{gem_name.inspect} in the current bundle"
21
+ elsif specs.count > 1
22
+ raise <<~MSG
23
+ Found multiple versions of #{gem_name.inspect} in the current bundle:
24
+ #{specs.sort_by(&:version).map { |spec| " - #{spec.name} #{spec.version}" }.join("\n")}
25
+ MSG
26
+ else
27
+ spec = specs.first
28
+ %(gem "#{spec.name}", "= #{spec.version}")
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,8 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "spoom/bundler_helper"
5
+
4
6
  module Spoom
5
7
  module Cli
6
8
  module Srb
@@ -142,12 +144,14 @@ module Spoom
142
144
  # Now we create a new context to import our modified gem and run tapioca
143
145
  say("Running Tapioca...")
144
146
  tapioca_context = Spoom::Context.mktmp!
145
- tapioca_context.write!("Gemfile", <<~RB)
147
+ tapioca_context.write_gemfile!(<<~GEMFILE)
146
148
  source "https://rubygems.org"
147
149
 
148
- gem "tapioca"
150
+ #{Spoom::BundlerHelper.gem_requirement_from_real_bundle("rbs")}
151
+ #{Spoom::BundlerHelper.gem_requirement_from_real_bundle("tapioca")}
152
+
149
153
  gem "#{spec.name}", path: "#{copy_context.absolute_path}"
150
- RB
154
+ GEMFILE
151
155
  exec(tapioca_context, "bundle install")
152
156
  exec(tapioca_context, "bundle exec tapioca gem #{spec.name} --no-doc --no-loc --no-file-header")
153
157
 
@@ -48,7 +48,7 @@ module Spoom
48
48
  return {} unless file?("Gemfile.lock")
49
49
 
50
50
  parser = Bundler::LockfileParser.new(read_gemfile_lock)
51
- parser.specs.map { |spec| [spec.name, spec] }.to_h
51
+ parser.specs.to_h { |spec| [spec.name, spec] }
52
52
  end
53
53
 
54
54
  # Get `gem` version from the `Gemfile.lock` content
data/lib/spoom/poset.rb CHANGED
@@ -119,7 +119,7 @@ module Spoom
119
119
  dot << " \"#{value}\" -> \"#{to}\";\n"
120
120
  end
121
121
  end
122
- if transitive # rubocop:disable Style/Next
122
+ if transitive
123
123
  element.ancestors.each do |ancestor|
124
124
  dot << " \"#{value}\" -> \"#{ancestor}\" [style=dotted];\n"
125
125
  end
data/lib/spoom/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Spoom
5
- VERSION = "1.7.9"
5
+ VERSION = "1.7.10"
6
6
  end
data/rbi/spoom.rbi CHANGED
@@ -11,6 +11,13 @@ module Spoom
11
11
  end
12
12
  end
13
13
 
14
+ module Spoom::BundlerHelper
15
+ class << self
16
+ sig { params(gem_name: ::String).returns(::String) }
17
+ def gem_requirement_from_real_bundle(gem_name); end
18
+ end
19
+ end
20
+
14
21
  module Spoom::Cli; end
15
22
 
16
23
  class Spoom::Cli::Deadcode < ::Thor
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spoom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.9
4
+ version: 1.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Terrasa
@@ -162,6 +162,7 @@ files:
162
162
  - exe/spoom
163
163
  - lib/spoom.rb
164
164
  - lib/spoom/backtrace_filter/minitest.rb
165
+ - lib/spoom/bundler_helper.rb
165
166
  - lib/spoom/cli.rb
166
167
  - lib/spoom/cli/config.rb
167
168
  - lib/spoom/cli/deadcode.rb