Skip to content

Commit db5e88f

Browse files
authored
Merge pull request #762 from Shopify/at-rbs-helpers
Translate Sorbet helpers to RBs comments
2 parents f75b50b + 4173a44 commit db5e88f

File tree

21 files changed

+51
-124
lines changed

21 files changed

+51
-124
lines changed

lib/spoom/cli/helper.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77

88
module Spoom
99
module Cli
10+
# @requires_ancestor: Thor
1011
module Helper
11-
extend T::Helpers
12-
1312
include Colorize
1413

15-
requires_ancestor { Thor }
16-
1714
# Print `message` on `$stdout`
1815
#: (String message) -> void
1916
def say(message)

lib/spoom/context/bundle.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
module Spoom
55
class Context
66
# Bundle features for a context
7+
# @requires_ancestor: Context
78
module Bundle
8-
extend T::Helpers
9-
10-
requires_ancestor { Context }
11-
129
# Read the contents of the Gemfile in this context directory
1310
#: -> String?
1411
def read_gemfile

lib/spoom/context/exec.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ def to_s
2222

2323
class Context
2424
# Execution features for a context
25+
# @requires_ancestor: Context
2526
module Exec
26-
extend T::Helpers
27-
28-
requires_ancestor { Context }
29-
3027
# Run a command in this context directory
3128
#: (String command, ?capture_err: bool) -> ExecResult
3229
def exec(command, capture_err: true)

lib/spoom/context/file_system.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
module Spoom
55
class Context
66
# File System features for a context
7+
# @requires_ancestor: Context
78
module FileSystem
8-
extend T::Helpers
9-
10-
requires_ancestor { Context }
11-
129
# Returns the absolute path to `relative_path` in the context's directory
1310
#: (String relative_path) -> String
1411
def absolute_path_to(relative_path)

lib/spoom/context/git.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ def timestamp
2828

2929
class Context
3030
# Git features for a context
31+
# @requires_ancestor: Context
3132
module Git
32-
extend T::Helpers
33-
34-
requires_ancestor { Context }
35-
3633
# Run a command prefixed by `git` in this context directory
3734
#: (String command) -> ExecResult
3835
def git(command)

lib/spoom/context/sorbet.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
module Spoom
55
class Context
66
# Sorbet features for a context
7+
# @requires_ancestor: Context
78
module Sorbet
8-
extend T::Helpers
9-
10-
requires_ancestor { Context }
11-
129
# Run `bundle exec srb` in this context directory
1310
#: (*String arg, ?sorbet_bin: String?, ?capture_err: bool) -> ExecResult
1411
def srb(*arg, sorbet_bin: nil, capture_err: true)

lib/spoom/coverage/d3/base.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
module Spoom
55
module Coverage
66
module D3
7+
# @abstract
78
class Base
8-
extend T::Sig
9-
extend T::Helpers
10-
11-
abstract!
12-
139
#: String
1410
attr_reader :id
1511

@@ -44,7 +40,8 @@ def tooltip
4440
""
4541
end
4642

47-
sig { abstract.returns(String) }
43+
# @abstract
44+
#: -> String
4845
def script; end
4946
end
5047
end

lib/spoom/coverage/d3/pie.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
module Spoom
77
module Coverage
88
module D3
9+
# @abstract
910
class Pie < Base
10-
extend T::Helpers
11-
12-
abstract!
13-
1411
#: (String id, String title, untyped data) -> void
1512
def initialize(id, title, data)
1613
super(id, data)

lib/spoom/coverage/d3/timeline.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
module Spoom
77
module Coverage
88
module D3
9+
# @abstract
910
class Timeline < Base
10-
extend T::Helpers
11-
12-
abstract!
13-
1411
#: (String id, untyped data, Array[String] keys) -> void
1512
def initialize(id, data, keys)
1613
super(id, data)
@@ -120,7 +117,8 @@ def script
120117
HTML
121118
end
122119

123-
sig { abstract.returns(String) }
120+
# @abstract
121+
#: -> String
124122
def plot; end
125123

126124
#: -> String
@@ -324,11 +322,8 @@ def plot
324322
end
325323
end
326324

325+
# @abstract
327326
class Stacked < Timeline
328-
extend T::Helpers
329-
330-
abstract!
331-
332327
# @override
333328
#: -> String
334329
def script

lib/spoom/coverage/report.rb

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77

88
module Spoom
99
module Coverage
10+
# @abstract
1011
class Template
11-
extend T::Helpers
12-
13-
abstract!
14-
1512
# Create a new template from an Erb file path
1613
#: (template: String) -> void
1714
def initialize(template:)
@@ -34,12 +31,8 @@ def get_binding # rubocop:disable Naming/AccessorMethodName
3431
end
3532
end
3633

34+
# @abstract
3735
class Page < Template
38-
extend T::Sig
39-
extend T::Helpers
40-
41-
abstract!
42-
4336
TEMPLATE = "#{Spoom::SPOOM_PATH}/templates/page.erb" #: String
4437

4538
#: String
@@ -75,7 +68,8 @@ def body_html
7568
cards.map(&:html).join("\n")
7669
end
7770

78-
sig { abstract.returns(T::Array[Cards::Card]) }
71+
# @abstract
72+
#: -> Array[Cards::Card]
7973
def cards; end
8074

8175
#: -> String
@@ -86,8 +80,6 @@ def footer_html
8680

8781
module Cards
8882
class Card < Template
89-
extend T::Sig
90-
9183
TEMPLATE = "#{Spoom::SPOOM_PATH}/templates/card.erb" #: String
9284

9385
#: String?
@@ -101,11 +93,8 @@ def initialize(template: TEMPLATE, title: nil, body: nil)
10193
end
10294
end
10395

96+
# @abstract
10497
class Erb < Card
105-
extend T::Helpers
106-
107-
abstract!
108-
10998
#: -> void
11099
def initialize; end # rubocop:disable Lint/MissingSuper
111100

@@ -115,7 +104,8 @@ def html
115104
ERB.new(erb).result(get_binding)
116105
end
117106

118-
sig { abstract.returns(String) }
107+
# @abstract
108+
#: -> String
119109
def erb; end
120110
end
121111

0 commit comments

Comments
 (0)