Module: Forward

Defined in:
lib/forward.rb,
lib/forward/api.rb,
lib/forward/cli.rb,
lib/forward/common.rb,
lib/forward/config.rb,
lib/forward/socket.rb,
lib/forward/tunnel.rb,
lib/forward/request.rb,
lib/forward/version.rb,
lib/forward/api/user.rb,
lib/forward/api/tunnel.rb,
lib/forward/static/app.rb,
lib/forward/api/resource.rb,
lib/forward/command/base.rb,
lib/forward/command/config.rb,
lib/forward/command/tunnel.rb,
lib/forward/command/account.rb

Defined Under Namespace

Modules: API, Command, Common, Config, Static Classes: CLI, CLIError, ClientError, ConfigError, Error, Request, Socket, Tunnel, TunnelError

Constant Summary collapse

SUPPORT_EMAIL =
'[email protected]'.freeze
VERSION =
'1.1.7'

Class Method Summary collapse

Class Method Details

.client_stringObject

Returns a string representing a detailed client version

Returns a String representing the client



118
119
120
121
122
123
124
# File 'lib/forward.rb', line 118

def self.client_string
  os     = RbConfig::CONFIG['host_os']
  engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'

  # TODO: make os version more friendly
  "(#{engine}-#{RUBY_VERSION})(#{os})(v#{Forward::VERSION})"
end

.debug!Object

Helper method for setting the log level to debug



89
90
91
# File 'lib/forward.rb', line 89

def self.debug!
  logger.level = Logger::DEBUG
end

.loggerObject

Getter for the logger

Returns the new or cached Logger instance



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/forward.rb', line 103

def self.logger
  @logger ||= begin
    _logger           = Logger.new(STDOUT)
    _logger.level     = Logger::WARN
    _logger.formatter = proc do |severity, datetime, progname, msg|
      "#{severity} - [#{datetime.strftime('%H:%M:%S')}] #{msg}\n"
    end

    _logger
  end
end

.logger=(logger) ⇒ Object

Setter for the logger

Returns the new Logger instance



96
97
98
# File 'lib/forward.rb', line 96

def self.logger=(logger)
  @logger ||= logger
end

.osObject

Helper for determining the host OS

Returns simplified and symbolized host os name



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/forward.rb', line 42

def self.os
  @os ||= begin
    case RbConfig::CONFIG['host_os']
    when /mswin|mingw|cygwin/
      :windows
    when /darwin/
      :osx
    when /linux|bsd/
      :unix
    else
      :unknown
    end
  end
end

.quiet!Object

Helper method for making forward quiet (silence most output)



79
80
81
# File 'lib/forward.rb', line 79

def self.quiet!
  @quiet = true
end

.quiet?Boolean

Helper method for making forward quiet (silence most output)

Returns:

  • (Boolean)


84
85
86
# File 'lib/forward.rb', line 84

def self.quiet?
  @quiet == true
end

.tunnelObject

Getter for the current Client

Returns a Forward::Client instance



74
75
76
# File 'lib/forward.rb', line 74

def self.tunnel
  @tunnel
end

.tunnel=(tunnel) ⇒ Object

Setter for the current Client

Returns the new Forawrd::Client instance



67
68
69
# File 'lib/forward.rb', line 67

def self.tunnel=(tunnel)
  @tunnel = tunnel
end

.windows?Boolean

Helper to determine if host OS is windows

Returns Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/forward.rb', line 60

def self.windows?
  @windows ||= os == :windows
end