plugin_development.md in retrospec-0.6.2 vs plugin_development.md in retrospec-0.7.0

- old
+ new

@@ -2,45 +2,51 @@ If you wish to automate the creation of a project or other project plugins you should create a retrospec plugin. Follow the steps below to create a plugin. ## Creating a plugin using the plugin generator -1. Install the retrospec plugin that creates retrospec plugins! `gem install retrospec-plugingen` + +1. Install the retrospec plugin that creates retrospec plugins! `gem install retrospec-plugingen` 2. Come up with a name for you plugin. 3. Use the retrospec plugin help `retrospec -m /path_to_project/plugin_name plugingen -h` 4. Create the plugin `retrospec -m /path_to_project/plugin_name plugingen` 5. Open the /path_to_project/plugin_name in your favorite editor 6. Hack --> Test --> Publish ## Choosing a plugin name -By default the plugin generator will use the name of the directory or the name specified via the -n option. This name -will be used throughout the generator templates so its important to pick a sensible name. The generator also uses the plugin_name -as a class name although you are free to change it after creation. +By default the plugin generator will use the name of the directory or the name specified via the -n option. This name +will be used throughout the generator templates so its important to pick a sensible name. The generator also uses the plugin_name +as a class name although you are free to change it after creation. + ### Naming the gem and repo + Please ensure the gem name uses the following naming scheme retrospec-plugin_name and that your repo is also named retrospec-plugin_name. -This will help everyone identify what the repo and gem do. +This will help everyone identify what the repo and gem do. Note: puppet-retrospec does not follow this standard due to a legacy name issue that would have caused confusion. ## What you need to override -* self.run_cli +- self.run_cli + ## Create a context object -By default the plugin generator will create a context object that can be used inside templates. The default context object + +By default the plugin generator will create a context object that can be used inside templates. The default context object does not contain anything useful so you will want to customize this object only if your templates require variable interpolation. ## Main method to override -Retrospec will call your plugin by running the plugin.run_cli class method. You can do whatever you want in this method. -The global_opts are the options passed into the retrospec command which are specific to retrospec. Additionally, the -global_config (~/.retrospec/config.yaml) is a hash map of the entire config while the plugin_config is a subset that pertains +Retrospec will call your plugin by running the plugin.run_cli class method. You can do whatever you want in this method. + +The global_opts are the options passed into the retrospec command which are specific to retrospec. Additionally, the +global_config (~/.retrospec/config.yaml) is a hash map of the entire config while the plugin_config is a subset that pertains only to your plugin. -In this method you should at least call self.new() on your plugin and then plugin_instance.run. +In this method you should at least call self.new() on your plugin and then plugin_instance.run. -For simplicity sake you can also just copy and paste this into your method. This is the default layout when using +For simplicity sake you can also just copy and paste this into your method. This is the default layout when using the retrospec plugin generator. ```ruby def self.run_cli(global_opts, global_config, plugin_config) # a list of subcommands for this plugin @@ -48,11 +54,11 @@ if sub_commands.count > 0 sub_command_help = "Subcommands:\n#{sub_commands.join("\n")}\n" else sub_command_help = "" end - plugin_opts = Trollop::options do + plugin_opts = optimist::options do version "#{Retrospec::Pluginname::VERSION} (c) Your Name" banner <<-EOS Some description goes here.\n #{sub_command_help} @@ -75,13 +81,12 @@ exit 1 end end ``` -See the [trollop documentation](http://trollop.rubyforge.org) for more info. +See the [optimist documentation](http://optimist.rubyforge.org) for more info. ## Module helpers + The module helpers module is included by default and contains useful methods to safely create files. When creating files use the safe create methods in order to protect the users content from being overwritten. For a list of methods please see the [source code](https://github.com/nwops/retrospec/blob/master/lib/retrospec/plugins/v1/module_helpers.rb) - -