mac_ios_info 0.1.0 → 0.2.0

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: 260eaa3b5ec834d574b42cf6a03a8cd34f6e85ac62127ed32ced03d59a0b09d1
4
- data.tar.gz: 5abbe4f888f68c236968021e20f396256d269e5eb814a750451253d1b0d262f3
3
+ metadata.gz: 0b723fa3c21ee9ba5340899021c2d9b93f0948a4c5ad54b09f37f74a00eb62f8
4
+ data.tar.gz: 6bf50b0df694a8138b171448db2db85351a55e1d71e002f443d72bade52df0b2
5
5
  SHA512:
6
- metadata.gz: 7f771cd6f27485c08d68fb18c8a6883e717b0ea366ab26c2d24ab1e48cfd7201a708990b6628de421ddfb06d046110f35f2ae10ab7a685b0cefab7c8ae67ab21
7
- data.tar.gz: fb2bcc5f4b4e8281908f95be506b257da08b813bf3a9ea8e3d54d180290e2dcb4c959d8075d9bb231382a58ea7412acd1cb3baf33a1ebfc4118b2ca7f5ab59f6
6
+ metadata.gz: ab7c71d3f03e44ff5e39b54182cc698e844e9d5136ddf4c74d4066269e1a1f8f0496a9c2e282fbc76392964c193a7ab1a6a33420cde68a9e0427d7a0dea8dcc1
7
+ data.tar.gz: b0d7160b1ae21593097b83384daa7121b15b6841408e0f1fd6d818931ad087817771faa47373675f33ef742bf2a404fbd9948758298afdeaeb651caaac689135
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # MacIosInfo
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mac_ios_info`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Resolve a macOS **build number** (the value Xcode writes into `BuildMachineOSBuild`,
4
+ e.g. `24G830`) into a macOS version and marketing name.
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ ```ruby
7
+ MacIosInfo.macos_build_to_macos_version(build_number: "24G830") #=> "15.7.9"
8
+ MacIosInfo.macos_build_to_os_name(build_number: "24G830") #=> "macOS Sequoia"
9
+ MacIosInfo.macos_version_to_os_name(version: "15.7.9") #=> "macOS Sequoia"
10
+ ```
6
11
 
7
12
  ## Installation
8
13
 
@@ -22,7 +27,67 @@ Or install it yourself as:
22
27
 
23
28
  ## Usage
24
29
 
25
- TODO: Write usage instructions here
30
+ ### macos_build_to_macos_version
31
+
32
+ Returns the exact macOS version for a known build number.
33
+
34
+ ```ruby
35
+ MacIosInfo.macos_build_to_macos_version(build_number: "20D80") #=> "11.2.2"
36
+ MacIosInfo.macos_build_to_macos_version(build_number: "24C101") #=> "15.2"
37
+ MacIosInfo.macos_build_to_macos_version(build_number: "25G83") #=> "26.6.2"
38
+ ```
39
+
40
+ A build number begins with the Darwin (kernel) major version, so when a build is
41
+ not in the table the **major version is still derived from it** rather than giving up:
42
+
43
+ ```ruby
44
+ # a point release published after this gem was updated
45
+ MacIosInfo.macos_build_to_macos_version(build_number: "25Z999") #=> "26"
46
+ ```
47
+
48
+ `"UnKnown"` is only returned when even the release family cannot be determined:
49
+
50
+ ```ruby
51
+ MacIosInfo.macos_build_to_macos_version(build_number: "99A1") #=> "UnKnown"
52
+ ```
53
+
54
+ ### macos_build_to_os_name
55
+
56
+ Goes straight from a build number to the marketing name. This works for every
57
+ build of a known release family, including ones not in the version table.
58
+
59
+ ```ruby
60
+ MacIosInfo.macos_build_to_os_name(build_number: "24A335") #=> "macOS Sequoia"
61
+ MacIosInfo.macos_build_to_os_name(build_number: "24Z999") #=> "macOS Sequoia"
62
+ ```
63
+
64
+ ### macos_version_to_os_name
65
+
66
+ ```ruby
67
+ MacIosInfo.macos_version_to_os_name(version: "10.13.5") #=> "macOS High Sierra"
68
+ MacIosInfo.macos_version_to_os_name(version: "11.2.2") #=> "macOS Big Sur"
69
+ MacIosInfo.macos_version_to_os_name(version: "26.6.2") #=> "macOS Tahoe"
70
+ MacIosInfo.macos_version_to_os_name(version: "15") #=> "macOS Sequoia"
71
+ ```
72
+
73
+ ## Supported releases
74
+
75
+ | Darwin | macOS | Name |
76
+ | --- | --- | --- |
77
+ | 16 | 10.12 | macOS Sierra |
78
+ | 17 | 10.13 | macOS High Sierra |
79
+ | 18 | 10.14 | macOS Mojave |
80
+ | 19 | 10.15 | macOS Catalina |
81
+ | 20 | 11 | macOS Big Sur |
82
+ | 21 | 12 | macOS Monterey |
83
+ | 22 | 13 | macOS Ventura |
84
+ | 23 | 14 | macOS Sonoma |
85
+ | 24 | 15 | macOS Sequoia |
86
+ | 25 | 26 | macOS Tahoe |
87
+
88
+ Exact build numbers are listed for macOS High Sierra through macOS Tahoe. Builds
89
+ outside that table resolve to the release family via the Darwin major version, so
90
+ a new macOS release does not have to be added here before it reports correctly.
26
91
 
27
92
  ## Development
28
93
 
@@ -32,8 +97,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
97
 
33
98
  ## Contributing
34
99
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mac_ios_info. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/mac_ios_info/blob/master/CODE_OF_CONDUCT.md).
36
-
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tarappo/mac_ios_info. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/tarappo/mac_ios_info/blob/main/CODE_OF_CONDUCT.md).
37
101
 
38
102
  ## License
39
103
 
@@ -41,4 +105,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
41
105
 
42
106
  ## Code of Conduct
43
107
 
44
- Everyone interacting in the MacIosInfo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mac_ios_info/blob/master/CODE_OF_CONDUCT.md).
108
+ Everyone interacting in the MacIosInfo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tarappo/mac_ios_info/blob/main/CODE_OF_CONDUCT.md).
@@ -1,3 +1,3 @@
1
1
  module MacIosInfo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/mac_ios_info.rb CHANGED
@@ -3,99 +3,369 @@ require "mac_ios_info/version"
3
3
  module MacIosInfo
4
4
  class Error < StandardError; end
5
5
 
6
- # Change macOS build number to macOS version
7
- # @param build_number macOS Build Number
8
- # @return macOS version(High Sierra or higher)
6
+ UNKNOWN = "UnKnown".freeze
7
+
8
+ # Darwin (kernel) major version => [macOS name, macOS major version].
9
+ #
10
+ # A macOS build number starts with the Darwin major version ("24G830" => 24),
11
+ # so this resolves the release family of *any* build, including releases that
12
+ # came out after this gem was published.
13
+ DARWIN_MAJOR_TO_MACOS = {
14
+ 16 => ["macOS Sierra", "10.12"],
15
+ 17 => ["macOS High Sierra", "10.13"],
16
+ 18 => ["macOS Mojave", "10.14"],
17
+ 19 => ["macOS Catalina", "10.15"],
18
+ 20 => ["macOS Big Sur", "11"],
19
+ 21 => ["macOS Monterey", "12"],
20
+ 22 => ["macOS Ventura", "13"],
21
+ 23 => ["macOS Sonoma", "14"],
22
+ 24 => ["macOS Sequoia", "15"],
23
+ 25 => ["macOS Tahoe", "26"]
24
+ }.freeze
25
+
26
+ # macOS version major => macOS name, for macOS 11 and later.
27
+ MAJOR_TO_OS_NAME = DARWIN_MAJOR_TO_MACOS.each_with_object({}) do |(_darwin, (name, version)), acc|
28
+ next if version.start_with?("10.")
29
+
30
+ acc[version.to_i] = name
31
+ end.freeze
32
+
33
+ # macOS version minor => macOS name, for the "10.x" era.
34
+ LEGACY_MINOR_TO_OS_NAME = DARWIN_MAJOR_TO_MACOS.each_with_object({}) do |(_darwin, (name, version)), acc|
35
+ next unless version.start_with?("10.")
36
+
37
+ acc[version.split(".")[1].to_i] = name
38
+ end.freeze
39
+
40
+ # macOS build number => macOS version.
41
+ BUILD_NUMBER_TO_VERSION = {
42
+ # macOS High Sierra
43
+ "17A365" => "10.13",
44
+ "17A405" => "10.13",
45
+ "17B1002" => "10.13.1",
46
+ "17B1003" => "10.13.1",
47
+ "17B48" => "10.13.1",
48
+ "17C205" => "10.13.2",
49
+ "17C2205" => "10.13.2",
50
+ "17C88" => "10.13.2",
51
+ "17C89" => "10.13.2",
52
+ "17D102" => "10.13.3",
53
+ "17D2047" => "10.13.3",
54
+ "17D2102" => "10.13.3",
55
+ "17D47" => "10.13.3",
56
+ "17E199" => "10.13.4",
57
+ "17E201" => "10.13.4",
58
+ "17E202" => "10.13.4",
59
+ "17F77" => "10.13.5",
60
+ "17G10021" => "10.13.6",
61
+ "17G11023" => "10.13.6",
62
+ "17G12034" => "10.13.6",
63
+ "17G13033" => "10.13.6",
64
+ "17G13035" => "10.13.6",
65
+ "17G14019" => "10.13.6",
66
+ "17G14033" => "10.13.6",
67
+ "17G14042" => "10.13.6",
68
+ "17G2208" => "10.13.6",
69
+ "17G2307" => "10.13.6",
70
+ "17G3025" => "10.13.6",
71
+ "17G4015" => "10.13.6",
72
+ "17G5019" => "10.13.6",
73
+ "17G6029" => "10.13.6",
74
+ "17G6030" => "10.13.6",
75
+ "17G65" => "10.13.6",
76
+ "17G7024" => "10.13.6",
77
+ "17G8029" => "10.13.6",
78
+ "17G8030" => "10.13.6",
79
+ "17G8037" => "10.13.6",
80
+ "17G9016" => "10.13.6",
81
+
82
+ # macOS Mojave
83
+ "18A391" => "10.14",
84
+ "18B2107" => "10.14.1",
85
+ "18B3094" => "10.14.1",
86
+ "18B75" => "10.14.1",
87
+ "18C54" => "10.14.2",
88
+ "18D109" => "10.14.3",
89
+ "18D42" => "10.14.3",
90
+ "18D43" => "10.14.3",
91
+ "18E226" => "10.14.4",
92
+ "18E227" => "10.14.4",
93
+ "18F132" => "10.14.5",
94
+ "18F203" => "10.14.5",
95
+ "18G1012" => "10.14.6",
96
+ "18G103" => "10.14.6",
97
+ "18G84" => "10.14.6",
98
+ "18G95" => "10.14.6",
99
+
100
+ # macOS Catalina
101
+ "19A583" => "10.15",
102
+ "19A602" => "10.15",
103
+ "19A603" => "10.15",
104
+ "19B88" => "10.15.1",
105
+ "19C57" => "10.15.2",
106
+ "19C58" => "10.15.2",
107
+ "19D76" => "10.15.3",
108
+ "19E266" => "10.15.4",
109
+ "19E287" => "10.15.4",
110
+ "19F101" => "10.15.5",
111
+ "19F96" => "10.15.5",
112
+ "19G2021" => "10.15.6",
113
+ "19G73" => "10.15.6",
114
+ "19H1030" => "10.15.7",
115
+ "19H114" => "10.15.7",
116
+ "19H1217" => "10.15.7",
117
+ "19H1323" => "10.15.7",
118
+ "19H1417" => "10.15.7",
119
+ "19H1419" => "10.15.7",
120
+ "19H15" => "10.15.7",
121
+ "19H1519" => "10.15.7",
122
+ "19H1615" => "10.15.7",
123
+ "19H1713" => "10.15.7",
124
+ "19H1715" => "10.15.7",
125
+ "19H1824" => "10.15.7",
126
+ "19H1922" => "10.15.7",
127
+ "19H2" => "10.15.7",
128
+ "19H2026" => "10.15.7",
129
+ "19H4" => "10.15.7",
130
+ "19H512" => "10.15.7",
131
+ "19H524" => "10.15.7",
132
+ "19H2036" => "10.15.8",
133
+
134
+ # macOS Big Sur
135
+ "20A2411" => "11.0",
136
+ "20B29" => "11.0.1",
137
+ "20B50" => "11.0.1",
138
+ "20C69" => "11.1",
139
+ "20D64" => "11.2",
140
+ "20D74" => "11.2.1",
141
+ "20D75" => "11.2.1",
142
+ "20D80" => "11.2.2",
143
+ "20D91" => "11.2.3",
144
+ "20E232" => "11.3",
145
+ "20E241" => "11.3.1",
146
+ "20F71" => "11.4",
147
+ "20G71" => "11.5",
148
+ "20G80" => "11.5.1",
149
+ "20G95" => "11.5.2",
150
+ "20G165" => "11.6",
151
+ "20G224" => "11.6.1",
152
+ "20G314" => "11.6.2",
153
+ "20G415" => "11.6.3",
154
+ "20G417" => "11.6.4",
155
+ "20G527" => "11.6.5",
156
+ "20G624" => "11.6.6",
157
+ "20G630" => "11.6.7",
158
+ "20G730" => "11.6.8",
159
+ "20G817" => "11.7",
160
+ "20G918" => "11.7.1",
161
+ "20G1020" => "11.7.2",
162
+ "20G1116" => "11.7.3",
163
+ "20G1120" => "11.7.4",
164
+ "20G1225" => "11.7.5",
165
+ "20G1231" => "11.7.6",
166
+ "20G1345" => "11.7.7",
167
+ "20G1351" => "11.7.8",
168
+ "20G1426" => "11.7.9",
169
+ "20G1427" => "11.7.10",
170
+ "20G1443" => "11.7.11",
171
+
172
+ # macOS Monterey
173
+ "21A344" => "12.0",
174
+ "21A559" => "12.0.1",
175
+ "21C52" => "12.1",
176
+ "21D49" => "12.2",
177
+ "21D62" => "12.2.1",
178
+ "21E230" => "12.3",
179
+ "21E258" => "12.3.1",
180
+ "21F2081" => "12.4",
181
+ "21F2092" => "12.4",
182
+ "21F79" => "12.4",
183
+ "21G72" => "12.5",
184
+ "21G83" => "12.5.1",
185
+ "21G115" => "12.6",
186
+ "21G217" => "12.6.1",
187
+ "21G320" => "12.6.2",
188
+ "21G419" => "12.6.3",
189
+ "21G526" => "12.6.4",
190
+ "21G531" => "12.6.5",
191
+ "21G646" => "12.6.6",
192
+ "21G651" => "12.6.7",
193
+ "21G725" => "12.6.8",
194
+ "21G726" => "12.6.9",
195
+ "21G816" => "12.7",
196
+ "21G920" => "12.7.1",
197
+ "21G1974" => "12.7.2",
198
+ "21H1015" => "12.7.3",
199
+ "21H1123" => "12.7.4",
200
+ "21H1222" => "12.7.5",
201
+ "21H1320" => "12.7.6",
202
+
203
+ # macOS Ventura
204
+ "22A380" => "13.0",
205
+ "22A400" => "13.0.1",
206
+ "22C65" => "13.1",
207
+ "22D49" => "13.2",
208
+ "22D68" => "13.2.1",
209
+ "22E252" => "13.3",
210
+ "22E261" => "13.3.1",
211
+ "22E772610a" => "13.3.1",
212
+ "22F66" => "13.4",
213
+ "22F770820b" => "13.4.1",
214
+ "22F770820d" => "13.4.1",
215
+ "22F82" => "13.4.1",
216
+ "22G74" => "13.5",
217
+ "22G90" => "13.5.1",
218
+ "22G91" => "13.5.2",
219
+ "22G120" => "13.6",
220
+ "22G313" => "13.6.1",
221
+ "22G320" => "13.6.2",
222
+ "22G436" => "13.6.3",
223
+ "22G513" => "13.6.4",
224
+ "22G621" => "13.6.5",
225
+ "22G630" => "13.6.6",
226
+ "22G720" => "13.6.7",
227
+ "22G820" => "13.6.8",
228
+ "22G830" => "13.6.9",
229
+ "22H123" => "13.7",
230
+ "22H221" => "13.7.1",
231
+ "22H313" => "13.7.2",
232
+ "22H417" => "13.7.3",
233
+ "22H420" => "13.7.4",
234
+ "22H527" => "13.7.5",
235
+ "22H625" => "13.7.6",
236
+ "22H722" => "13.7.7",
237
+ "22H730" => "13.7.8",
238
+
239
+ # macOS Sonoma
240
+ "23A344" => "14.0",
241
+ "23B74" => "14.1",
242
+ "23B2082" => "14.1.1",
243
+ "23B81" => "14.1.1",
244
+ "23B92" => "14.1.2",
245
+ "23C64" => "14.2",
246
+ "23C71" => "14.2.1",
247
+ "23D56" => "14.3",
248
+ "23D60" => "14.3.1",
249
+ "23E214" => "14.4",
250
+ "23E224" => "14.4.1",
251
+ "23F79" => "14.5",
252
+ "23G80" => "14.6",
253
+ "23G93" => "14.6.1",
254
+ "23H124" => "14.7",
255
+ "23H222" => "14.7.1",
256
+ "23H311" => "14.7.2",
257
+ "23H417" => "14.7.3",
258
+ "23H420" => "14.7.4",
259
+ "23H527" => "14.7.5",
260
+ "23H626" => "14.7.6",
261
+ "23H723" => "14.7.7",
262
+ "23H730" => "14.7.8",
263
+ "23J21" => "14.8",
264
+ "23J30" => "14.8.1",
265
+ "23J126" => "14.8.2",
266
+ "23J220" => "14.8.3",
267
+ "23J319" => "14.8.4",
268
+ "23J423" => "14.8.5",
269
+ "23J520" => "14.8.7",
270
+ "23J620" => "14.8.8",
271
+ "23J631" => "14.8.9",
272
+
273
+ # macOS Sequoia
274
+ "24A335" => "15.0",
275
+ "24A348" => "15.0.1",
276
+ "24B2083" => "15.1",
277
+ "24B83" => "15.1",
278
+ "24B91" => "15.1.1",
279
+ "24C101" => "15.2",
280
+ "24D60" => "15.3",
281
+ "24D70" => "15.3.1",
282
+ "24D2082" => "15.3.2",
283
+ "24D81" => "15.3.2",
284
+ "24E248" => "15.4",
285
+ "24E263" => "15.4.1",
286
+ "24F74" => "15.5",
287
+ "24G84" => "15.6",
288
+ "24G90" => "15.6.1",
289
+ "24G222" => "15.7",
290
+ "24G231" => "15.7.1",
291
+ "24G325" => "15.7.2",
292
+ "24G419" => "15.7.3",
293
+ "24G517" => "15.7.4",
294
+ "24G624" => "15.7.5",
295
+ "24G720" => "15.7.7",
296
+ "24G824" => "15.7.8",
297
+ "24G830" => "15.7.9",
298
+
299
+ # macOS Tahoe
300
+ "25A354" => "26.0",
301
+ "25A8353" => "26.0",
302
+ "25A362" => "26.0.1",
303
+ "25A8364" => "26.0.1",
304
+ "25B78" => "26.1",
305
+ "25C56" => "26.2",
306
+ "25D125" => "26.3",
307
+ "25D2128" => "26.3.1",
308
+ "25D771280a" => "26.3.1",
309
+ "25D2140" => "26.3.2",
310
+ "25D771400a" => "26.3.2",
311
+ "25E246" => "26.4",
312
+ "25E253" => "26.4.1",
313
+ "25F71" => "26.5",
314
+ "25F80" => "26.5.1",
315
+ "25F84" => "26.5.2",
316
+ "25G72" => "26.6",
317
+ "25G76" => "26.6.1",
318
+ "25G83" => "26.6.2"
319
+ }.freeze
320
+
321
+ # Change a macOS build number to a macOS version.
322
+ #
323
+ # When the exact build is not listed, the major version is derived from the
324
+ # build number instead of giving up, so newer releases still resolve.
325
+ #
326
+ # @param build_number macOS build number (e.g. "24G830")
327
+ # @return the version (e.g. "15.7.9"), the major version alone when only the
328
+ # release family is known (e.g. "15"), or "UnKnown"
9
329
  def self.macos_build_to_macos_version(build_number:)
10
- case build_number
11
- # macOS Big Sur
12
- when "20D80" then
13
- "11.2.2"
14
- when "20D74", "20D75" then
15
- "11.2.1"
16
- when "20D64" then
17
- "11.2"
18
- when "20C69" then
19
- "11.1"
20
- when "20B29", "20B50" then
21
- "11.0.1"
22
- when "20A2411" then
23
- "11.0.0"
24
- # macOS Catalina
25
- when "19H2", "19H15" then
26
- "10.15.7"
27
- when "19G73", "19G2021" then
28
- "10.15.6"
29
- when "19F101", "19F96" then
30
- "10.15.5"
31
- when "19E266" then
32
- "10.15.4"
33
- when "19D76" then
34
- "10.15.3"
35
- when "19C57" then
36
- "10.15.2"
37
- when "19B88" then
38
- "10.15.1"
39
- when "19A583", "19A602", "19A603" then
40
- "10.15"
41
- # macOS Mojave
42
- when "18G84", "18G103", "18G1012", "18G95" then
43
- "10.14.6"
44
- when "18F132", "18F203" then
45
- "10.14.5"
46
- when "18E226", "18E227" then
47
- "10.14.4"
48
- when "18D42", "18D43", "18D109" then
49
- "10.14.3"
50
- when "18C54" then
51
- "10.14.2"
52
- when "18B75", "18B2107", "18B3094" then
53
- "10.14.1"
54
- when "18A391" then
55
- "10.14"
56
- # macOS High Sierra
57
- when "17G65", "17G6029" then
58
- "10.13.6"
59
- when "17F77" then
60
- "10.13.5"
61
- when "17E199", "17E201", "17E202" then
62
- "10.13.4"
63
- when "17D47", "17D102", "17D2047", "17D2102" then
64
- "10.13.3"
65
- when "17C88", "17C89", "17C205", "17C2205" then
66
- "10.13.2"
67
- when "17B48", "17B1002", "17B1003" then
68
- "10.13.1"
69
- when "17A365", "17A405" then
70
- "10.13"
71
- else
72
- "UnKnown"
73
- end
330
+ exact = BUILD_NUMBER_TO_VERSION[build_number.to_s]
331
+ return exact unless exact.nil?
332
+
333
+ _name, version = darwin_major_to_macos(build_number)
334
+ version || UNKNOWN
335
+ end
336
+
337
+ # Change a macOS build number to a macOS name.
338
+ #
339
+ # @param build_number macOS build number (e.g. "24G830")
340
+ # @return the name (e.g. "macOS Sequoia") or "UnKnown"
341
+ def self.macos_build_to_os_name(build_number:)
342
+ name, = darwin_major_to_macos(build_number)
343
+ return name unless name.nil?
344
+
345
+ macos_version_to_os_name(version: macos_build_to_macos_version(build_number: build_number))
74
346
  end
75
347
 
76
- # Change version to macOS Name
77
- # @param version (e.g. 10.15.7)
78
- # @return macOS Name
348
+ # Change a macOS version to a macOS name.
349
+ #
350
+ # @param version macOS version (e.g. "15.7.9", "15")
351
+ # @return the name (e.g. "macOS Sequoia") or "UnKnown"
79
352
  def self.macos_version_to_os_name(version:)
80
- major_version = version.split(".")[0].to_i
81
- minor_version = version.split(".")[1].to_i
82
- # reference https://support.apple.com/ja-jp/HT201260
83
- case major_version
84
- when 11
85
- return "macOS Big Sur"
86
- end
87
-
88
- case minor_version
89
- when 15
90
- "macOS Catalina"
91
- when 14
92
- "macOS Mojave"
93
- when 13
94
- "macOS High Sierra"
95
- when 12
96
- "macOS Sierra"
97
- else
98
- "UnKnown"
99
- end
353
+ major, minor = version.to_s.split(".")
354
+ return UNKNOWN if major.nil? || major.empty?
355
+
356
+ return MAJOR_TO_OS_NAME.fetch(major.to_i, UNKNOWN) unless major == "10"
357
+ return UNKNOWN if minor.nil?
358
+
359
+ LEGACY_MINOR_TO_OS_NAME.fetch(minor.to_i, UNKNOWN)
360
+ end
361
+
362
+ # @return [macOS name, macOS major version], or [nil, nil] when the build
363
+ # number does not start with a Darwin major version we know
364
+ def self.darwin_major_to_macos(build_number)
365
+ darwin_major = build_number.to_s[/\A\d+/]
366
+ return [nil, nil] if darwin_major.nil?
367
+
368
+ DARWIN_MAJOR_TO_MACOS.fetch(darwin_major.to_i, [nil, nil])
100
369
  end
370
+ private_class_method :darwin_major_to_macos
101
371
  end
data/mac_ios_info.gemspec CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.email = ["tarappo@gmail.com"]
8
8
 
9
9
  spec.summary = %q{macOS, iOS Information}
10
+ spec.description = %q{Resolve a macOS build number (the value Xcode writes into BuildMachineOSBuild, e.g. 24G830) into a macOS version and marketing name. Build numbers start with the Darwin major version, so releases published after this gem was updated still resolve to their release family instead of being reported as unknown.}
10
11
  spec.homepage = "https://github.com/tarappo/mac_ios_info"
11
12
  spec.license = "MIT"
12
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
@@ -14,11 +15,15 @@ Gem::Specification.new do |spec|
14
15
  spec.metadata["homepage_uri"] = spec.homepage
15
16
  spec.metadata["source_code_uri"] = "https://github.com/tarappo/mac_ios_info"
16
17
  spec.metadata["changelog_uri"] = "https://github.com/tarappo/mac_ios_info/releases"
18
+ spec.metadata["rubygems_mfa_required"] = "true"
17
19
 
18
20
  # Specify which files should be added to the gem when it is released.
19
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
22
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ # drop the specs and the editor/IDE files that do not belong in the package
25
+ f.match(%r{^(test|spec|features)/}) || f.match(%r{^\.(idea/|rakeTasks)})
26
+ end
22
27
  end
23
28
  spec.bindir = "exe"
24
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
metadata CHANGED
@@ -1,16 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mac_ios_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tarappo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-27 00:00:00.000000000 Z
11
+ date: 2026-08-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description: Resolve a macOS build number (the value Xcode writes into BuildMachineOSBuild,
14
+ e.g. 24G830) into a macOS version and marketing name. Build numbers start with the
15
+ Darwin major version, so releases published after this gem was updated still resolve
16
+ to their release family instead of being reported as unknown.
14
17
  email:
15
18
  - tarappo@gmail.com
16
19
  executables: []
@@ -18,13 +21,6 @@ extensions: []
18
21
  extra_rdoc_files: []
19
22
  files:
20
23
  - ".gitignore"
21
- - ".idea/.gitignore"
22
- - ".idea/inspectionProfiles/Project_Default.xml"
23
- - ".idea/mac_ios_info.iml"
24
- - ".idea/misc.xml"
25
- - ".idea/modules.xml"
26
- - ".idea/vcs.xml"
27
- - ".rakeTasks"
28
24
  - ".rspec"
29
25
  - CODE_OF_CONDUCT.md
30
26
  - Gemfile
@@ -44,7 +40,8 @@ metadata:
44
40
  homepage_uri: https://github.com/tarappo/mac_ios_info
45
41
  source_code_uri: https://github.com/tarappo/mac_ios_info
46
42
  changelog_uri: https://github.com/tarappo/mac_ios_info/releases
47
- post_install_message:
43
+ rubygems_mfa_required: 'true'
44
+ post_install_message:
48
45
  rdoc_options: []
49
46
  require_paths:
50
47
  - lib
@@ -59,8 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
56
  - !ruby/object:Gem::Version
60
57
  version: '0'
61
58
  requirements: []
62
- rubygems_version: 3.0.3
63
- signing_key:
59
+ rubygems_version: 3.4.19
60
+ signing_key:
64
61
  specification_version: 4
65
62
  summary: macOS, iOS Information
66
63
  test_files: []
data/.idea/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Datasource local storage ignored files
5
- /dataSources/
6
- /dataSources.local.xml
7
- # Editor-based HTTP Client requests
8
- /httpRequests/
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
- </profile>
6
- </component>
@@ -1,17 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="ModuleRunConfigurationManager">
4
- <shared />
5
- </component>
6
- <component name="NewModuleRootManager">
7
- <content url="file://$MODULE_DIR$">
8
- <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
- <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
- <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
- </content>
12
- <orderEntry type="inheritedJdk" />
13
- <orderEntry type="sourceFolder" forTests="false" />
14
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.2, rbenv: 2.6.5) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="rake (v12.3.2, rbenv: 2.6.5) [gem]" level="application" />
16
- </component>
17
- </module>
data/.idea/misc.xml DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptSettings">
4
- <option name="languageLevel" value="ES6" />
5
- </component>
6
- <component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 2.6.5" project-jdk-type="RUBY_SDK" />
7
- </project>
data/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/mac_ios_info.iml" filepath="$PROJECT_DIR$/.idea/mac_ios_info.iml" />
6
- </modules>
7
- </component>
8
- </project>
data/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
data/.rakeTasks DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Settings><!--This file was automatically generated by Ruby plugin.
3
- You are allowed to:
4
- 1. Remove rake task
5
- 2. Add existing rake tasks
6
- To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>