Module: UI

Defined in:
lib/uiux.rb

Overview

Renamed UIUX module to just UI for simplicity of calling it

Class Method Summary collapse

Class Method Details

.error(message) ⇒ Object

Rename to fail one in the gem



25
26
27
# File 'lib/uiux.rb', line 25

def self.error(message) # Rename to fail one in the gem
  fail "ERROR: #{message}".color(:red)
end

.execute(command) ⇒ Object



29
30
31
32
# File 'lib/uiux.rb', line 29

def self.execute(command)
  puts "#{'==>'.color(:blue)} #{command.bright}"
  system command
end

.execute_and_register(command) ⇒ Object



34
35
36
37
38
# File 'lib/uiux.rb', line 34

def self.execute_and_register(command)
  puts "#{'==>'.color(:blue)} #{command.bright}"
  puts result = `#{command}`
  result
end

.heading(message) ⇒ Object



17
18
19
# File 'lib/uiux.rb', line 17

def self.heading(message)
  puts "\n#{message}".color(:green)
end

.message(message) ⇒ Object



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

def self.message(message)
  puts "#{message}".color(:white)
end

.start(message, &block) ⇒ Object



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

def self.start(message, &block)
  @start_time = Time.now.utc
  start_heading(message)
  yield block
  finished
rescue Exception => error
  puts heading_with_columns("\nFailed after #{time_from_start}", '', time).color(:red)
  raise error
end

.time(time = Time.now.utc) ⇒ Object



40
41
42
# File 'lib/uiux.rb', line 40

def self.time(time = Time.now.utc)
  "🕑  #{time} 🕑 ".color(:white)
end