Module: Qas::Utils

Defined in:
lib/qas/utils.rb

Overview

General Utilities.

Class Method Summary collapse

Class Method Details

.spin(project) ⇒ Object

Spin for me, dear.



7
8
9
10
11
12
13
14
15
16
# File 'lib/qas/utils.rb', line 7

def self.spin(project)
  require 'tty-spinner'

  spinner = TTY::Spinner.new("#{project} :spinner ", format: :dots_6)
  spinner.auto_spin

  yield

  spinner.success
end

.which?(executable) ⇒ Boolean

prints external executable location

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/qas/utils.rb', line 19

def self.which?(executable)
  require 'pathname'

  [].tap do |x|
    ENV['PATH'].split(File::PATH_SEPARATOR) do |directory|
      exec = Pathname.new(directory).join executable.to_s

      x << exec.to_path if exec.file?
    end
  end.uniq
end