Skip to content

Commit

Permalink
add choice to not add setup hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Teubert committed Dec 20, 2010
1 parent 8a3d846 commit a40485f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
15 changes: 11 additions & 4 deletions generate.rb
Expand Up @@ -37,6 +37,11 @@ def slug
desc 'The name of the plugin'
end

option :no_setup do
long '--no-setup'
desc 'Disable creation and registration of setup hooks'
end

end

name = Choice.choices.name
Expand Down Expand Up @@ -64,10 +69,12 @@ def slug
main.close

# render setup template
template = ERB.new File.read(BASEDIR + '/templates/setup.php')
main = File.new("setup.php", "w")
main.write(template.result)
main.close
unless Choice.choices.no_setup
template = ERB.new File.read(BASEDIR + '/templates/setup.php')
main = File.new("setup.php", "w")
main.write(template.result)
main.close
end

# copy application controller
FileUtils.copy BASEDIR + '/templates/ApplicationController.php', 'app/controllers/'
8 changes: 7 additions & 1 deletion templates/plugin_name.php
Expand Up @@ -55,4 +55,10 @@ function <%= name.slug %>_add_default_view_directory($directories)
return $directories;
}
}
add_filter('app-view-directories', '<%= name.slug %>_add_default_view_directory');
add_filter('app-view-directories', '<%= name.slug %>_add_default_view_directory');

<% unless Choice.choices.no_setup %>
register_activation_hook(__FILE__, '<%= name.slug %>_activate');
register_deactivation_hook(__FILE__, '<%= name.slug %>_deactivate');
register_uninstall_hook(__FILE__, '<%= name.slug %>_uninstall');
<% end %>

0 comments on commit a40485f

Please sign in to comment.