Class: BuildTool::Cfg::ServerDeclarationNodeVisitor

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

Instance Attribute Summary

Attributes inherited from MJ::VisitorBase

#configuration

Instance Method Summary collapse

Methods inherited from ListVisitor

#visit, #visit_nodes

Methods inherited from MJ::VisitorBase

#visit_Object

Constructor Details

#initialize(configuration) ⇒ ServerDeclarationNodeVisitor

Returns a new instance of ServerDeclarationNodeVisitor.



826
827
828
829
# File 'lib/build-tool/cfg/visitor.rb', line 826

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

Instance Method Details

#visit_ServerDeclarationNode(node) ⇒ Object



831
832
833
834
835
836
837
838
839
840
841
# File 'lib/build-tool/cfg/visitor.rb', line 831

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



843
844
845
# File 'lib/build-tool/cfg/visitor.rb', line 843

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

#visit_ServerPathNode(node) ⇒ Object



847
848
849
# File 'lib/build-tool/cfg/visitor.rb', line 847

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

#visit_ServerProtocolNode(node) ⇒ Object



851
852
853
# File 'lib/build-tool/cfg/visitor.rb', line 851

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

#visit_ServerStatementList(node) ⇒ Object



855
856
857
# File 'lib/build-tool/cfg/visitor.rb', line 855

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

#visit_SshKeyDeclarationNode(node) ⇒ Object



859
860
861
# File 'lib/build-tool/cfg/visitor.rb', line 859

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

#visit_UseSshKeyNode(node) ⇒ Object

Raises:



863
864
865
866
867
# File 'lib/build-tool/cfg/visitor.rb', line 863

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