Method: Puppet::Parser::Scope#to_s
- Defined in:
- lib/puppet/parser/scope.rb
#to_s ⇒ Object Also known as: inspect
Used mainly for logging
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 |
# File 'lib/puppet/parser/scope.rb', line 886 def to_s # As this is used for logging, this should really not be done in this class at all... return "Scope(#{@resource})" unless @resource.nil? # For logging of function-scope - it is now showing the file and line. detail = Puppet::Pops::PuppetStack.top_of_stack return "Scope()" if detail.empty? # shorten the path if possible path = detail[0] env_path = nil env_path = environment.configuration.path_to_env unless environment.nil? || environment.configuration.nil? # check module paths first since they may be in the environment (i.e. they are longer) module_path = environment.full_modulepath.detect { |m_path| path.start_with?(m_path) } if module_path path = "<module>" + path[module_path.length..] elsif env_path && path && path.start_with?(env_path) path = "<env>" + path[env_path.length..] end # Make the output appear as "Scope(path, line)" "Scope(#{[path, detail[1]].join(', ')})" end |