Class: ReverseTunnel::CLI::Configurator

Inherits:
Base
  • Object
show all
Defined in:
lib/reverse-tunnel/cli.rb

Direct Known Subclasses

Client, Server

Instance Attribute Summary

Attributes inherited from Base

#arguments

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#configure, #initialize, #options

Constructor Details

This class inherits a constructor from ReverseTunnel::CLI::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



68
69
70
# File 'lib/reverse-tunnel/cli.rb', line 68

def method_missing(name, *args)
  instance.send name, *args
end

Class Method Details

.configure(arguments) ⇒ Object



87
88
89
# File 'lib/reverse-tunnel/cli.rb', line 87

def self.configure(arguments)
  new(arguments).configure
end

Instance Method Details

#instanceObject



64
65
66
# File 'lib/reverse-tunnel/cli.rb', line 64

def instance
  @instance ||= ReverseTunnel.const_get(self.class.name.split("::").last).new
end

#parse_host_port(string) ⇒ Object



72
73
74
75
# File 'lib/reverse-tunnel/cli.rb', line 72

def parse_host_port(string)
  host, port = string.split(':')
  [ host, port.to_i ]
end

#parse_host_port_range(string) ⇒ Object



77
78
79
80
81
# File 'lib/reverse-tunnel/cli.rb', line 77

def parse_host_port_range(string)
  if string =~ /(.*):(\d+)-(\d+)$/
    [ $1, ($2.to_i)..($3.to_i) ]
  end
end

#server=(server) ⇒ Object



83
84
85
# File 'lib/reverse-tunnel/cli.rb', line 83

def server=(server)
  self.server_host, self.server_port = parse_host_port(server)
end