Module: CbzTools::SystemDependencies
- Defined in:
- lib/cbz_tools/system_dependencies.rb
Defined Under Namespace
Classes: MissingExecutableError
Class Method Summary
collapse
Class Method Details
.find_executable(name) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/cbz_tools/system_dependencies.rb', line 7
def self.find_executable(name)
extensions = Gem.win_platform? ? ENV.fetch("PATHEXT", "").split(";") : [""]
ENV.fetch("PATH", "").split(File::PATH_SEPARATOR).each do |directory|
extensions.each do |extension|
path = File.join(directory, "#{name}#{extension}")
return path if File.file?(path) && File.executable?(path)
end
end
nil
end
|
.unrar! ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/cbz_tools/system_dependencies.rb', line 20
def self.unrar!
find_executable("unrar") ||
raise(
MissingExecutableError,
"`unrar` is required for CBR conversion but was not found in PATH. " \
"Install unrar using your system's package manager."
)
end
|