From 58136e1bd359ce71275eb8e8e5c20d1c9b286b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 17 Jan 2010 15:17:50 +0100 Subject: Plugin generator should use templates. --- .../generators/rails/plugin/templates/MIT-LICENSE | 20 -------------------- .../rails/plugin/templates/MIT-LICENSE.tt | 20 ++++++++++++++++++++ .../rails/generators/rails/plugin/templates/README | 13 ------------- .../generators/rails/plugin/templates/README.tt | 13 +++++++++++++ .../generators/rails/plugin/templates/Rakefile | 22 ---------------------- .../generators/rails/plugin/templates/Rakefile.tt | 22 ++++++++++++++++++++++ railties/test/generators/plugin_generator_test.rb | 15 +++++++++++++++ 7 files changed, 70 insertions(+), 55 deletions(-) delete mode 100644 railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE create mode 100644 railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt delete mode 100644 railties/lib/rails/generators/rails/plugin/templates/README create mode 100644 railties/lib/rails/generators/rails/plugin/templates/README.tt delete mode 100644 railties/lib/rails/generators/rails/plugin/templates/Rakefile create mode 100644 railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt diff --git a/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE b/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE deleted file mode 100644 index 8717df053d..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) <%= Date.today.year %> [name of plugin creator] - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt b/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt new file mode 100644 index 0000000000..8717df053d --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt @@ -0,0 +1,20 @@ +Copyright (c) <%= Date.today.year %> [name of plugin creator] + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/railties/lib/rails/generators/rails/plugin/templates/README b/railties/lib/rails/generators/rails/plugin/templates/README deleted file mode 100644 index 702db07cb1..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/README +++ /dev/null @@ -1,13 +0,0 @@ -<%= class_name %> -<%= "=" * class_name.size %> - -Introduction goes here. - - -Example -======= - -Example goes here. - - -Copyright (c) <%= Date.today.year %> [name of plugin creator], released under the MIT license diff --git a/railties/lib/rails/generators/rails/plugin/templates/README.tt b/railties/lib/rails/generators/rails/plugin/templates/README.tt new file mode 100644 index 0000000000..702db07cb1 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/README.tt @@ -0,0 +1,13 @@ +<%= class_name %> +<%= "=" * class_name.size %> + +Introduction goes here. + + +Example +======= + +Example goes here. + + +Copyright (c) <%= Date.today.year %> [name of plugin creator], released under the MIT license diff --git a/railties/lib/rails/generators/rails/plugin/templates/Rakefile b/railties/lib/rails/generators/rails/plugin/templates/Rakefile deleted file mode 100644 index 23c2245a41..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the <%= file_name %> plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' -end - -desc 'Generate documentation for the <%= file_name %> plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = '<%= class_name %>' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt b/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt new file mode 100644 index 0000000000..23c2245a41 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt @@ -0,0 +1,22 @@ +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' + +desc 'Default: run unit tests.' +task :default => :test + +desc 'Test the <%= file_name %> plugin.' +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' +end + +desc 'Generate documentation for the <%= file_name %> plugin.' +Rake::RDocTask.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = '<%= class_name %>' + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('lib/**/*.rb') +end diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index f84b8b6d50..2989cdb67d 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -6,12 +6,27 @@ class PluginGeneratorTest < GeneratorsTestCase def test_plugin_skeleton_is_created run_generator + year = Date.today.year %w( vendor/plugins vendor/plugins/plugin_fu + vendor/plugins/plugin_fu/init.rb + vendor/plugins/plugin_fu/install.rb + vendor/plugins/plugin_fu/uninstall.rb vendor/plugins/plugin_fu/lib + vendor/plugins/plugin_fu/lib/plugin_fu.rb ).each{ |path| assert_file path } + + %w( + vendor/plugins/plugin_fu/README + vendor/plugins/plugin_fu/Rakefile + ).each{ |path| assert_file path, /PluginFu/ } + + %w( + vendor/plugins/plugin_fu/README + vendor/plugins/plugin_fu/MIT-LICENSE + ).each{ |path| assert_file path, /#{year}/ } end def test_check_class_collision -- cgit v1.2.3