Class: Canals::CanalOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/canals/options.rb

Constant Summary collapse

BIND_ADDRESS =
"127.0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CanalOptions

Returns a new instance of CanalOptions.



10
11
12
13
14
15
16
17
18
# File 'lib/canals/options.rb', line 10

def initialize(args)
  @args = validate?(args)
  @name = @args["name"]
  @remote_host = @args["remote_host"]
  @remote_port = @args["remote_port"]
  @local_port = @args["local_port"]
  @env_name = @args['env']
  @env = Canals.repository.environment(@env_name)
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



8
9
10
# File 'lib/canals/options.rb', line 8

def env
  @env
end

#env_nameObject (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_portObject (readonly)

Returns the value of attribute local_port.



8
9
10
# File 'lib/canals/options.rb', line 8

def local_port
  @local_port
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/canals/options.rb', line 8

def name
  @name
end

#remote_hostObject (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_portObject (readonly)

Returns the value of attribute remote_port.



8
9
10
# File 'lib/canals/options.rb', line 8

def remote_port
  @remote_port
end

Instance Method Details

#bind_addressObject



24
25
26
27
28
# File 'lib/canals/options.rb', line 24

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

#hostnameObject



30
31
32
# File 'lib/canals/options.rb', line 30

def hostname
  get_env_var("hostname")
end

#pemObject



38
39
40
# File 'lib/canals/options.rb', line 38

def pem
  get_env_var("pem")
end

#proxyObject



42
43
44
45
46
47
# File 'lib/canals/options.rb', line 42

def proxy
  prxy = ""
  prxy += "-i #{pem} " if pem
  prxy += "#{user}@#{hostname}"
  prxy
end

#to_hashObject



53
54
55
# File 'lib/canals/options.rb', line 53

def to_hash
  @args.dup
end

#to_sObject



20
21
22
# File 'lib/canals/options.rb', line 20

def to_s
  return "CanalOptions<#{@args}>"
end

#to_yamlObject



49
50
51
# File 'lib/canals/options.rb', line 49

def to_yaml
  Psych.dump(@args)
end

#userObject



34
35
36
# File 'lib/canals/options.rb', line 34

def user
  get_env_var("user")
end