summaryrefslogtreecommitdiffstats
path: root/lib/puppet/interface/action_builder.rb
Commit message (Collapse)AuthorAgeFilesLines
* (#7291) Fix issues with instance_methods in Ruby 1.9Matt Robinson2011-05-161-2/+2
| | | | | | | | | | | | | | | | | | | | | instance_methods in Ruby 1.8.7 returns an array of strings, but returns an array of symbols in 1.9.2. This manifested itself when running the tests because in 1.9.2 we were trying to call sub on a sybmol. The original proposed solution was to monkey patch symbols to have a sub method, but this didn't deal with the real issue of need to check whether a method was defined, and actually made it worse. Turns out that checking for the presence of a method in an array that may contain symbols and may contain strings is better done by just calling method_defined? instead. This patch addresses all the places ack turned up the code doing this include? check instead of directly calling method_defined?. Thanks to Alex Sharp ajsharp@gmail.com for pointing out the Ruby 1.9 problems and working toward a solution. Reviewed-by: Nick Lewis <nick@puppetlabs.com>
* (#7353) Remove :for_humans format entirely.Daniel Pittman2011-05-051-3/+1
| | | | | | | Since we never shipped this in a real release, we don't need to maintain compatibility. So, remove it entirely from the codebase. Reviewed-By: Max Martin <max@puppetlabs.com>
* (#7353) Note the :for_humans compatibility issue.Daniel Pittman2011-05-041-0/+2
| | | | | | | | Where we need special support for :for_humans as an alias for :console, call it out in comments. This makes it clear to someone who wonders why what the actual underlying purpose of the whole thing is. Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
* (#7282) action without `when_invoked` should fail...Daniel Pittman2011-05-021-0/+1
| | | | | | | | | | | | | | We used to let actions be declared without the `when_invoked` block, which was usually a sign of either someone writing their method code direct in action declaration, or someone forgetting to add their code at all. This was just let silently by: the error only showed up when you finally tried to invoke the action, and a NoMethod error was raised by the face. ...except for our own testing. We took advantage of this a whole pile of times in there; fixing the original UI issue means fixing all those too. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
* (#7249) Publicize ActionBuilder DSL methods.Pieter van de Bruggen2011-04-261-14/+14
| | | | | | | | This change permits users to call functions with a reference to `self` that can augment the in-progress action declaration, which can be helpful in some more involved cases. Reviewed-By: Max Martin Reviewed-By: Daniel Pittman
* (#7013) Support 'when_rendering' and 'render_as' in actions.Daniel Pittman2011-04-191-5/+39
| | | | | | | | | | | These define the API used by folks writing actions that supports their rendering hooks. 'when_rendering' defines a helper method on the interface, which runs the users code in their expected context. 'render_as' just sets the default rendering format; by default this is :for_humans. Reviewed-By: Max Martin <max@puppetlabs.com>
* (#7115) Enable default actions.Pieter van de Bruggen2011-04-151-0/+4
| | | | | | | This also enables the 'help' action on the 'help' face to serve as a default action. Reviewed-By: Daniel Pittman Reviewed-By: Nick Lewis
* (#6962) Implement 'summary' for actions.Daniel Pittman2011-04-121-0/+4
| | | | | | | This extends the summary function down through the actions themselves, allowing us to display a useful summary to the user. Reviewed-By: Matt Robinson <matt@puppetlabs.com>
* (#7012) Split plumbing into Puppet::InterfaceDaniel Pittman2011-04-071-0/+31
| | | | | | | | | This splits out the plumbing into the Puppet::Interface namespace, and uses Puppet::Faces for all the public-facing code. The fault line is "what you care about if you are using or writing a face", which is public, against "what you care about to enable either of those two", which is the plumbing.
* MAINT: the API is officially named "string" as of this moment.Daniel Pittman2011-03-281-27/+0
| | | | | | | Now that we have settled on the final public name for the API, "Puppet::String", mass-rename and mass-edit all the files to follow. Reviewed-By: Randall Hansen <randall@puppetlabs.com>
* (#6833) support 'script' as a short form of 'action'Daniel Pittman2011-03-241-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment the action method is a fairly heavy tool: it provides a DSL, and is designed to allow substantial metadata to be added to the action. For some users this is low on value, since they just want to write a little script that drives things a bit differently. Which there is substantial value in the metadata, adding the capability to do these light-weight things quickly is valid. To meet this we add a script action; the contrast is: action :foo do # other metadata goes here invoke do |args| # method body goes here end end script :bar do |args| # method body goes here end # ...and if you want metadata, you have to add it in more ugly, procedural # ways, which we are not going to encourage. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
* (#6814) Add missing require for specsNick Lewis2011-03-221-0/+1
|
* (#6814) Create a dedicated Action classNick Lewis2011-03-221-0/+29
This class will represents an action, and allows us to store metadata for an action, and programmatically introspect and invoke them. A helper class ActionBuilder represents the DSL for defining an action. Also defined an "invoke" DSL method to handle the functionality of defining the method for an action. Reviewed-By: Daniel Pittman