Permalink
Browse files

Added a hook_CUSTOM command that prompts the user for a hook name. Th…

…is allows for hooks that are not defined in core.
  • Loading branch information...
1 parent c4aca56 commit 2a1791d663193d523a1e5cef99fd9e65c51c613a Adam A. Gregory committed May 13, 2011
Showing with 24 additions and 3 deletions.
  1. +4 −3 drupal.ruble/bundle.rb
  2. +20 −0 drupal.ruble/commands/hooks.rb
View
7 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 = <<END
-Development support for <a href="http://drupal.org/">Drupal</a>.
-END
+ bundle.description = 'Development support for <a href="http://drupal.org/">Drupal</a>.'
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'
View
20 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

0 comments on commit 2a1791d

Please sign in to comment.