class Massa::Analyzier

Attributes

verbose[R]
verbose?[R]

Public Class Methods

new(verbose: false) click to toggle source
# File lib/massa/analyzer.rb, line 18
def initialize(verbose: false)
  @verbose = verbose
end
run!(options) click to toggle source
# File lib/massa/analyzer.rb, line 14
def self.run!(options)
  new(**options).run!
end

Public Instance Methods

execute(tool) click to toggle source
# File lib/massa/analyzer.rb, line 42
def execute(tool)
  command_output = ''

  if verbose?
    system(tool.command)
  else
    IO.popen(tool.command, err: %i[child out]) { |io| command_output = io.read }
  end

  return if $CHILD_STATUS.success?

  Massa::CLI.colorize :red, "¯\\_(ツ)_/¯ #{tool.description} failed:"
  Massa::CLI.colorize :yellow, "$ #{tool.command}"

  puts command_output if command_output.to_s != ''

  exit 1 if tool.required?
end
gem_installed?(tool) click to toggle source
# File lib/massa/analyzer.rb, line 34
def gem_installed?(tool)
  return true if `gem query -i #{tool.name}`.chomp == 'true'

  Massa::CLI.colorize :yellow, "༼ つ ◕_◕ ༽つ '#{tool.name}' gem is not installed"

  tool.required? ? exit(1) : false
end
run!() click to toggle source
# File lib/massa/analyzer.rb, line 22
def run!
  Massa::Tool.list.each do |tool|
    Massa::CLI.colorize :blue, "➙ #{tool.description}"

    next if tool.gem? && !gem_installed?(tool)

    execute(tool)
  end

  Massa::CLI.colorize :green, '~(‾▿‾)~ All good!'
end