Class: BuildTool::Cfg::ServerDeclarationNodeVisitor

Inherits:
ListVisitor show all
Defined in:
lib/build-tool/cfg/visitor.rb

Instance Attribute Summary

Attributes inherited from VisitorBase

#configuration

Instance Method Summary collapse

Methods inherited from ListVisitor

#visit, #visit_nodes

Constructor Details

#initialize(configuration) ⇒ ServerDeclarationNodeVisitor

Returns a new instance of ServerDeclarationNodeVisitor.



595
596
597
598
# File 'lib/build-tool/cfg/visitor.rb', line 595

def initialize( configuration )
    super( configuration )
    @server = nil
end

Instance Method Details

#visit_ServerDeclarationNode(node) ⇒ Object



600
601
602
603
604
605
606
607
608
609
610
# File 'lib/build-tool/cfg/visitor.rb', line 600

def visit_ServerDeclarationNode( node )
    name = node.values[0]
    # Check if a server with that name already exists
    @server = configuration.server(name)
    # Create a new one if not
    @server = Server.new( name ) if @server.nil?
    statements = node.values[1]
    self.visit_nodes(statements.values)
    configuration.add_server( @server )
    return @server
end

#visit_ServerHostNode(node) ⇒ Object



612
613
614
# File 'lib/build-tool/cfg/visitor.rb', line 612

def visit_ServerHostNode( node )
    @server.host = node.value
end

#visit_ServerPathNode(node) ⇒ Object



616
617
618
# File 'lib/build-tool/cfg/visitor.rb', line 616

def visit_ServerPathNode( node )
    @server.path = node.value
end

#visit_ServerProtocolNode(node) ⇒ Object



620
621
622
# File 'lib/build-tool/cfg/visitor.rb', line 620

def visit_ServerProtocolNode( node )
    @server.protocol = node.value
end

#visit_ServerStatementList(node) ⇒ Object



624
625
626
# File 'lib/build-tool/cfg/visitor.rb', line 624

def visit_ServerStatementList( node )
    self.visit( node )
end

#visit_SshKeyDeclarationNode(node) ⇒ Object



628
629
630
# File 'lib/build-tool/cfg/visitor.rb', line 628

def visit_SshKeyDeclarationNode( node )
    @server.sshkey = node.value
end

#visit_UseSshKeyNode(node) ⇒ Object

Raises:



632
633
634
635
636
# File 'lib/build-tool/cfg/visitor.rb', line 632

def visit_UseSshKeyNode( node )
    name = node.value
    @server.sshkey = configuration.sshkey(name)
    raise ConfigurationError, "Unknown ssh-key #{name} configured for server #{@server.name}!" if @server.sshkey.nil?
end