spoom 1.7.9 → 1.7.11

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: dcd8a922c433ab7b03fd7d6a419205e983467d5437eed8a078e57835f2168eec
4
+ data.tar.gz: 2a74d166079aa6c1f7a2f95dca5de050f6d40b4a49eb43e2eaa7059df1275e7a
5
5
  SHA512:
6
- metadata.gz: 1168d181aa2f2d7512dfae7f01b8845a247bfecc5b8ea85441c9377a7bd33e51ab288d4078f3b86bbceef129c81721ba68a386095dd8feb215d0afea93bb1788
7
- data.tar.gz: f9e7e65da944d81186ca772535b84befff429ce4c0cb9406ce2d0f6b9f0b5b46ba2efc67ab942782e635dd339139f9d902e71092a86c1ea28f221a0e219af0be
6
+ metadata.gz: b735c17851bebe3875bc1023e799060146de1965b5d3dca786e2868b68d5d27ff0e0e13324c2c6762581eb176d036b078d7168378e0f7b1637e69084e5e9a2ab
7
+ data.tar.gz: 9e4730cd210bdef36bed6f610e7b56815fd7d6cad3bf791c8b628f2c5db08e29111e9e7d6a414af8af3612d739d8431ea7461b1205fff6d339f05b4116cc3560
data/README.md CHANGED
@@ -375,7 +375,7 @@ $ spoom deadcode remove path/to/file.rb:42:18-47:23
375
375
 
376
376
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Don't forget to run `bin/sanity` before pushing your changes.
377
377
 
378
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
378
+ To install this gem onto your local machine, run `bundle exec rake install`.
379
379
 
380
380
  ## Contributing
381
381
 
@@ -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
@@ -1,6 +1,8 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "shellwords"
5
+
4
6
  module Spoom
5
7
  class ExecResult < T::Struct
6
8
  const :out, String
@@ -30,11 +32,21 @@ module Spoom
30
32
  Bundler.with_unbundled_env do
31
33
  opts = { chdir: absolute_path } #: Hash[Symbol, untyped]
32
34
 
35
+ # When Ruby is wrapped in another dev environment (e.g. Nix), that environment might set
36
+ # env variables that cause Sorbet (or other tools) to link to incorrect versions of
37
+ # dependencies.
38
+ #
39
+ # In the case of Sorbet, this can lead to corrupted JSON output.
40
+ #
41
+ # Executing the command directly through the shell bypasses any Ruby wrappers and
42
+ # ensures that we are using the versions of tools that are default on the system.
43
+ command_with_shell = "/bin/sh -c #{command.shellescape}"
44
+
33
45
  if capture_err
34
- out, err, status = Open3.capture3(command, opts)
46
+ out, err, status = Open3.capture3(command_with_shell, opts)
35
47
  ExecResult.new(out: out, err: err, status: T.must(status.success?), exit_code: T.must(status.exitstatus))
36
48
  else
37
- out, status = Open3.capture2(command, opts)
49
+ out, status = Open3.capture2(command_with_shell, opts)
38
50
  ExecResult.new(out: out, err: nil, status: T.must(status.success?), exit_code: T.must(status.exitstatus))
39
51
  end
40
52
  end
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.11"
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.11
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
@@ -274,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
275
  - !ruby/object:Gem::Version
275
276
  version: '0'
276
277
  requirements: []
277
- rubygems_version: 3.7.2
278
+ rubygems_version: 3.6.7
278
279
  specification_version: 4
279
280
  summary: Useful tools for Sorbet enthusiasts.
280
281
  test_files: []