spoom 1.1.0 → 1.1.4
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 +4 -4
- data/README.md +6 -0
- data/lib/spoom/cli/bump.rb +2 -1
- data/lib/spoom/cli/coverage.rb +6 -5
- data/lib/spoom/cli/helper.rb +5 -2
- data/lib/spoom/coverage/d3/timeline.rb +146 -9
- data/lib/spoom/coverage/report.rb +10 -0
- data/lib/spoom/coverage/snapshot.rb +3 -1
- data/lib/spoom/coverage.rb +14 -1
- data/lib/spoom/git.rb +21 -2
- data/lib/spoom/sorbet/config.rb +13 -0
- data/lib/spoom/sorbet/sigils.rb +1 -1
- data/lib/spoom/test_helpers/project.rb +12 -2
- data/lib/spoom/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c138290b530402f788fd25c8238340609f68e370cdfce7166f82f910f6352125
|
4
|
+
data.tar.gz: '08595ccc6f1485d1b935c98a318daf9de6475d2fbcc742efafd955679e372cd3'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8617496b57ade807623ef5cad109d20ff1024c8b6125c6286092859c69aab3e34f2a367fcb3ed531f425425af41cbc04492c0fd098f6e42170a9edf4bb41d120
|
7
|
+
data.tar.gz: b8040df444748a8769739caf0699d784ffcc4518e1a55c152d72f2073ae5a62d08ef02085aaa8808eb48c078baba7655e3880700ca8fb0b79830a52d66f95c7d
|
data/README.md
CHANGED
@@ -226,6 +226,12 @@ Bump files using a custom instance of Sorbet:
|
|
226
226
|
$ spoom bump --from false --to true --sorbet /path/to/sorbet/bin
|
227
227
|
```
|
228
228
|
|
229
|
+
Count the number of type-checking errors if all files were bumped to true:
|
230
|
+
|
231
|
+
```
|
232
|
+
$ spoom bump --count-errors --dry
|
233
|
+
```
|
234
|
+
|
229
235
|
#### Interact with Sorbet LSP mode
|
230
236
|
|
231
237
|
**Experimental**
|
data/lib/spoom/cli/bump.rb
CHANGED
@@ -102,6 +102,7 @@ module Spoom
|
|
102
102
|
path = File.expand_path(err.file)
|
103
103
|
next unless path.start_with?(directory)
|
104
104
|
next unless File.file?(path)
|
105
|
+
next unless files_to_bump.include?(path)
|
105
106
|
path
|
106
107
|
end.compact.uniq
|
107
108
|
|
@@ -133,7 +134,7 @@ module Spoom
|
|
133
134
|
if dry && command
|
134
135
|
say("\nRun `#{command}` to bump them")
|
135
136
|
elsif dry
|
136
|
-
say("\nRun `spoom bump --from #{from} --to #{to}`
|
137
|
+
say("\nRun `spoom bump --from #{from} --to #{to}` locally then `commit the changes` and `push them`")
|
137
138
|
end
|
138
139
|
end
|
139
140
|
|
data/lib/spoom/cli/coverage.rb
CHANGED
@@ -15,7 +15,7 @@ module Spoom
|
|
15
15
|
|
16
16
|
desc "snapshot", "Run srb tc and display metrics"
|
17
17
|
option :save, type: :string, lazy_default: DATA_DIR, desc: "Save snapshot data as json"
|
18
|
-
option :rbi, type: :boolean, default: true, desc: "
|
18
|
+
option :rbi, type: :boolean, default: true, desc: "Include RBI files in metrics"
|
19
19
|
option :sorbet, type: :string, desc: "Path to custom Sorbet bin"
|
20
20
|
def snapshot
|
21
21
|
in_sorbet_project!
|
@@ -44,8 +44,9 @@ module Spoom
|
|
44
44
|
path = exec_path
|
45
45
|
sorbet = options[:sorbet]
|
46
46
|
|
47
|
-
|
48
|
-
unless
|
47
|
+
ref_before = Spoom::Git.current_branch
|
48
|
+
ref_before = Spoom::Git.last_commit(path: path) unless ref_before
|
49
|
+
unless ref_before
|
49
50
|
say_error("Not in a git repository")
|
50
51
|
say_error("\nSpoom needs to checkout into your previous commits to build the timeline.", status: nil)
|
51
52
|
exit(1)
|
@@ -90,7 +91,7 @@ module Spoom
|
|
90
91
|
|
91
92
|
snapshot = T.let(nil, T.nilable(Spoom::Coverage::Snapshot))
|
92
93
|
if options[:bundle_install]
|
93
|
-
Bundler.
|
94
|
+
Bundler.with_unbundled_env do
|
94
95
|
next unless bundle_install(path, sha)
|
95
96
|
snapshot = Spoom::Coverage.snapshot(path: path, sorbet_bin: sorbet)
|
96
97
|
end
|
@@ -107,7 +108,7 @@ module Spoom
|
|
107
108
|
File.write(file, snapshot.to_json)
|
108
109
|
say(" Snapshot data saved under `#{file}`\n\n")
|
109
110
|
end
|
110
|
-
Spoom::Git.checkout(
|
111
|
+
Spoom::Git.checkout(ref_before, path: path)
|
111
112
|
end
|
112
113
|
|
113
114
|
desc "report", "Produce a typing coverage report"
|
data/lib/spoom/cli/helper.rb
CHANGED
@@ -9,8 +9,11 @@ module Spoom
|
|
9
9
|
module Cli
|
10
10
|
module Helper
|
11
11
|
extend T::Sig
|
12
|
+
extend T::Helpers
|
12
13
|
include Thor::Shell
|
13
14
|
|
15
|
+
requires_ancestor { Thor }
|
16
|
+
|
14
17
|
# Print `message` on `$stdout`
|
15
18
|
sig { params(message: String).void }
|
16
19
|
def say(message)
|
@@ -66,7 +69,7 @@ module Spoom
|
|
66
69
|
# Return the path specified through `--path`
|
67
70
|
sig { returns(String) }
|
68
71
|
def exec_path
|
69
|
-
|
72
|
+
options[:path]
|
70
73
|
end
|
71
74
|
|
72
75
|
sig { returns(String) }
|
@@ -87,7 +90,7 @@ module Spoom
|
|
87
90
|
# Is the `--color` option true?
|
88
91
|
sig { returns(T::Boolean) }
|
89
92
|
def color?
|
90
|
-
|
93
|
+
options[:color]
|
91
94
|
end
|
92
95
|
|
93
96
|
sig { params(string: String).returns(String) }
|
@@ -36,10 +36,28 @@ module Spoom
|
|
36
36
|
pointer-events: none;
|
37
37
|
}
|
38
38
|
|
39
|
+
.area {
|
40
|
+
fill-opacity: 0.5;
|
41
|
+
}
|
42
|
+
|
43
|
+
.line {
|
44
|
+
stroke-width: 2;
|
45
|
+
fill: transparent;
|
46
|
+
}
|
47
|
+
|
48
|
+
.dot {
|
49
|
+
r: 2;
|
50
|
+
fill: #888;
|
51
|
+
}
|
52
|
+
|
39
53
|
.inverted .grid line {
|
40
54
|
stroke: #777;
|
41
55
|
}
|
42
56
|
|
57
|
+
.inverted .area {
|
58
|
+
fill-opacity: 0.9;
|
59
|
+
}
|
60
|
+
|
43
61
|
.inverted .axis text {
|
44
62
|
fill: #fff;
|
45
63
|
}
|
@@ -47,6 +65,10 @@ module Spoom
|
|
47
65
|
.inverted .axis line {
|
48
66
|
stroke: #fff;
|
49
67
|
}
|
68
|
+
|
69
|
+
.inverted .dot {
|
70
|
+
fill: #fff;
|
71
|
+
}
|
50
72
|
CSS
|
51
73
|
end
|
52
74
|
|
@@ -170,7 +192,6 @@ module Spoom
|
|
170
192
|
.y1((d) => yScale_#{id}(#{y}))
|
171
193
|
.curve(d3.#{curve}))
|
172
194
|
.attr("fill", "#{color}")
|
173
|
-
.attr("fill-opacity", 0.5)
|
174
195
|
HTML
|
175
196
|
end
|
176
197
|
|
@@ -185,8 +206,6 @@ module Spoom
|
|
185
206
|
.y((d) => yScale_#{id}(#{y}))
|
186
207
|
.curve(d3.#{curve}))
|
187
208
|
.attr("stroke", "#{color}")
|
188
|
-
.attr("stroke-width", 3)
|
189
|
-
.attr("fill", "transparent")
|
190
209
|
HTML
|
191
210
|
end
|
192
211
|
|
@@ -198,10 +217,8 @@ module Spoom
|
|
198
217
|
.enter()
|
199
218
|
.append("circle")
|
200
219
|
.attr("class", "dot")
|
201
|
-
.attr("r", 3)
|
202
220
|
.attr("cx", (d) => xScale_#{id}(parseDate(d.timestamp)))
|
203
221
|
.attr("cy", (d, i) => yScale_#{id}(#{y}))
|
204
|
-
.attr("fill", "#aaa")
|
205
222
|
.on("mouseover", (d) => tooltip.style("opacity", 1))
|
206
223
|
.on("mousemove", tooltip_#{id})
|
207
224
|
.on("mouseleave", (d) => tooltip.style("opacity", 0));
|
@@ -381,18 +398,15 @@ module Spoom
|
|
381
398
|
layer.append("path")
|
382
399
|
.attr("class", "area")
|
383
400
|
.attr("d", area_#{id})
|
384
|
-
.attr("fill", (d) =>
|
385
|
-
.attr("fill-opacity", 0.9)
|
401
|
+
.attr("fill", (d) => #{color})
|
386
402
|
|
387
403
|
svg_#{id}.selectAll("circle")
|
388
404
|
.data(points_#{id})
|
389
405
|
.enter()
|
390
406
|
.append("circle")
|
391
407
|
.attr("class", "dot")
|
392
|
-
.attr("r", 2)
|
393
408
|
.attr("cx", (d) => xScale_#{id}(parseDate(#{y})))
|
394
409
|
.attr("cy", (d, i) => yScale_#{id}(d[1]))
|
395
|
-
.attr("fill", "#fff")
|
396
410
|
.on("mouseover", (d) => tooltip.style("opacity", 1))
|
397
411
|
.on("mousemove", tooltip_#{id})
|
398
412
|
.on("mouseleave", (d) => tooltip.style("opacity", 0));
|
@@ -480,6 +494,129 @@ module Spoom
|
|
480
494
|
JS
|
481
495
|
end
|
482
496
|
end
|
497
|
+
|
498
|
+
class RBIs < Stacked
|
499
|
+
extend T::Sig
|
500
|
+
|
501
|
+
sig { params(id: String, snapshots: T::Array[Snapshot]).void }
|
502
|
+
def initialize(id, snapshots)
|
503
|
+
keys = ['rbis', 'files']
|
504
|
+
data = snapshots.map do |snapshot|
|
505
|
+
{
|
506
|
+
timestamp: snapshot.commit_timestamp,
|
507
|
+
commit: snapshot.commit_sha,
|
508
|
+
total: snapshot.files,
|
509
|
+
values: { files: snapshot.files - snapshot.rbi_files, rbis: snapshot.rbi_files },
|
510
|
+
}
|
511
|
+
end
|
512
|
+
super(id, data, keys)
|
513
|
+
end
|
514
|
+
|
515
|
+
sig { override.returns(String) }
|
516
|
+
def tooltip
|
517
|
+
<<~JS
|
518
|
+
function tooltip_#{id}(d) {
|
519
|
+
moveTooltip(d)
|
520
|
+
.html("commit <b>" + d.data.commit + "</b><br>"
|
521
|
+
+ d3.timeFormat("%y/%m/%d")(parseDate(d.data.timestamp)) + "<br><br>"
|
522
|
+
+ "Files: <b>" + d.data.values.files + "</b><br>"
|
523
|
+
+ "RBIs: <b>" + d.data.values.rbis + "</b><br><br>"
|
524
|
+
+ "Total: <b>" + d.data.total + "</b>")
|
525
|
+
}
|
526
|
+
JS
|
527
|
+
end
|
528
|
+
|
529
|
+
sig { override.returns(String) }
|
530
|
+
def script
|
531
|
+
<<~JS
|
532
|
+
#{tooltip}
|
533
|
+
|
534
|
+
var data_#{id} = #{@data.to_json};
|
535
|
+
var keys_#{id} = #{T.unsafe(@keys).to_json};
|
536
|
+
|
537
|
+
var stack_#{id} = d3.stack()
|
538
|
+
.keys(keys_#{id})
|
539
|
+
.value((d, key) => d.values[key]);
|
540
|
+
|
541
|
+
var layers_#{id} = stack_#{id}(data_#{id});
|
542
|
+
|
543
|
+
var points_#{id} = []
|
544
|
+
layers_#{id}.forEach(function(d) {
|
545
|
+
d.forEach(function(p) {
|
546
|
+
p.key = d.key
|
547
|
+
points_#{id}.push(p);
|
548
|
+
});
|
549
|
+
})
|
550
|
+
|
551
|
+
function draw_#{id}() {
|
552
|
+
var width_#{id} = document.getElementById("#{id}").clientWidth;
|
553
|
+
var height_#{id} = 200;
|
554
|
+
|
555
|
+
d3.select("##{id}").selectAll("*").remove()
|
556
|
+
|
557
|
+
var svg_#{id} = d3.select("##{id}")
|
558
|
+
.attr("width", width_#{id})
|
559
|
+
.attr("height", height_#{id});
|
560
|
+
|
561
|
+
#{plot}
|
562
|
+
}
|
563
|
+
|
564
|
+
draw_#{id}();
|
565
|
+
window.addEventListener("resize", draw_#{id});
|
566
|
+
JS
|
567
|
+
end
|
568
|
+
|
569
|
+
sig { override.params(y: String, color: String, curve: String).returns(String) }
|
570
|
+
def line(y:, color: 'strictnessColor(d.key)', curve: 'curveCatmullRom.alpha(1)')
|
571
|
+
<<~JS
|
572
|
+
var area_#{id} = d3.area()
|
573
|
+
.x((d) => xScale_#{id}(parseDate(#{y})))
|
574
|
+
.y0((d) => yScale_#{id}(d[0]))
|
575
|
+
.y1((d) => yScale_#{id}(d[1]))
|
576
|
+
.curve(d3.#{curve});
|
577
|
+
|
578
|
+
var layer = svg_#{id}.selectAll(".layer")
|
579
|
+
.data(layers_#{id})
|
580
|
+
.enter().append("g")
|
581
|
+
.attr("class", "layer")
|
582
|
+
|
583
|
+
layer.append("path")
|
584
|
+
.attr("class", "area")
|
585
|
+
.attr("d", area_#{id})
|
586
|
+
.attr("fill", (d) => #{color})
|
587
|
+
|
588
|
+
layer.append("path")
|
589
|
+
.attr("class", "line")
|
590
|
+
.attr("d", d3.line()
|
591
|
+
.x((d) => xScale_#{id}(parseDate(#{y})))
|
592
|
+
.y((d, i) => yScale_#{id}(d[1]))
|
593
|
+
.curve(d3.#{curve}))
|
594
|
+
.attr("stroke", (d) => #{color})
|
595
|
+
|
596
|
+
svg_#{id}.selectAll("circle")
|
597
|
+
.data(points_#{id})
|
598
|
+
.enter()
|
599
|
+
.append("circle")
|
600
|
+
.attr("class", "dot")
|
601
|
+
.attr("cx", (d) => xScale_#{id}(parseDate(#{y})))
|
602
|
+
.attr("cy", (d, i) => yScale_#{id}(d[1]))
|
603
|
+
.on("mouseover", (d) => tooltip.style("opacity", 1))
|
604
|
+
.on("mousemove", tooltip_#{id})
|
605
|
+
.on("mouseleave", (d) => tooltip.style("opacity", 0));
|
606
|
+
JS
|
607
|
+
end
|
608
|
+
|
609
|
+
sig { override.returns(String) }
|
610
|
+
def plot
|
611
|
+
<<~JS
|
612
|
+
#{x_scale}
|
613
|
+
#{y_scale(min: '0', max: "d3.max(data_#{id}, (d) => d.total + 10)", ticks: 'tickValues([0, 25, 50, 75, 100])')}
|
614
|
+
#{line(y: 'd.data.timestamp', color: "d.key == 'rbis' ? '#8673ff' : '#007bff'")}
|
615
|
+
#{x_ticks}
|
616
|
+
#{y_ticks(ticks: 'tickValues([25, 50, 75])', format: 'd', padding: 20)}
|
617
|
+
JS
|
618
|
+
end
|
619
|
+
end
|
483
620
|
end
|
484
621
|
end
|
485
622
|
end
|
@@ -194,6 +194,15 @@ module Spoom
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
+
class RBIs < Timeline
|
198
|
+
extend T::Sig
|
199
|
+
|
200
|
+
sig { params(snapshots: T::Array[Coverage::Snapshot], title: String).void }
|
201
|
+
def initialize(snapshots:, title: "RBIs Timeline")
|
202
|
+
super(title: title, timeline: D3::Timeline::RBIs.new("timeline_rbis", snapshots))
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
197
206
|
class Versions < Timeline
|
198
207
|
extend T::Sig
|
199
208
|
|
@@ -298,6 +307,7 @@ module Spoom
|
|
298
307
|
cards << Cards::Timeline::Sigils.new(snapshots: snapshots)
|
299
308
|
cards << Cards::Timeline::Calls.new(snapshots: snapshots)
|
300
309
|
cards << Cards::Timeline::Sigs.new(snapshots: snapshots)
|
310
|
+
cards << Cards::Timeline::RBIs.new(snapshots: snapshots)
|
301
311
|
cards << Cards::Timeline::Versions.new(snapshots: snapshots)
|
302
312
|
cards << Cards::Timeline::Runtimes.new(snapshots: snapshots)
|
303
313
|
cards << Cards::SorbetIntro.new(sorbet_intro_commit: sorbet_intro_commit, sorbet_intro_date: sorbet_intro_date)
|
@@ -13,6 +13,7 @@ module Spoom
|
|
13
13
|
prop :commit_sha, T.nilable(String), default: nil
|
14
14
|
prop :commit_timestamp, T.nilable(Integer), default: nil
|
15
15
|
prop :files, Integer, default: 0
|
16
|
+
prop :rbi_files, Integer, default: 0
|
16
17
|
prop :modules, Integer, default: 0
|
17
18
|
prop :classes, Integer, default: 0
|
18
19
|
prop :singleton_classes, Integer, default: 0
|
@@ -46,6 +47,7 @@ module Spoom
|
|
46
47
|
snapshot.commit_sha = obj.fetch("commit_sha", nil)
|
47
48
|
snapshot.commit_timestamp = obj.fetch("commit_timestamp", nil)
|
48
49
|
snapshot.files = obj.fetch("files", 0)
|
50
|
+
snapshot.rbi_files = obj.fetch("rbi_files", 0)
|
49
51
|
snapshot.modules = obj.fetch("modules", 0)
|
50
52
|
snapshot.classes = obj.fetch("classes", 0)
|
51
53
|
snapshot.singleton_classes = obj.fetch("singleton_classes", 0)
|
@@ -86,7 +88,7 @@ module Spoom
|
|
86
88
|
end
|
87
89
|
printl("Content:")
|
88
90
|
indent
|
89
|
-
printl("files: #{snapshot.files}")
|
91
|
+
printl("files: #{snapshot.files} (including #{snapshot.rbi_files} RBIs)")
|
90
92
|
printl("modules: #{snapshot.modules}")
|
91
93
|
printl("classes: #{snapshot.classes - snapshot.singleton_classes}")
|
92
94
|
printl("methods: #{methods}")
|
data/lib/spoom/coverage.rb
CHANGED
@@ -21,6 +21,9 @@ module Spoom
|
|
21
21
|
|
22
22
|
metrics = Spoom::Sorbet.srb_metrics(
|
23
23
|
"--no-config",
|
24
|
+
"--no-error-sections",
|
25
|
+
"--no-error-count",
|
26
|
+
"--isolate-error-code=0",
|
24
27
|
new_config.options_string,
|
25
28
|
path: path,
|
26
29
|
capture_err: true,
|
@@ -54,6 +57,9 @@ module Spoom
|
|
54
57
|
snapshot.version_static = Spoom::Sorbet.version_from_gemfile_lock(gem: "sorbet-static", path: path)
|
55
58
|
snapshot.version_runtime = Spoom::Sorbet.version_from_gemfile_lock(gem: "sorbet-runtime", path: path)
|
56
59
|
|
60
|
+
files = Spoom::Sorbet.srb_files(new_config, path: path)
|
61
|
+
snapshot.rbi_files = files.count { |file| file.end_with?(".rbi") }
|
62
|
+
|
57
63
|
snapshot
|
58
64
|
end
|
59
65
|
|
@@ -81,8 +87,15 @@ module Spoom
|
|
81
87
|
def self.sigils_tree(path: ".")
|
82
88
|
config = sorbet_config(path: path)
|
83
89
|
files = Sorbet.srb_files(config, path: path)
|
84
|
-
|
90
|
+
|
91
|
+
extensions = config.allowed_extensions
|
92
|
+
extensions = [".rb"] if extensions.empty?
|
93
|
+
extensions -= [".rbi"]
|
94
|
+
|
95
|
+
pattern = /\.(#{Regexp.union(extensions.map { |ext| ext[1..-1] })})$/
|
96
|
+
files.select! { |file| file =~ pattern }
|
85
97
|
files.reject! { |file| file =~ %r{/test/} }
|
98
|
+
|
86
99
|
FileTree.new(files, strip_prefix: path)
|
87
100
|
end
|
88
101
|
end
|
data/lib/spoom/git.rb
CHANGED
@@ -20,7 +20,7 @@ module Spoom
|
|
20
20
|
err = e.read.to_s
|
21
21
|
e.close
|
22
22
|
i.close
|
23
|
-
[out, err,
|
23
|
+
[out, err, s.value.success?]
|
24
24
|
end
|
25
25
|
|
26
26
|
# Git commands
|
@@ -50,6 +50,13 @@ module Spoom
|
|
50
50
|
exec("git show #{arg.join(' ')}", path: path)
|
51
51
|
end
|
52
52
|
|
53
|
+
sig { params(path: String).returns(T.nilable(String)) }
|
54
|
+
def self.current_branch(path: ".")
|
55
|
+
out, _, status = exec("git branch --show-current", path: path)
|
56
|
+
return nil unless status
|
57
|
+
out.strip
|
58
|
+
end
|
59
|
+
|
53
60
|
# Utils
|
54
61
|
|
55
62
|
# Get the commit epoch timestamp for a `sha`
|
@@ -93,7 +100,19 @@ module Spoom
|
|
93
100
|
def self.sorbet_intro_commit(path: ".")
|
94
101
|
res, _, status = Spoom::Git.log("--diff-filter=A --format='%h' -1 -- sorbet/config", path: path)
|
95
102
|
return nil unless status
|
96
|
-
res.strip
|
103
|
+
res.strip!
|
104
|
+
return nil if res.empty?
|
105
|
+
res
|
106
|
+
end
|
107
|
+
|
108
|
+
# Get the hash of the commit removing the `sorbet/config` file
|
109
|
+
sig { params(path: String).returns(T.nilable(String)) }
|
110
|
+
def self.sorbet_removal_commit(path: ".")
|
111
|
+
res, _, status = Spoom::Git.log("--diff-filter=D --format='%h' -1 -- sorbet/config", path: path)
|
112
|
+
return nil unless status
|
113
|
+
res.strip!
|
114
|
+
return nil if res.empty?
|
115
|
+
res
|
97
116
|
end
|
98
117
|
end
|
99
118
|
end
|
data/lib/spoom/sorbet/config.rb
CHANGED
@@ -29,11 +29,15 @@ module Spoom
|
|
29
29
|
sig { returns(T::Array[String]) }
|
30
30
|
attr_reader :paths, :ignore, :allowed_extensions
|
31
31
|
|
32
|
+
sig { returns(T::Boolean) }
|
33
|
+
attr_accessor :no_stdlib
|
34
|
+
|
32
35
|
sig { void }
|
33
36
|
def initialize
|
34
37
|
@paths = T.let([], T::Array[String])
|
35
38
|
@ignore = T.let([], T::Array[String])
|
36
39
|
@allowed_extensions = T.let([], T::Array[String])
|
40
|
+
@no_stdlib = T.let(false, T::Boolean)
|
37
41
|
end
|
38
42
|
|
39
43
|
sig { returns(Config) }
|
@@ -42,6 +46,7 @@ module Spoom
|
|
42
46
|
new_config.paths.concat(@paths)
|
43
47
|
new_config.ignore.concat(@ignore)
|
44
48
|
new_config.allowed_extensions.concat(@allowed_extensions)
|
49
|
+
new_config.no_stdlib = @no_stdlib
|
45
50
|
new_config
|
46
51
|
end
|
47
52
|
|
@@ -63,6 +68,7 @@ module Spoom
|
|
63
68
|
opts.concat(paths)
|
64
69
|
opts.concat(ignore.map { |p| "--ignore #{p}" })
|
65
70
|
opts.concat(allowed_extensions.map { |ext| "--allowed-extension #{ext}" })
|
71
|
+
opts << "--no-stdlib" if @no_stdlib
|
66
72
|
opts.join(" ")
|
67
73
|
end
|
68
74
|
|
@@ -106,12 +112,19 @@ module Spoom
|
|
106
112
|
when /^--dir=/
|
107
113
|
config.paths << parse_option(line)
|
108
114
|
next
|
115
|
+
when /^--no-stdlib$/
|
116
|
+
config.no_stdlib = true
|
117
|
+
next
|
109
118
|
when /^--.*=/
|
110
119
|
next
|
111
120
|
when /^--/
|
112
121
|
state = :skip
|
113
122
|
when /^-.*=?/
|
114
123
|
next
|
124
|
+
when /^#/
|
125
|
+
next
|
126
|
+
when /^$/
|
127
|
+
next
|
115
128
|
else
|
116
129
|
case state
|
117
130
|
when :ignore
|
data/lib/spoom/sorbet/sigils.rb
CHANGED
@@ -55,7 +55,7 @@ module Spoom
|
|
55
55
|
# * returns nil if no sigil
|
56
56
|
sig { params(path: T.any(String, Pathname)).returns(T.nilable(String)) }
|
57
57
|
def self.file_strictness(path)
|
58
|
-
return nil unless File.
|
58
|
+
return nil unless File.file?(path)
|
59
59
|
content = File.read(path, encoding: Encoding::ASCII_8BIT)
|
60
60
|
strictness_in_content(content)
|
61
61
|
end
|
@@ -82,7 +82,7 @@ module Spoom
|
|
82
82
|
opts = {}
|
83
83
|
opts[:chdir] = path
|
84
84
|
out, err, status = Open3.capture3("bundle", "install", opts)
|
85
|
-
[out, err, status.success?]
|
85
|
+
[out, err, T.must(status.success?)]
|
86
86
|
end
|
87
87
|
|
88
88
|
# Run a command with `bundle exec` in this project
|
@@ -91,7 +91,7 @@ module Spoom
|
|
91
91
|
opts = {}
|
92
92
|
opts[:chdir] = path
|
93
93
|
out, err, status = Open3.capture3(["bundle", "exec", cmd, *args].join(' '), opts)
|
94
|
-
[out, err, status.success?]
|
94
|
+
[out, err, T.must(status.success?)]
|
95
95
|
end
|
96
96
|
|
97
97
|
# Delete this project and its content
|
@@ -100,6 +100,16 @@ module Spoom
|
|
100
100
|
FileUtils.rm_rf(path)
|
101
101
|
end
|
102
102
|
|
103
|
+
sig { params(name: String).void }
|
104
|
+
def create_and_checkout_branch(name)
|
105
|
+
Spoom::Git.exec("git checkout -b #{name}", path: path)
|
106
|
+
end
|
107
|
+
|
108
|
+
sig { returns(T.nilable(String)) }
|
109
|
+
def current_branch
|
110
|
+
Spoom::Git.current_branch(path: path)
|
111
|
+
end
|
112
|
+
|
103
113
|
private
|
104
114
|
|
105
115
|
# Create an absolute path from `self.path` and `rel_path`
|
data/lib/spoom/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spoom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Terrasa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.10
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.5.9204
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.5.9204
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sorbet
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.5.
|
75
|
+
version: 0.5.9204
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.5.
|
82
|
+
version: 0.5.9204
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: thor
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
rubygems_version: 3.
|
177
|
+
rubygems_version: 3.2.20
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Useful tools for Sorbet enthusiasts.
|