Class: RakeRack::DependencyChecker
- Inherits:
-
Object
- Object
- RakeRack::DependencyChecker
- Includes:
- Term::ANSIColor
- Defined in:
- lib/dependency_checker.rb
Instance Method Summary collapse
- #check(silent = false) ⇒ Object
-
#initialize(dependencies) ⇒ DependencyChecker
constructor
A new instance of DependencyChecker.
- #missing ⇒ Object
Constructor Details
#initialize(dependencies) ⇒ DependencyChecker
Returns a new instance of DependencyChecker.
7 8 9 |
# File 'lib/dependency_checker.rb', line 7 def initialize dependencies @dependencies = Array(dependencies) end |
Instance Method Details
#check(silent = false) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/dependency_checker.rb', line 11 def check silent = false @results = @dependencies.each_with_object({}) do |dep, results| results[dep] = system "which #{dep} >/dev/null" unless silent results[dep] ? print(".".green) : print("F".red) end end end |
#missing ⇒ Object
20 21 22 23 |
# File 'lib/dependency_checker.rb', line 20 def missing @results ||= check(true) @results.select{|_, present| present == false}.keys end |