Skip to content
Browse files

Added hook selection to the module and install templates.

  • Loading branch information...
1 parent 9de0146 commit 36bfd00c1d0cc308385578774eb5e5828fddbc9e Adam A. Gregory committed Jul 27, 2011
View
348 drupal.ruble/lib/functions.rb
@@ -20,7 +20,347 @@ def find_module_name(dir)
return '${1:hook}'
end
-
-
-
-
+def hooks_list()
+ hooks = [
+ 'action_info',
+ 'action_info_alter',
+ 'actions_delete',
+ 'admin_paths',
+ 'admin_paths_alter',
+ 'aggregator_fetch',
+ 'aggregator_fetch_info',
+ 'aggregator_parse',
+ 'aggregator_parse_info',
+ 'aggregator_process',
+ 'aggregator_process_info',
+ 'aggregator_remove',
+ 'ajax_render_alter',
+ 'archiver_info',
+ 'archiver_info_alter',
+ 'batch_alter',
+ 'block_configure',
+ 'block_info',
+ 'block_info_alter',
+ 'block_list_alter',
+ 'block_save',
+ 'block_view',
+ 'block_view_alter',
+ 'boot',
+ 'comment_delete',
+ 'comment_insert',
+ 'comment_load',
+ 'comment_presave',
+ 'comment_publish',
+ 'comment_unpublish',
+ 'comment_update',
+ 'comment_view',
+ 'comment_view_alter',
+ 'contextual_links_view_alter',
+ 'countries_alter',
+ 'cron',
+ 'cron_queue_info',
+ 'cron_queue_info_alter',
+ 'css_alter',
+ 'custom_theme',
+ 'dashboard_regions',
+ 'dashboard_regions_alter',
+ 'date_format_types',
+ 'date_format_types_alter',
+ 'date_formats',
+ 'date_formats_alter',
+ 'delete',
+ 'disable',
+ 'drupal_goto_alter',
+ 'element_info',
+ 'element_info_alter',
+ 'enable',
+ 'entity_delete',
+ 'entity_info',
+ 'entity_info_alter',
+ 'entity_insert',
+ 'entity_load',
+ 'entity_prepare_view',
+ 'entity_presave',
+ 'entity_query_alter',
+ 'entity_update',
+ 'entity_view',
+ 'entity_view_alter',
+ 'exit',
+ 'field_access',
+ 'field_attach_create_bundle',
+ 'field_attach_delete',
+ 'field_attach_delete_bundle',
+ 'field_attach_delete_revision',
+ 'field_attach_form',
+ 'field_attach_insert',
+ 'field_attach_load',
+ 'field_attach_prepare_translation_alter',
+ 'field_attach_preprocess_alter',
+ 'field_attach_presave',
+ 'field_attach_purge',
+ 'field_attach_rename_bundle',
+ 'field_attach_submit',
+ 'field_attach_update',
+ 'field_attach_validate',
+ 'field_attach_view_alter',
+ 'field_available_languages_alter',
+ 'field_create_field',
+ 'field_create_instance',
+ 'field_delete',
+ 'field_delete_field',
+ 'field_delete_instance',
+ 'field_delete_revision',
+ 'field_display_alter',
+ 'field_extra_fields',
+ 'field_extra_fields_alter',
+ 'field_extra_fields_display_alter',
+ 'field_formatter_info',
+ 'field_formatter_info_alter',
+ 'field_formatter_prepare_view',
+ 'field_formatter_settings_form',
+ 'field_formatter_settings_summary',
+ 'field_formatter_view',
+ 'field_info',
+ 'field_info_alter',
+ 'field_info_max_weight',
+ 'field_insert',
+ 'field_instance_settings_form',
+ 'field_is_empty',
+ 'field_language_alter',
+ 'field_load',
+ 'field_prepare_translation',
+ 'field_prepare_view',
+ 'field_presave',
+ 'field_purge_field',
+ 'field_purge_field_instance',
+ 'field_read_field',
+ 'field_read_instance',
+ 'field_schema',
+ 'field_settings_form',
+ 'field_storage_create_field',
+ 'field_storage_delete',
+ 'field_storage_delete_field',
+ 'field_storage_delete_instance',
+ 'field_storage_delete_revision',
+ 'field_storage_details',
+ 'field_storage_details_alter',
+ 'field_storage_info',
+ 'field_storage_info_alter',
+ 'field_storage_load',
+ 'field_storage_pre_insert',
+ 'field_storage_pre_load',
+ 'field_storage_pre_update',
+ 'field_storage_purge',
+ 'field_storage_purge_field',
+ 'field_storage_purge_field_instance',
+ 'field_storage_query',
+ 'field_storage_update_field',
+ 'field_storage_write',
+ 'field_update',
+ 'field_update_field',
+ 'field_update_forbid',
+ 'field_update_instance',
+ 'field_validate',
+ 'field_widget_error',
+ 'field_widget_form',
+ 'field_widget_info',
+ 'field_widget_info_alter',
+ 'field_widget_properties_alter',
+ 'field_widget_settings_form',
+ 'file_copy',
+ 'file_delete',
+ 'file_download',
+ 'file_download_access',
+ 'file_download_access_alter',
+ 'file_insert',
+ 'file_load',
+ 'file_mimetype_mapping_alter',
+ 'file_move',
+ 'file_presave',
+ 'file_update',
+ 'file_url_alter',
+ 'file_validate',
+ 'filetransfer_info',
+ 'filetransfer_info_alter',
+ 'filter_format_disable',
+ 'filter_format_insert',
+ 'filter_format_update',
+ 'filter_info',
+ 'filter_info_alter',
+ 'flush_caches',
+ 'form',
+ 'form_alter',
+ 'forms',
+ 'help',
+ 'html_head_alter',
+ 'image_default_styles',
+ 'image_effect_info',
+ 'image_effect_info_alter',
+ 'image_style_delete',
+ 'image_style_flush',
+ 'image_style_save',
+ 'image_styles_alter',
+ 'image_toolkits',
+ 'info',
+ 'info_alter',
+ 'init',
+ 'insert',
+ 'install',
+ 'install_tasks',
+ 'install_tasks_alter',
+ 'js_alter',
+ 'language_fallback_candidates_alter',
+ 'language_init',
+ 'language_negotiation_info',
+ 'language_negotiation_info_alter',
+ 'language_switch_links_alter',
+ 'language_types_info',
+ 'language_types_info_alter',
+ 'library',
+ 'library_alter',
+ 'load',
+ 'locale',
+ 'mail',
+ 'mail_alter',
+ 'menu',
+ 'menu_alter',
+ 'menu_breadcrumb_alter',
+ 'menu_contextual_links_alter',
+ 'menu_delete',
+ 'menu_get_item_alter',
+ 'menu_insert',
+ 'menu_link_alter',
+ 'menu_link_delete',
+ 'menu_link_insert',
+ 'menu_link_update',
+ 'menu_local_tasks_alter',
+ 'menu_site_status_alter',
+ 'menu_update',
+ 'module_implements_alter',
+ 'modules_disabled',
+ 'modules_enabled',
+ 'modules_installed',
+ 'modules_uninstalled',
+ 'multilingual_settings_changed',
+ 'node_access',
+ 'node_access_records',
+ 'node_access_records_alter',
+ 'node_delete',
+ 'node_grants',
+ 'node_grants_alter',
+ 'node_info',
+ 'node_insert',
+ 'node_load',
+ 'node_operations',
+ 'node_prepare',
+ 'node_presave',
+ 'node_revision_delete',
+ 'node_search_result',
+ 'node_submit',
+ 'node_type_delete',
+ 'node_type_insert',
+ 'node_type_update',
+ 'node_update',
+ 'node_update_index',
+ 'node_validate',
+ 'node_view',
+ 'node_view_alter',
+ 'openid',
+ 'openid_discovery_method_info',
+ 'openid_discovery_method_info_alter',
+ 'openid_normalization_method_info',
+ 'openid_normalization_method_info_alter',
+ 'openid_response',
+ 'overlay_child_initialize',
+ 'overlay_parent_initialize',
+ 'page_alter',
+ 'page_build',
+ 'page_delivery_callback_alter',
+ 'path_delete',
+ 'path_insert',
+ 'path_update',
+ 'permission',
+ 'prepare',
+ 'query_alter',
+ 'ranking',
+ 'rdf_mapping',
+ 'rdf_namespaces',
+ 'registry_files_alter',
+ 'requirements',
+ 'sample_search_conditions_callback',
+ 'schema',
+ 'schema_alter',
+ 'search_access',
+ 'search_admin',
+ 'search_execute',
+ 'search_info',
+ 'search_page',
+ 'search_preprocess',
+ 'search_reset',
+ 'search_status',
+ 'shortcut_default_set',
+ 'simpletest_alter',
+ 'stream_wrappers',
+ 'stream_wrappers_alter',
+ 'system_info_alter',
+ 'system_themes_page_alter',
+ 'taxonomy_term_delete',
+ 'taxonomy_term_insert',
+ 'taxonomy_term_load',
+ 'taxonomy_term_presave',
+ 'taxonomy_term_update',
+ 'taxonomy_term_view_alter',
+ 'taxonomy_vocabulary_delete',
+ 'taxonomy_vocabulary_insert',
+ 'taxonomy_vocabulary_load',
+ 'taxonomy_vocabulary_presave',
+ 'taxonomy_vocabulary_update',
+ 'test_finished',
+ 'test_group_finished',
+ 'test_group_started',
+ 'theme',
+ 'theme_registry_alter',
+ 'token_info',
+ 'token_info_alter',
+ 'tokens',
+ 'tokens_alter',
+ 'translated_menu_link_alter',
+ 'trigger_info',
+ 'trigger_info_alter',
+ 'uninstall',
+ 'update',
+ 'update_dependencies',
+ 'update_index',
+ 'update_last_removed',
+ 'update_projects_alter',
+ 'update_status_alter',
+ 'updater_info',
+ 'updater_info_alter',
+ 'url_inbound_alter',
+ 'url_outbound_alter',
+ 'user_cancel',
+ 'user_cancel_methods_alter',
+ 'user_categories',
+ 'user_delete',
+ 'user_insert',
+ 'user_load',
+ 'user_login',
+ 'user_logout',
+ 'user_operations',
+ 'user_presave',
+ 'user_role_delete',
+ 'user_role_insert',
+ 'user_role_update',
+ 'user_update',
+ 'user_view',
+ 'user_view_alter',
+ 'username_alter',
+ 'validate',
+ 'verify_update_archive',
+ 'view',
+ 'watchdog',
+ 'xmlrpc',
+ 'xmlrpc_alter'
+ ]
+ return hooks
+end
View
31 drupal.ruble/templates/template.install
@@ -3,33 +3,4 @@
* @file
* Install, Uninstall, Schema, and Update functionality
*/
-
-/**
- * Implements hook_install().
- */
-function ${TM_NEW_FILE_BASENAME}_install() {
-
-}
-
-/**
- * Implements hook_uninstall().
- */
-function ${TM_NEW_FILE_BASENAME}_uninstall() {
-
-}
-
-/**
- * Implements hook_schema().
- */
-function ${TM_NEW_FILE_BASENAME}_schema() {
- $schema = array();
-
- return $schema;
-}
-
-/**
- * Implements hook_update_N().
- */
-function ${TM_NEW_FILE_BASENAME}_update_7100() {
-
-}
+${hooks}
View
10 drupal.ruble/templates/template.module
@@ -1,12 +1,6 @@
<?php
/**
* @file
- * Core and Contrib Hooks, and required functions for module
+ * Core & Contrib hooks and other primary functions
*/
-
-/**
- * Implements hook_help().
- */
-function ${TM_NEW_FILE_BASENAME}_help($path, $arg) {
-
-}
+${hooks}
View
48 drupal.ruble/templates/templates.rb
@@ -1,9 +1,34 @@
require 'ruble'
+require 'functions.rb'
+require 'multiple.rb'
+
+Ruble::Logger.log_level = :trace
template "Module Template" do |t|
t.filetype = "*.module"
t.replace_parameters = true
t.invoke do |context|
+ options = {}
+ items = hooks_list()
+ options[:items] = items
+ options[:title] = "Select Hooks to Include"
+ chosen = RubleM::UI.request_items(options)
+ hooks = ''
+ moduleName = ENV['TM_NEW_FILE_BASENAME']
+ chosen.each do |hook|
+ hook_s = hook.to_s
+ out =<<END
+
+/**
+ * Implements hook_#{hook_s}()
+ */
+function #{moduleName}_#{hook_s}() {
+
+}
+END
+ hooks << out
+ end
+ ENV['hooks'] = hooks
raw_contents = IO.read("#{ENV['TM_BUNDLE_SUPPORT']}/../templates/template.module")
raw_contents.gsub(/\$\{([^}]*)\}/) {|match| ENV[match[2..-2]] }
end
@@ -12,7 +37,30 @@
template "Install Template" do |t|
t.filetype = "*.install"
t.replace_parameters = true
+ t.input = :none
+ t.output = :none
t.invoke do |context|
+ options = {}
+ items = ['install', 'uninstall', 'schema']
+ options[:items] = items
+ options[:title] = "Select Hooks to Include"
+ chosen = RubleM::UI.request_items(options)
+ hooks = ''
+ moduleName = ENV['TM_NEW_FILE_BASENAME']
+ chosen.each do |hook|
+ hook_s = hook.to_s
+ out =<<END
+
+/**
+ * Implements hook_#{hook_s}()
+ */
+function #{moduleName}_#{hook_s}() {
+
+}
+END
+ hooks << out
+ end
+ ENV['hooks'] = hooks
raw_contents = IO.read("#{ENV['TM_BUNDLE_SUPPORT']}/../templates/template.install")
raw_contents.gsub(/\$\{([^}]*)\}/) {|match| ENV[match[2..-2]] }
end

0 comments on commit 36bfd00

Please sign in to comment.
Something went wrong with that request. Please try again.