You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

redmine_plugin_generator.rb 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006- Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. class RedminePluginGenerator < Rails::Generators::NamedBase
  19. source_root File.expand_path("../templates", __FILE__)
  20. attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
  21. def initialize(*args)
  22. super
  23. @plugin_name = file_name.underscore
  24. @plugin_pretty_name = plugin_name.titleize
  25. @plugin_path = File.join(Redmine::Plugin.directory, plugin_name)
  26. end
  27. def copy_templates
  28. empty_directory "#{plugin_path}/app"
  29. empty_directory "#{plugin_path}/app/controllers"
  30. empty_directory "#{plugin_path}/app/helpers"
  31. empty_directory "#{plugin_path}/app/models"
  32. empty_directory "#{plugin_path}/app/views"
  33. empty_directory "#{plugin_path}/db/migrate"
  34. empty_directory "#{plugin_path}/lib/tasks"
  35. empty_directory "#{plugin_path}/assets/images"
  36. empty_directory "#{plugin_path}/assets/javascripts"
  37. empty_directory "#{plugin_path}/assets/stylesheets"
  38. empty_directory "#{plugin_path}/config/locales"
  39. empty_directory "#{plugin_path}/test"
  40. empty_directory "#{plugin_path}/test/fixtures"
  41. empty_directory "#{plugin_path}/test/unit"
  42. empty_directory "#{plugin_path}/test/functional"
  43. empty_directory "#{plugin_path}/test/integration"
  44. empty_directory "#{plugin_path}/test/system"
  45. template 'README.rdoc', "#{plugin_path}/README.rdoc"
  46. template 'init.rb.erb', "#{plugin_path}/init.rb"
  47. template 'routes.rb', "#{plugin_path}/config/routes.rb"
  48. template 'en_rails_i18n.yml', "#{plugin_path}/config/locales/en.yml"
  49. template 'test_helper.rb.erb', "#{plugin_path}/test/test_helper.rb"
  50. end
  51. end