7
7
class MacOSRequirement < Requirement
8
8
fatal true
9
9
10
- attr_reader :comparator , :version
10
+ sig { returns ( String ) }
11
+ attr_reader :comparator
12
+
13
+ attr_reader :version
11
14
12
15
# TODO: when Yosemite is removed here, keep these around as empty arrays so we
13
16
# can keep the deprecation/disabling code the same.
14
- DISABLED_MACOS_VERSIONS = [
17
+ DISABLED_MACOS_VERSIONS = T . let ( [
15
18
:yosemite ,
16
- ] . freeze
17
- DEPRECATED_MACOS_VERSIONS = [ ] . freeze
19
+ ] . freeze , T :: Array [ Symbol ] )
20
+ DEPRECATED_MACOS_VERSIONS = T . let ( [ ] . freeze , T :: Array [ Symbol ] )
18
21
19
22
def initialize ( tags = [ ] , comparator : ">=" )
20
23
@version = begin
@@ -44,10 +47,11 @@ def initialize(tags = [], comparator: ">=")
44
47
MacOSVersion . new ( HOMEBREW_MACOS_OLDEST_ALLOWED ) if comparator == ">="
45
48
end
46
49
47
- @comparator = comparator
50
+ @comparator = T . let ( comparator , String )
48
51
super ( tags . drop ( 1 ) )
49
52
end
50
53
54
+ sig { returns ( T ::Boolean ) }
51
55
def version_specified?
52
56
@version . present?
53
57
end
@@ -61,20 +65,23 @@ def version_specified?
61
65
false
62
66
end
63
67
68
+ sig { returns ( MacOSVersion ) }
64
69
def minimum_version
65
70
return MacOSVersion . new ( HOMEBREW_MACOS_OLDEST_ALLOWED ) if @comparator == "<=" || !version_specified?
66
71
return @version . min if @version . respond_to? ( :to_ary )
67
72
68
73
@version
69
74
end
70
75
76
+ sig { returns ( MacOSVersion ) }
71
77
def maximum_version
72
78
return MacOSVersion . new ( HOMEBREW_MACOS_NEWEST_UNSUPPORTED ) if @comparator == ">=" || !version_specified?
73
79
return @version . max if @version . respond_to? ( :to_ary )
74
80
75
81
@version
76
82
end
77
83
84
+ sig { params ( other : MacOSVersion ) . returns ( T ::Boolean ) }
78
85
def allows? ( other )
79
86
return true unless version_specified?
80
87
@@ -98,6 +105,7 @@ def highest_allowed
98
105
end
99
106
end
100
107
108
+ sig { params ( type : Symbol ) . returns ( String ) }
101
109
def message ( type : :formula )
102
110
return "macOS is required for this software." unless version_specified?
103
111
@@ -113,6 +121,8 @@ def message(type: :formula)
113
121
EOS
114
122
when :cask
115
123
"This cask does not run on macOS versions newer than #{ @version . pretty_name } ."
124
+ else
125
+ "This does not run on macOS versions newer than #{ @version . pretty_name } ."
116
126
end
117
127
else
118
128
if @version . respond_to? ( :to_ary )
@@ -129,6 +139,7 @@ def ==(other)
129
139
end
130
140
alias eql? ==
131
141
142
+ sig { returns ( Integer ) }
132
143
def hash
133
144
[ super , comparator , version ] . hash
134
145
end
@@ -151,6 +162,7 @@ def display_s
151
162
end
152
163
end
153
164
165
+ sig { params ( options : T . untyped ) . returns ( String ) }
154
166
def to_json ( options )
155
167
comp = @comparator . to_s
156
168
return { comp => @version . map ( &:to_s ) } . to_json ( options ) if @version . is_a? ( Array )
0 commit comments