macos.rb 0.54.0 → 0.55.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 +4 -4
- data/CHANGELOG +13 -0
- data/lib/MacOS/USBFlashDrive.rb +12 -2
- data/lib/MacOS/VERSION.rb +1 -1
- data/test/MacOS/USBFlashDrive_test.rb +13 -5
- data/test/commands_test.rb +1 -1
- data/test/fixtures/system_profiler-SPUSBDataType.json +147 -0
- metadata +2 -2
- data/test/fixtures/system_profiler-SPUSBDataType.txt +0 -58
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c622c8e7b2f39cac37e078cbd4351c89dfd2ff1ee30c19086bc51732f1fed03
|
|
4
|
+
data.tar.gz: c1debdded1f8caeb0be74973eeaf080148cf4947a61a1f0fe4bb6784db56091d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 571f84bfbbc9a6b93c87b2941279292b4f424cf5309ed0189fb3ef7dd0ada437b014767c92ba1dbbcbefdff53cd7dfa42f168b51a9c7c445c65949e18cbbfb73
|
|
7
|
+
data.tar.gz: e4fa5ffbaf59c18e053f9551c93e9f5d837371af9ee67754a1714102717807c24a7d610351b582f99f1d5937bc70708bd440c9e7862b36553bf85de703328d7e
|
data/CHANGELOG
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## 20261111
|
|
4
4
|
|
|
5
|
+
0.55.0: ~ MacOS::USBFlashDrive: It reads the mount points from system_profiler -json, rather than from its text.
|
|
6
|
+
|
|
7
|
+
1. ~ MacOS::USBFlashDrive.system_profiler_usb_data_type_command: It runs system_profiler -json SPUSBDataType, the text being translated outside an English locale.
|
|
8
|
+
2. ~ MacOS::USBFlashDrive.all_mount_points: It takes each volume's mount_point from the JSON, a volume not mounted having none.
|
|
9
|
+
3. + MacOS::USBFlashDrive.volumes, private: Every volume of every device, behind a hub or not.
|
|
10
|
+
4. ~ lib/MacOS/USBFlashDrive.rb: + require 'json'.
|
|
11
|
+
5. + test/fixtures/system_profiler-SPUSBDataType.json: The keys of a real capture, with example values.
|
|
12
|
+
6. - test/fixtures/system_profiler-SPUSBDataType.txt
|
|
13
|
+
7. ~ test/MacOS/USBFlashDrive_test.rb: Mount points are found behind a hub or not, and none for a volume not mounted or where no drive is plugged in.
|
|
14
|
+
8. ~ test/commands_test.rb: The system_profiler command takes -json.
|
|
15
|
+
9. ~ TODO: - 6, done, the rest renumbered.
|
|
16
|
+
10. ~ MacOS::VERSION: /0.54.0/0.55.0/
|
|
17
|
+
|
|
5
18
|
0.54.0: ~ MacOS::SystemProfiler: It reads system_profiler -json, giving each field as the JSON gives it; - its interpreting methods.
|
|
6
19
|
|
|
7
20
|
1. ~ MacOS::SystemProfiler.system_profiler_output: It runs system_profiler -json SPSoftwareDataType, the text being translated outside an English locale.
|
data/lib/MacOS/USBFlashDrive.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# MacOS/USBFlashDrive.rb
|
|
2
2
|
# MacOS::USBFlashDrive
|
|
3
3
|
|
|
4
|
+
require 'json'
|
|
4
5
|
require 'open3'
|
|
5
6
|
require 'shellwords'
|
|
6
7
|
|
|
@@ -9,7 +10,7 @@ module MacOS
|
|
|
9
10
|
class << self
|
|
10
11
|
|
|
11
12
|
def system_profiler_usb_data_type_command
|
|
12
|
-
"system_profiler SPUSBDataType"
|
|
13
|
+
"system_profiler -json SPUSBDataType"
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def raw_system_profiler_output
|
|
@@ -18,7 +19,16 @@ module MacOS
|
|
|
18
19
|
|
|
19
20
|
def all_mount_points
|
|
20
21
|
stdout, stderr, status = raw_system_profiler_output
|
|
21
|
-
|
|
22
|
+
volumes(JSON.parse(stdout)['SPUSBDataType']).filter_map{|volume| volume['mount_point']}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
# Every volume of every device, a device behind a hub being listed under the hub's _items.
|
|
28
|
+
def volumes(devices)
|
|
29
|
+
devices.flat_map do |device|
|
|
30
|
+
(device['Media'] || []).flat_map{|media| media['volumes'] || []} + volumes(device['_items'] || [])
|
|
31
|
+
end
|
|
22
32
|
end
|
|
23
33
|
|
|
24
34
|
end # class << self
|
data/lib/MacOS/VERSION.rb
CHANGED
|
@@ -2,19 +2,27 @@ require_relative '../helper'
|
|
|
2
2
|
require 'MacOS/USBFlashDrive'
|
|
3
3
|
|
|
4
4
|
describe MacOS::USBFlashDrive do
|
|
5
|
+
def with_output(output, &block)
|
|
6
|
+
MacOS::USBFlashDrive.stub(:raw_system_profiler_output, [output, '', nil], &block)
|
|
7
|
+
end
|
|
8
|
+
|
|
5
9
|
it "asks system_profiler for the USB devices" do
|
|
6
|
-
_(MacOS::USBFlashDrive.system_profiler_usb_data_type_command).must_equal('system_profiler SPUSBDataType')
|
|
10
|
+
_(MacOS::USBFlashDrive.system_profiler_usb_data_type_command).must_equal('system_profiler -json SPUSBDataType')
|
|
7
11
|
end
|
|
8
12
|
|
|
9
|
-
it "gives every flash drive's mount point" do
|
|
10
|
-
|
|
13
|
+
it "gives every flash drive's mount point, behind a hub or not, and none for a volume which isn't mounted" do
|
|
14
|
+
with_output(fixture('system_profiler-SPUSBDataType.json')) do
|
|
11
15
|
_(MacOS::USBFlashDrive.all_mount_points).must_equal(['/Volumes/EXAMPLE', '/Volumes/Example 2'])
|
|
12
16
|
end
|
|
13
17
|
end
|
|
14
18
|
|
|
15
|
-
it "gives none where no flash drive is
|
|
16
|
-
|
|
19
|
+
it "gives none where no flash drive is plugged in" do
|
|
20
|
+
with_output('{"SPUSBDataType": [{"_name": "USB31Bus", "host_controller": "AppleUSBXHCI"}]}') do
|
|
17
21
|
_(MacOS::USBFlashDrive.all_mount_points).must_equal([])
|
|
18
22
|
end
|
|
19
23
|
end
|
|
24
|
+
|
|
25
|
+
it "keeps its walk through the devices to itself" do
|
|
26
|
+
_(MacOS::USBFlashDrive.respond_to?(:volumes)).must_equal(false)
|
|
27
|
+
end
|
|
20
28
|
end
|
data/test/commands_test.rb
CHANGED
|
@@ -49,6 +49,6 @@ describe "the commands" do
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "asks system_profiler for the USB devices" do
|
|
52
|
-
_(captured_by(MacOS::USBFlashDrive, :raw_system_profiler_output)).must_equal(['system_profiler SPUSBDataType'])
|
|
52
|
+
_(captured_by(MacOS::USBFlashDrive, :raw_system_profiler_output)).must_equal(['system_profiler -json SPUSBDataType'])
|
|
53
53
|
end
|
|
54
54
|
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
{
|
|
2
|
+
"SPUSBDataType" : [
|
|
3
|
+
{
|
|
4
|
+
"_name" : "USB31Bus",
|
|
5
|
+
"host_controller" : "AppleUSBXHCI"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"_name" : "USB31Bus",
|
|
9
|
+
"host_controller" : "AppleUSBXHCI",
|
|
10
|
+
"_items" : [
|
|
11
|
+
{
|
|
12
|
+
"_name" : "USB3.1 Hub",
|
|
13
|
+
"bcd_device" : "1.00",
|
|
14
|
+
"bus_power" : "900",
|
|
15
|
+
"bus_power_used" : "896",
|
|
16
|
+
"device_speed" : "super_speed",
|
|
17
|
+
"extra_current_used" : "0",
|
|
18
|
+
"location_id" : "0x01100000",
|
|
19
|
+
"manufacturer" : "Example",
|
|
20
|
+
"product_id" : "0x0000",
|
|
21
|
+
"vendor_id" : "0x0000",
|
|
22
|
+
"_items" : [
|
|
23
|
+
{
|
|
24
|
+
"_name" : "Flash Drive",
|
|
25
|
+
"bcd_device" : "1.00",
|
|
26
|
+
"bus_power" : "900",
|
|
27
|
+
"bus_power_used" : "896",
|
|
28
|
+
"device_speed" : "super_speed",
|
|
29
|
+
"extra_current_used" : "0",
|
|
30
|
+
"location_id" : "0x01100000",
|
|
31
|
+
"manufacturer" : "Example",
|
|
32
|
+
"product_id" : "0x0000",
|
|
33
|
+
"serial_num" : "EXAMPLE000000000",
|
|
34
|
+
"vendor_id" : "0x0000",
|
|
35
|
+
"Media" : [
|
|
36
|
+
{
|
|
37
|
+
"_name" : "Flash Drive",
|
|
38
|
+
"bsd_name" : "disk4",
|
|
39
|
+
"Logical Unit" : 0,
|
|
40
|
+
"partition_map_type" : "master_boot_record_partition_map_type",
|
|
41
|
+
"removable_media" : "yes",
|
|
42
|
+
"size" : "32 GB",
|
|
43
|
+
"size_in_bytes" : 32000000000,
|
|
44
|
+
"smart_status" : "Verified",
|
|
45
|
+
"USB Interface" : 0,
|
|
46
|
+
"volumes" : [
|
|
47
|
+
{
|
|
48
|
+
"_name" : "EXAMPLE",
|
|
49
|
+
"bsd_name" : "disk4s1",
|
|
50
|
+
"file_system" : "MS-DOS FAT32",
|
|
51
|
+
"free_space" : "31.9 GB",
|
|
52
|
+
"free_space_in_bytes" : 31900000000,
|
|
53
|
+
"iocontent" : "Windows_FAT_32",
|
|
54
|
+
"mount_point" : "/Volumes/EXAMPLE",
|
|
55
|
+
"size" : "32 GB",
|
|
56
|
+
"size_in_bytes" : 32000000000,
|
|
57
|
+
"volume_uuid" : "00000000-0000-0000-0000-000000000000",
|
|
58
|
+
"writable" : "yes"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"_name" : "Flash Drive",
|
|
66
|
+
"bcd_device" : "1.00",
|
|
67
|
+
"bus_power" : "900",
|
|
68
|
+
"bus_power_used" : "896",
|
|
69
|
+
"device_speed" : "super_speed",
|
|
70
|
+
"extra_current_used" : "0",
|
|
71
|
+
"location_id" : "0x01100000",
|
|
72
|
+
"manufacturer" : "Example",
|
|
73
|
+
"product_id" : "0x0000",
|
|
74
|
+
"serial_num" : "EXAMPLE000000000",
|
|
75
|
+
"vendor_id" : "0x0000",
|
|
76
|
+
"Media" : [
|
|
77
|
+
{
|
|
78
|
+
"_name" : "Flash Drive",
|
|
79
|
+
"bsd_name" : "disk4",
|
|
80
|
+
"Logical Unit" : 0,
|
|
81
|
+
"partition_map_type" : "master_boot_record_partition_map_type",
|
|
82
|
+
"removable_media" : "yes",
|
|
83
|
+
"size" : "32 GB",
|
|
84
|
+
"size_in_bytes" : 32000000000,
|
|
85
|
+
"smart_status" : "Verified",
|
|
86
|
+
"USB Interface" : 0,
|
|
87
|
+
"volumes" : [
|
|
88
|
+
{
|
|
89
|
+
"_name" : "EXAMPLE 3",
|
|
90
|
+
"bsd_name" : "disk6s1",
|
|
91
|
+
"file_system" : "MS-DOS FAT32",
|
|
92
|
+
"iocontent" : "Windows_FAT_32",
|
|
93
|
+
"size" : "32 GB",
|
|
94
|
+
"size_in_bytes" : 32000000000,
|
|
95
|
+
"volume_uuid" : "00000000-0000-0000-0000-000000000000"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"_name" : "Flash Drive",
|
|
105
|
+
"bcd_device" : "1.00",
|
|
106
|
+
"bus_power" : "900",
|
|
107
|
+
"bus_power_used" : "896",
|
|
108
|
+
"device_speed" : "super_speed",
|
|
109
|
+
"extra_current_used" : "0",
|
|
110
|
+
"location_id" : "0x01100000",
|
|
111
|
+
"manufacturer" : "Example",
|
|
112
|
+
"product_id" : "0x0000",
|
|
113
|
+
"serial_num" : "EXAMPLE000000000",
|
|
114
|
+
"vendor_id" : "0x0000",
|
|
115
|
+
"Media" : [
|
|
116
|
+
{
|
|
117
|
+
"_name" : "Flash Drive",
|
|
118
|
+
"bsd_name" : "disk4",
|
|
119
|
+
"Logical Unit" : 0,
|
|
120
|
+
"partition_map_type" : "master_boot_record_partition_map_type",
|
|
121
|
+
"removable_media" : "yes",
|
|
122
|
+
"size" : "32 GB",
|
|
123
|
+
"size_in_bytes" : 32000000000,
|
|
124
|
+
"smart_status" : "Verified",
|
|
125
|
+
"USB Interface" : 0,
|
|
126
|
+
"volumes" : [
|
|
127
|
+
{
|
|
128
|
+
"_name" : "Example 2",
|
|
129
|
+
"bsd_name" : "disk5s1",
|
|
130
|
+
"file_system" : "MS-DOS FAT32",
|
|
131
|
+
"free_space" : "31.9 GB",
|
|
132
|
+
"free_space_in_bytes" : 31900000000,
|
|
133
|
+
"iocontent" : "Windows_FAT_32",
|
|
134
|
+
"mount_point" : "/Volumes/Example 2",
|
|
135
|
+
"size" : "32 GB",
|
|
136
|
+
"size_in_bytes" : 32000000000,
|
|
137
|
+
"volume_uuid" : "00000000-0000-0000-0000-000000000000",
|
|
138
|
+
"writable" : "yes"
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: macos.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.55.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -153,7 +153,7 @@ files:
|
|
|
153
153
|
- test/fixtures/say-v.txt
|
|
154
154
|
- test/fixtures/system_profiler-SPAirPortDataType.txt
|
|
155
155
|
- test/fixtures/system_profiler-SPSoftwareDataType.json
|
|
156
|
-
- test/fixtures/system_profiler-SPUSBDataType.
|
|
156
|
+
- test/fixtures/system_profiler-SPUSBDataType.json
|
|
157
157
|
- test/gemspec_test.rb
|
|
158
158
|
- test/helper.rb
|
|
159
159
|
homepage: https://github.com/thoran/macos.rb
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
USB:
|
|
2
|
-
|
|
3
|
-
USB 3.1 Bus:
|
|
4
|
-
|
|
5
|
-
Host Controller Driver: AppleT8112USBXHCI
|
|
6
|
-
|
|
7
|
-
Flash Drive:
|
|
8
|
-
|
|
9
|
-
Product ID: 0x0001
|
|
10
|
-
Vendor ID: 0x0000
|
|
11
|
-
Version: 1.00
|
|
12
|
-
Serial Number: 0000000000000001
|
|
13
|
-
Speed: Up to 5 Gb/s
|
|
14
|
-
Manufacturer: Example
|
|
15
|
-
Location ID: 0x00100000 / 1
|
|
16
|
-
Current Available (mA): 900
|
|
17
|
-
Current Required (mA): 224
|
|
18
|
-
Extra Operating Current (mA): 0
|
|
19
|
-
Media:
|
|
20
|
-
Flash Drive:
|
|
21
|
-
Capacity: 32.01 GB (32,010,928,128 bytes)
|
|
22
|
-
Removable Media: Yes
|
|
23
|
-
BSD Name: disk4
|
|
24
|
-
Logical Unit: 0
|
|
25
|
-
Partition Map Type: MBR (Master Boot Record)
|
|
26
|
-
USB Interface: 0
|
|
27
|
-
Volumes:
|
|
28
|
-
EXAMPLE:
|
|
29
|
-
Capacity: 32 GB (32,006,733,824 bytes)
|
|
30
|
-
Free: 31.99 GB (31,990,808,576 bytes)
|
|
31
|
-
Writable: Yes
|
|
32
|
-
File System: MS-DOS FAT32
|
|
33
|
-
BSD Name: disk4s1
|
|
34
|
-
Mount Point: /Volumes/EXAMPLE
|
|
35
|
-
Content: Windows_FAT_32
|
|
36
|
-
|
|
37
|
-
Flash Drive:
|
|
38
|
-
|
|
39
|
-
Product ID: 0x0002
|
|
40
|
-
Vendor ID: 0x0000
|
|
41
|
-
Version: 1.00
|
|
42
|
-
Serial Number: 0000000000000002
|
|
43
|
-
Speed: Up to 480 Mb/s
|
|
44
|
-
Manufacturer: Example
|
|
45
|
-
Location ID: 0x00200000 / 2
|
|
46
|
-
Media:
|
|
47
|
-
Flash Drive:
|
|
48
|
-
Capacity: 8 GB (8,004,304,896 bytes)
|
|
49
|
-
Removable Media: Yes
|
|
50
|
-
BSD Name: disk5
|
|
51
|
-
Volumes:
|
|
52
|
-
Example 2:
|
|
53
|
-
Capacity: 8 GB (8,000,110,592 bytes)
|
|
54
|
-
File System: ExFAT
|
|
55
|
-
BSD Name: disk5s1
|
|
56
|
-
Mount Point: /Volumes/Example 2
|
|
57
|
-
Content: Windows_NTFS
|
|
58
|
-
|