Class: BuildTool::Cfg::FeatureNodeVisitor

Inherits:
ConfigurationFileVisitor 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 ConfigurationFileVisitor

#visit_LogDirectoryNode

Methods inherited from StatementVisitor

#visit_BuildSystemDeclarationNode, #visit_ConfigurationFileList, #visit_DisableFeatureNode, #visit_DisableModuleNode, #visit_EnableFeatureNode, #visit_EnableModuleNode, #visit_EnvironmentDeclarationNode, #visit_GitOptionsDeclarationNode, #visit_IncludeNode, #visit_ModuleDeclarationNode, #visit_RepositoryDeclarationNode, #visit_ServerDeclarationNode, #visit_SshKeyDeclarationNode

Methods inherited from ListVisitor

#visit, #visit_nodes

Methods inherited from MJ::VisitorBase

#visit_Object

Constructor Details

#initialize(configuration) ⇒ FeatureNodeVisitor

Returns a new instance of FeatureNodeVisitor.



284
285
286
287
# File 'lib/build-tool/cfg/visitor.rb', line 284

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

Instance Method Details

#visit_FeatureNode(node) ⇒ Object

Raises:



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/build-tool/cfg/visitor.rb', line 289

def visit_FeatureNode( node )
    raise ArgumentsError if node.values.length != 2
    childs = node.values
    # Get the name if nested
    name = childs.shift
    if configuration.active_feature
       @feature = configuration.feature( "#{configuration.active_feature.path}/#{name}" )
    else
       @feature = configuration.feature( name )
    end
    # Create a new feature if needed
    if @feature.nil?
        @feature = configuration.create_feature( name, configuration.active_feature )
    end
    # Set it as the current feature
    old_feat = configuration.active_feature
    configuration.active_feature= @feature
    # Visit the childs
    visit_nodes( childs.shift )
    # Reset the old current feature
    configuration.active_feature = old_feat
end

#visit_LongDescriptionNode(node) ⇒ Object



312
313
314
315
316
317
# File 'lib/build-tool/cfg/visitor.rb', line 312

def visit_LongDescriptionNode( node )
    if @feature.long_description
        logger.warn "Overwriting long description for feature #{@feature.name}"
    end
    @feature.long_description = node.values
end

#visit_ShortDescriptionNode(node) ⇒ Object



319
320
321
322
323
324
# File 'lib/build-tool/cfg/visitor.rb', line 319

def visit_ShortDescriptionNode( node )
    if !@feature.description.nil?
        logger.warn "Overwriting short description for feature #{@feature.name}"
    end
    @feature.description = node.values
end