summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/ast/astarray.rb4
-rw-r--r--lib/puppet/parser/ast/function.rb5
-rw-r--r--lib/puppet/parser/ast/leaf.rb14
-rw-r--r--lib/puppet/parser/ast/resource_reference.rb8
4 files changed, 30 insertions, 1 deletions
diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb
index 9b59d196a..dfd2bcd09 100644
--- a/lib/puppet/parser/ast/astarray.rb
+++ b/lib/puppet/parser/ast/astarray.rb
@@ -47,6 +47,10 @@ class Puppet::Parser::AST
return self
end
+
+ def to_s
+ "[" + @children.collect { |c| c.to_s }.join(', ') + "]"
+ end
end
# A simple container class, containing the parameters for an object.
diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb
index 2f768ebdb..4c3a5dc05 100644
--- a/lib/puppet/parser/ast/function.rb
+++ b/lib/puppet/parser/ast/function.rb
@@ -51,5 +51,10 @@ class Puppet::Parser::AST
@fname = Puppet::Parser::Functions.function(@name)
# Lastly, check the parity
end
+
+ def to_s
+ args = arguments.is_a?(ASTArray) ? arguments.to_s.gsub(/\[(.*)\]/,'\1') : arguments
+ "#{name}(#{args})"
+ end
end
end
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index dba9812a7..d08938011 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -11,7 +11,7 @@ class Puppet::Parser::AST
end
def to_s
- return @value
+ return @value.to_s unless @value.nil?
end
end
@@ -29,6 +29,10 @@ class Puppet::Parser::AST
end
@value
end
+
+ def to_s
+ @value ? "true" : "false"
+ end
end
# The base string class.
@@ -38,6 +42,10 @@ class Puppet::Parser::AST
def evaluate(scope)
return scope.strinterp(@value, file, line)
end
+
+ def to_s
+ "\"#{@value}\""
+ end
end
# An uninterpreted string.
@@ -45,6 +53,10 @@ class Puppet::Parser::AST
def evaluate(scope)
return @value
end
+
+ def to_s
+ "\"#{@value}\""
+ end
end
# The 'default' option on case statements and selectors.
diff --git a/lib/puppet/parser/ast/resource_reference.rb b/lib/puppet/parser/ast/resource_reference.rb
index 6189ab8de..117bc88af 100644
--- a/lib/puppet/parser/ast/resource_reference.rb
+++ b/lib/puppet/parser/ast/resource_reference.rb
@@ -64,5 +64,13 @@ class Puppet::Parser::AST
end
return objtype
end
+
+ def to_s
+ if title.is_a?(ASTArray)
+ "#{type.to_s.capitalize}#{title}"
+ else
+ "#{type.to_s.capitalize}[#{title}]"
+ end
+ end
end
end