Class: RakeRack::DependencyChecker

Inherits:
Object
  • Object
show all
Includes:
Term::ANSIColor
Defined in:
lib/dependency_checker.rb

Instance Method Summary collapse

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

#missingObject



20
21
22
23
# File 'lib/dependency_checker.rb', line 20

def missing
  @results ||= check(true)
  @results.select{|_, present| present == false}.keys
end