Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
resource_attributes should show all of the relevant part of the AST #31
In the event of a resource which contains a notifies, for example, resource_attributes shows the following:
 pry(#FoodCritic::RuleDsl)> resource_attributes(cmd)
Ideally we'd be able to see what the "notifies" is being sent to, in this specific case shown in the <method_add_arg> tags in the AST.
I can indeed get the AST as expected from the rule, however the AST returned doesn't seem to work with resource_attribute or resource_attributes (which returns a blank hash).
This is the AST I'm getting: https://gist.github.com/2780473 based on running resource_attribute(cmd, 'notifies') on the AST. When I try and run resource_attribute or resource_attributes on this resulting AST, the return value is blank.
I have a sneaky suspicion that those methods may not be expected to work on this sub-AST, but it seems like they should, otherwise I just have a slightly smaller AST to write an xpath against :p
Yes, the resulting AST isn't supposed to be able to be used as input to resource_attributes. You are only getting more convenient access to that part of the tree.
It looks like you need another function to extract simple expressions from the hash?