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
-
#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.
Instance Method Summary collapse
- #bind_address ⇒ Object
- #hostname ⇒ Object
-
#initialize(args) ⇒ CanalOptions
constructor
A new instance of CanalOptions.
- #pem ⇒ Object
- #proxy ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
- #to_yaml ⇒ Object
- #user ⇒ Object
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
#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 |
Instance Method Details
#bind_address ⇒ Object
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 |
#hostname ⇒ Object
30 31 32 |
# File 'lib/canals/options.rb', line 30 def hostname get_env_var("hostname") end |
#pem ⇒ Object
38 39 40 |
# File 'lib/canals/options.rb', line 38 def pem get_env_var("pem") end |
#proxy ⇒ Object
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_hash ⇒ Object
53 54 55 |
# File 'lib/canals/options.rb', line 53 def to_hash @args.dup end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/canals/options.rb', line 20 def to_s return "CanalOptions<#{@args}>" end |
#to_yaml ⇒ Object
49 50 51 |
# File 'lib/canals/options.rb', line 49 def to_yaml Psych.dump(@args) end |
#user ⇒ Object
34 35 36 |
# File 'lib/canals/options.rb', line 34 def user get_env_var("user") end |