Skip to content

Commit 1fa1ac8

Browse files
author
Alex Evanczuk
authored
Revert bb40f15 (#46)
* Revert "for_class accepts string, remove unnecessary conversions (#39)" This reverts commit bb40f15. * bump version
1 parent e9f29ac commit 1fa1ac8

File tree

4 files changed

+38
-47
lines changed

4 files changed

+38
-47
lines changed

Gemfile.lock

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
code_ownership (1.32.2)
4+
code_ownership (1.32.3)
55
code_teams (~> 1.0)
66
packs
77
sorbet-runtime
@@ -13,19 +13,17 @@ GEM
1313
code_teams (1.0.1)
1414
sorbet-runtime
1515
coderay (1.1.3)
16-
diff-lcs (1.5.0)
16+
diff-lcs (1.4.4)
1717
method_source (1.0.0)
18-
netrc (0.11.0)
1918
packs (0.0.6)
2019
sorbet-runtime
21-
parallel (1.22.1)
22-
parser (3.2.1.1)
20+
parser (3.1.2.0)
2321
ast (~> 2.4.1)
24-
pry (0.14.2)
22+
pry (0.14.1)
2523
coderay (~> 1.1)
2624
method_source (~> 1.0)
2725
rake (13.0.6)
28-
rbi (0.0.16)
26+
rbi (0.0.14)
2927
ast
3028
parser (>= 2.6.4.0)
3129
sorbet-runtime (>= 0.5.9204)
@@ -43,43 +41,39 @@ GEM
4341
diff-lcs (>= 1.2.0, < 2.0)
4442
rspec-support (~> 3.10.0)
4543
rspec-support (3.10.2)
46-
sorbet (0.5.10707)
47-
sorbet-static (= 0.5.10707)
48-
sorbet-runtime (0.5.10707)
49-
sorbet-static (0.5.10707-universal-darwin-14)
50-
sorbet-static (0.5.10707-universal-darwin-15)
51-
sorbet-static (0.5.10707-universal-darwin-16)
52-
sorbet-static (0.5.10707-universal-darwin-17)
53-
sorbet-static (0.5.10707-universal-darwin-18)
54-
sorbet-static (0.5.10707-universal-darwin-19)
55-
sorbet-static (0.5.10707-universal-darwin-20)
56-
sorbet-static (0.5.10707-universal-darwin-21)
57-
sorbet-static (0.5.10707-universal-darwin-22)
58-
sorbet-static (0.5.10707-x86_64-linux)
59-
sorbet-static-and-runtime (0.5.10707)
60-
sorbet (= 0.5.10707)
61-
sorbet-runtime (= 0.5.10707)
62-
spoom (1.1.16)
63-
sorbet (>= 0.5.10187)
44+
sorbet (0.5.9889)
45+
sorbet-static (= 0.5.9889)
46+
sorbet-runtime (0.5.9889)
47+
sorbet-static (0.5.9889-universal-darwin-14)
48+
sorbet-static (0.5.9889-universal-darwin-15)
49+
sorbet-static (0.5.9889-universal-darwin-16)
50+
sorbet-static (0.5.9889-universal-darwin-17)
51+
sorbet-static (0.5.9889-universal-darwin-18)
52+
sorbet-static (0.5.9889-universal-darwin-19)
53+
sorbet-static (0.5.9889-universal-darwin-20)
54+
sorbet-static (0.5.9889-universal-darwin-21)
55+
sorbet-static (0.5.9889-x86_64-linux)
56+
spoom (1.1.11)
57+
sorbet (>= 0.5.9204)
6458
sorbet-runtime (>= 0.5.9204)
6559
thor (>= 0.19.2)
66-
tapioca (0.11.1)
60+
tapioca (0.7.2)
6761
bundler (>= 1.17.3)
68-
netrc (>= 0.11.0)
69-
parallel (>= 1.21.0)
70-
rbi (~> 0.0.0, >= 0.0.16)
71-
sorbet-static-and-runtime (>= 0.5.10187)
62+
pry (>= 0.12.2)
63+
rbi (~> 0.0.0, >= 0.0.14)
64+
sorbet-runtime (>= 0.5.9204)
65+
sorbet-static (>= 0.5.9204)
7266
spoom (~> 1.1.0, >= 1.1.11)
7367
thor (>= 1.2.0)
7468
yard-sorbet
7569
thor (1.2.1)
76-
unparser (0.6.7)
70+
unparser (0.6.4)
7771
diff-lcs (~> 1.3)
78-
parser (>= 3.2.0)
72+
parser (>= 3.1.0)
7973
webrick (1.7.0)
80-
yard (0.9.28)
74+
yard (0.9.27)
8175
webrick (~> 1.7.0)
82-
yard-sorbet (0.8.0)
76+
yard-sorbet (0.6.1)
8377
sorbet-runtime (>= 0.5)
8478
yard (>= 0.9)
8579

code_ownership.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
22
spec.name = "code_ownership"
3-
spec.version = '1.32.2'
3+
spec.version = '1.32.3'
44
spec.authors = ['Gusto Engineers']
55
spec.email = ['[email protected]']
66
spec.summary = 'A gem to help engineering teams declare ownership of code'

lib/code_ownership.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,23 +149,20 @@ def backtrace_with_ownership(backtrace)
149149
end
150150
private_class_method(:backtrace_with_ownership)
151151

152-
sig { params(klass: T.nilable(T.any(Class, Module, String))).returns(T.nilable(::CodeTeams::Team)) }
152+
sig { params(klass: T.nilable(T.any(Class, Module))).returns(T.nilable(::CodeTeams::Team)) }
153153
def for_class(klass)
154154
@memoized_values ||= T.let(@memoized_values, T.nilable(T::Hash[String, T.nilable(::CodeTeams::Team)]))
155155
@memoized_values ||= {}
156-
157-
klass_string = klass.to_s
158-
159156
# We use key because the memoized value could be `nil`
160-
if !@memoized_values.key?(klass_string)
161-
path = Private.path_from_klass_string(klass_string)
157+
if !@memoized_values.key?(klass.to_s)
158+
path = Private.path_from_klass(klass)
162159
return nil if path.nil?
163160

164161
value_to_memoize = for_file(path)
165-
@memoized_values[klass_string] = value_to_memoize
162+
@memoized_values[klass.to_s] = value_to_memoize
166163
value_to_memoize
167164
else
168-
@memoized_values[klass_string]
165+
@memoized_values[klass.to_s]
169166
end
170167
end
171168

lib/code_ownership/private.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ def self.validate!(files:, autocorrect: true, stage_changes: true)
5858

5959
# Returns a string version of the relative path to a Rails constant,
6060
# or nil if it can't find something
61-
sig { params(klass_string: T.nilable(String)).returns(T.nilable(String)) }
62-
def self.path_from_klass_string(klass_string)
63-
if klass_string
64-
path = Object.const_source_location(klass_string)&.first
61+
sig { params(klass: T.nilable(T.any(Class, Module))).returns(T.nilable(String)) }
62+
def self.path_from_klass(klass)
63+
if klass
64+
path = Object.const_source_location(klass.to_s)&.first
6565
(path && Pathname.new(path).relative_path_from(Pathname.pwd).to_s) || nil
6666
else
6767
nil

0 commit comments

Comments
 (0)