Class: BuildTool::Cfg::EnvironmentDeclarationNodeVisitor
Instance Attribute Summary
Attributes inherited from VisitorBase
#configuration
Instance Method Summary
collapse
Methods inherited from ListVisitor
#visit, #visit_nodes
Methods inherited from VisitorBase
#initialize, #visit_Object
Instance Method Details
#visit_EnvironmentDeclarationNode(node) ⇒ Object
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
# File 'lib/build-tool/cfg/visitor.rb', line 230
def visit_EnvironmentDeclarationNode( node )
name = node.values[0]
@environment = configuration.environment( name )
if @environment.nil?
@environment = BuildTool::Environment.new( name )
configuration.add_environment( @environment )
if !configuration.active_feature.nil?
@environment.feature = configuration.active_feature
configuration.active_feature.environments << @environment
end
end
if node.values[1] == :INHERITANCE
parentName = node.values[2]
@environment.parent = configuration.environment(parentName)
if @environment.parent.nil?
raise ConfigurationError, "Environment #{name} inherits from unknown environment #{parentName}!"
end
self.visit_nodes( node.values[3] )
else
self.visit_nodes( node.values[1] )
end
return @environment
end
|
#visit_EnvironmentVariableNode(node) ⇒ Object
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
# File 'lib/build-tool/cfg/visitor.rb', line 255
def visit_EnvironmentVariableNode( node )
case node.values.length
when 3
case node.values[1]
when 'append'; @environment.append( node.values[0], node.values[2] )
when 'prepend'; @environment.prepend( node.values[0], node.values[2] )
when 'set'; @environment.set( node.values[0], node.values[2] )
else raise StandardError, "Unexpected token #{node.values[1]}!"
end
when 2
@environment.set( node.values[0], node.values[1] )
else
raise StandardError, "Unexpected number of tokens #{node.values.length} #{node.values.join(', ')}"
end
end
|