Class: Canals::CanalOptions
- Inherits:
-
Object
- Object
- Canals::CanalOptions
- Defined in:
- lib/canals/options.rb
Constant Summary collapse
- BIND_ADDRESS =
"127.0.0.1"
Instance Attribute Summary collapse
-
#adhoc ⇒ Object
readonly
Returns the value of attribute adhoc.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#env_name ⇒ Object
readonly
Returns the value of attribute env_name.
-
#local_port ⇒ Object
readonly
Returns the value of attribute local_port.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#remote_host ⇒ Object
readonly
Returns the value of attribute remote_host.
-
#remote_port ⇒ Object
readonly
Returns the value of attribute remote_port.
-
#socks ⇒ Object
readonly
Returns the value of attribute socks.
Instance Method Summary collapse
- #bind_address ⇒ Object
- #exploded_options ⇒ Object
- #hostname ⇒ Object
-
#initialize(args) ⇒ CanalOptions
constructor
A new instance of CanalOptions.
- #pem ⇒ Object
- #proxy ⇒ Object
- #to_hash(mode = :basic) ⇒ Object
- #to_s ⇒ Object
- #to_yaml ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(args) ⇒ CanalOptions
Returns a new instance of CanalOptions.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/canals/options.rb', line 18 def initialize(args) @original_args = validate?(args) @args = Marshal.load(Marshal.dump(@original_args)) @name = @args[:name] @remote_host = @args[:remote_host] @remote_port = @args[:remote_port] @local_port = @args[:local_port] @adhoc = @args[:adhoc] || false @socks = @args[:socks] || false @env_name = @args[:env] @env = Canals.repository.environment(@env_name) end |
Instance Attribute Details
#adhoc ⇒ Object (readonly)
Returns the value of attribute adhoc.
8 9 10 |
# File 'lib/canals/options.rb', line 8 def adhoc @adhoc end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
8 9 10 |
# File 'lib/canals/options.rb', line 8 def env @env end |
#env_name ⇒ Object (readonly)
Returns the value of attribute env_name.
8 9 10 |
# File 'lib/canals/options.rb', line 8 def env_name @env_name end |
#local_port ⇒ Object (readonly)
Returns the value of attribute local_port.
8 9 10 |
# File 'lib/canals/options.rb', line 8 def local_port @local_port end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/canals/options.rb', line 8 def name @name end |
#remote_host ⇒ Object (readonly)
Returns the value of attribute remote_host.
8 9 10 |
# File 'lib/canals/options.rb', line 8 def remote_host @remote_host end |
#remote_port ⇒ Object (readonly)
Returns the value of attribute remote_port.
8 9 10 |
# File 'lib/canals/options.rb', line 8 def remote_port @remote_port end |
#socks ⇒ Object (readonly)
Returns the value of attribute socks.
8 9 10 |
# File 'lib/canals/options.rb', line 8 def socks @socks end |
Instance Method Details
#bind_address ⇒ Object
35 36 37 38 39 |
# File 'lib/canals/options.rb', line 35 def bind_address return @args[:bind_address] if @args[:bind_address] return Canals.config[:bind_address] if Canals.config[:bind_address] return BIND_ADDRESS end |
#exploded_options ⇒ Object
70 71 72 |
# File 'lib/canals/options.rb', line 70 def {bind_address: bind_address, hostname: hostname, user: user, pem: pem, proxy: proxy, adhoc: adhoc, socks: socks} end |
#hostname ⇒ Object
41 42 43 |
# File 'lib/canals/options.rb', line 41 def hostname get_env_var(:hostname) end |
#pem ⇒ Object
49 50 51 |
# File 'lib/canals/options.rb', line 49 def pem get_env_var(:pem) end |
#proxy ⇒ Object
53 54 55 56 57 58 |
# File 'lib/canals/options.rb', line 53 def proxy prxy = "" prxy += "-i #{pem} " if pem prxy += "#{user}@#{hostname}" prxy end |
#to_hash(mode = :basic) ⇒ Object
64 65 66 67 68 |
# File 'lib/canals/options.rb', line 64 def to_hash(mode=:basic) args_copy = Marshal.load(Marshal.dump(@args)) args_copy.merge! if mode == :full args_copy end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/canals/options.rb', line 31 def to_s return "CanalOptions<#{@args}>" end |
#to_yaml ⇒ Object
60 61 62 |
# File 'lib/canals/options.rb', line 60 def to_yaml Canals::Tools::YAML.to_yaml(@args) end |
#user ⇒ Object
45 46 47 |
# File 'lib/canals/options.rb', line 45 def user get_env_var(:user) end |