Class: Hackmac::Kext
- Inherits:
-
Object
show all
- Includes:
- Plist
- Defined in:
- lib/hackmac/kext.rb
Instance Method Summary
collapse
Methods included from Plist
#as_hash, #plist, #to_json
Constructor Details
#initialize(path:) ⇒ Kext
Returns a new instance of Kext.
8
9
10
11
|
# File 'lib/hackmac/kext.rb', line 8
def initialize(path:)
@path = Pathname.new(path) + 'Contents/Info.plist'
@plist = File.open(@path) { |f| ::Plist.parse_xml(f) }
end
|
Instance Method Details
#compare_to(others) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/hackmac/kext.rb', line 38
def compare_to(others)
matches = find_matches others
if other = matches[false]&.first
"#{to_s.red} ⚡#{other.to_s.red}"
elsif other = matches[true]&.first
"#{to_s.green} = #{other.to_s.green}"
else
"#{to_s.yellow}"
end
end
|
#find_matches(others) ⇒ Object
33
34
35
36
|
# File 'lib/hackmac/kext.rb', line 33
def find_matches(others)
candidates = others.select { |o| o.name == name }
candidates.group_by { |c| c.version == version }
end
|
#identifier ⇒ Object
13
14
15
|
# File 'lib/hackmac/kext.rb', line 13
def identifier
as_hash['CFBundleIdentifier']
end
|
#inspect ⇒ Object
25
26
27
|
# File 'lib/hackmac/kext.rb', line 25
def inspect
"#<#{self.class}: #{to_s}>"
end
|
#name ⇒ Object
17
18
19
|
# File 'lib/hackmac/kext.rb', line 17
def name
as_hash['CFBundleName'] || File.basename(identifier)
end
|
#to_s ⇒ Object
29
30
31
|
# File 'lib/hackmac/kext.rb', line 29
def to_s
"#{name} #{version}"
end
|
#version ⇒ Object
21
22
23
|
# File 'lib/hackmac/kext.rb', line 21
def version
as_hash['CFBundleShortVersionString']
end
|