Module: Iev::Cli::Ui::Helper

Defined in:
lib/iev/cli/ui.rb

Class Method Summary collapse

Class Method Details

.clear_progressObject



44
45
46
# File 'lib/iev/cli/ui.rb', line 44

def clear_progress
  $IEV_PROGRESS ? "\r#{' ' * 40}\r" : ""
end

.cli_out(level, *args) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/iev/cli/ui.rb', line 48

def cli_out(level, *args)
  topic = args[0].is_a?(Symbol) ? args.shift : nil
  message = args.map(&:to_s).join(" ").chomp
  ui_tag = Thread.current[:iev_ui_tag]

  return unless should_out?(level, topic)

  print [
    clear_progress,
    ui_tag,
    ui_tag && ": ",
    message,
    "\n",
  ].join
end

.should_out?(level, topic) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/iev/cli/ui.rb', line 64

def should_out?(level, topic)
  topic.nil? || level == :warn || $IEV_DEBUG[topic]
end