Class: Circus::ConnectionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/circus/connection_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ConnectionBuilder

Returns a new instance of ConnectionBuilder.



6
7
8
9
# File 'lib/circus/connection_builder.rb', line 6

def initialize(options)
  @options = options
  @local_config = LocalConfig.new
end

Instance Method Details

#build(target) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/circus/connection_builder.rb', line 11

def build(target)
  if not target.include? ':'
    if @local_config.aliases.include? target
      build(@local_config.aliases[target])
    else
      raise ArgumentError.new("Invalid target #{target} - looks like an alias, but none configured to match")
    end
  elsif target.start_with? 'local:'
    # Local connection
    client = Agents::DBusConnection.new
    # client.configure_bg!
    client
  elsif target.start_with? 'ssh://'
    # SSH connection
    client = Agents::SSHConnection.new(target)
    client
  elsif
    raise ArgumentError.new("Ivalid target #{target} - unknown protocol")
  end
end