Module: Pdfh::Utils::DependencyValidator
- Defined in:
- lib/pdfh/utils/dependency_validator.rb
Overview
Provides methods to validate external dependencies
Class Method Summary collapse
-
.installed?(*apps) ⇒ Boolean
Validates if the required command-line applications are installed.
-
.missing?(*apps) ⇒ Boolean
True if any application is missing, false if all are installed.
Class Method Details
.installed?(*apps) ⇒ Boolean
Validates if the required command-line applications are installed
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pdfh/utils/dependency_validator.rb', line 14 def installed?(*apps) missing = apps.filter_map do |app| _stdout, _stderr, status = Open3.capture3("which #{app}") app.to_s unless status.success? end if missing.any? errors = missing.map(&:red) puts "Required dependency #{errors.join(", ")} not found. Please install it before continuing." end missing.empty? end |
.missing?(*apps) ⇒ Boolean
Returns true if any application is missing, false if all are installed.
30 31 32 |
# File 'lib/pdfh/utils/dependency_validator.rb', line 30 def missing?(*apps) !installed?(*apps) end |