On Tue, Mar 1, 2011 at 9:05 AM, Dan Bode <d...@puppetlabs.com> wrote:

> Hi Nick (long time :) )
>
> On Tue, Mar 1, 2011 at 3:14 AM, Nick Moffitt <n...@zork.net> wrote:
>
>> I mean to write a lint checker for my manifests, but I am not a ruby
>> developer to any degree of proficiency.  What I think I would like is
>> some kind of serialization of the AST for a given .pp file, which I can
>> then import into my own Python code and analyze for undesirable
>> patterns.
>>
>
> It is possible to parse a given file and get an ASTArray back, is that
> sufficient? I am pretty sure you are going to have to get your hands into
> the Ruby code to really figure this out.
>

As a hack, I've occasionally done something like:

diff --git a/lib/puppet/application/apply.rb
b/lib/puppet/application/apply.rb
index cc733e1..6ca8f25 100644
--- a/lib/puppet/application/apply.rb
+++ b/lib/puppet/application/apply.rb
@@ -65,7 +65,7 @@ class Puppet::Application::Apply < Puppet::Application
       Puppet[:manifest] = command_line.args.shift
     end
     begin
-
Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types
+      print
ZAML.dump(Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types)
     rescue => detail
       Puppet.err detail
       exit 1

which changes --parseonly to dump the AST forest to stdout instead of just
constructing it and throwing it out.  I also typically filter the output
with "grep -v" or some such to skip the stuff I don't care about.

Not sure if that's useful info, but I figured it might be.

-- Markus
-----------------------------------------------------------
When in trouble or in doubt, run in circles,
scream and shout. -- 1920's parody of the
maritime general prudential rule
------------------------------------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to