From 2a1791d663193d523a1e5cef99fd9e65c51c613a Mon Sep 17 00:00:00 2001 From: "Adam A. Gregory" Date: Fri, 13 May 2011 13:41:56 -0700 Subject: [PATCH] Added a hook_CUSTOM command that prompts the user for a hook name. This allows for hooks that are not defined in core. --- drupal.ruble/bundle.rb | 7 ++++--- drupal.ruble/commands/hooks.rb | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drupal.ruble/bundle.rb b/drupal.ruble/bundle.rb index 3d74dce..b7d54ea 100755 --- a/drupal.ruble/bundle.rb +++ b/drupal.ruble/bundle.rb @@ -3,12 +3,13 @@ bundle 'Drupal 7' do |bundle| bundle.author = 'Jamie Holly/HollyIT' bundle.contact_email_rot_13 = 'jamie@hollyit.net' - bundle.description = <Drupal. -END + bundle.description = 'Development support for Drupal.' bundle.menu 'Drupal 7' do |main_menu| main_menu.menu 'Hooks' do |submenu| + submenu.menu 'Custom' do |custom| + custom.command 'hook_CUSTOM' + end submenu.menu 'aggregator' do |aggregator| aggregator.command 'hook_aggregator_fetch' aggregator.command 'hook_aggregator_fetch_info' diff --git a/drupal.ruble/commands/hooks.rb b/drupal.ruble/commands/hooks.rb index b86d150..1d82fd4 100755 --- a/drupal.ruble/commands/hooks.rb +++ b/drupal.ruble/commands/hooks.rb @@ -4903,4 +4903,24 @@ end end +command 'hook_CUSTOM' do |cmd| + require 'functions.rb' + cmd.trigger = 'hook_CUSTOM' + cmd.invoke do |context| + moduleName = find_module_name(ENV['TM_DIRECTORY']) + options = {} + options[:title] = "Hook Name" + options[:prompt] = "What is the hook name?" + hook = Ruble::UI.request_string(options) + func = moduleName + '_' + hook + " +/** +* Implements hook_#{hook}(). +*/ +function #{func}() { + ${1} +}" + end + end + end \ No newline at end of file