Module: Forward::Common

Included in:
API::Resource, API::Resource, CLI, Forward::Command::Base, Request, Socket, Tunnel
Defined in:
lib/forward/common.rb

Constant Summary collapse

EMAIL_REGEX =
/\A[^@]+@[^@]+\.[^@]+\z/.freeze

Instance Method Summary collapse

Instance Method Details

#configObject



10
11
12
# File 'lib/forward/common.rb', line 10

def config
  Forward::Config
end

#exit_with_error(message = nil) ⇒ Object



36
37
38
39
40
41
# File 'lib/forward/common.rb', line 36

def exit_with_error(message = nil)
  if message
    puts HighLine.color(message, :red)
  end
  stop_reactor_and_exit(1)
end

#exit_with_message(message = nil) ⇒ Object



26
27
28
29
# File 'lib/forward/common.rb', line 26

def exit_with_message(message = nil)
  puts message if message
  stop_reactor_and_exit
end

#logged_in?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/forward/common.rb', line 14

def logged_in?
  !Config..nil?
end

#loggerObject Also known as: log



5
6
7
# File 'lib/forward/common.rb', line 5

def logger
  Forward.logger
end

#osObject



18
19
20
# File 'lib/forward/common.rb', line 18

def os
  Forward.os
end

#stop_reactor_and_exit(code = 0) ⇒ Object



31
32
33
34
# File 'lib/forward/common.rb', line 31

def stop_reactor_and_exit(code = 0)
  EM.stop if EM.reactor_running?
  exit(code)
end

#windows?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/forward/common.rb', line 22

def windows?
  Forward.windows?
end