Class: Hackmac::Kext
- Inherits:
-
Object
show all
- Includes:
- Plist, Tins::StringVersion
- Defined in:
- lib/hackmac/kext.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Plist
#as_hash, #each, #method_missing, #plist, #to_json
Constructor Details
#initialize(path:, config: nil) ⇒ Kext
Returns a new instance of Kext.
10
11
12
13
14
15
|
# File 'lib/hackmac/kext.rb', line 10
def initialize(path:, config: nil)
@path = path
info = Pathname.new(@path) + 'Contents/Info.plist'
@plist = File.open(info, encoding: 'UTF-8') { |f| ::Plist.parse_xml(f) }
@config = config
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Hackmac::Plist
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
17
18
19
|
# File 'lib/hackmac/kext.rb', line 17
def path
@path
end
|
Instance Method Details
#identifier ⇒ Object
19
20
21
|
# File 'lib/hackmac/kext.rb', line 19
def identifier
CFBundleIdentifier()
end
|
#inspect ⇒ Object
65
66
67
|
# File 'lib/hackmac/kext.rb', line 65
def inspect
"#<#{self.class}: #{to_s}>"
end
|
#name ⇒ Object
23
24
25
|
# File 'lib/hackmac/kext.rb', line 23
def name
CFBundleName() || File.basename(identifier)
end
|
#remote_kext ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/hackmac/kext.rb', line 40
def remote_kext
return @remote_kext if @remote_kext
if @config
source = @config.kext.sources[name] or return
case
when github = source&.github?
auth = [ @config.github.user, @config.github.access_token ].compact
auth.empty? and auth = nil
suffix =
case debug = source.debug?
when true then 'DEBUG'
when false then 'RELEASE'
when nil then nil
end
@remote_kext = Hackmac::GithubSource.new(github, auth: auth, suffix: suffix)
when download = source&.download
@remote_kext = Hackmac::URLDownload.new(download.name, download.version, download.url)
end
end
end
|
#remote_version ⇒ Object
61
62
63
|
# File 'lib/hackmac/kext.rb', line 61
def remote_version
remote_kext&.version
end
|
#to_s ⇒ Object
69
70
71
|
# File 'lib/hackmac/kext.rb', line 69
def to_s
"#{name} #{version}"
end
|
#version ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/hackmac/kext.rb', line 27
def version
unless @version
if version = CFBundleShortVersionString()
begin
@version = Version.new(version)
rescue ArgumentError
@version = version
end
end
end
@version
end
|