Skip to content
Browse files

Support generating a thorfile.

  • Loading branch information...
1 parent 9dcbb46 commit b3b83db6e6b255b64a6d1182c83fb249efc8ba89 @technicalpickles committed Oct 18, 2009
Showing with 167 additions and 147 deletions.
  1. +8 −1 lib/jeweler/generator.rb
  2. +1 −146 lib/jeweler/templates/Rakefile
  3. +11 −0 lib/jeweler/templates/Thorfile
  4. +147 −0 lib/jeweler/templates/tasks.erb
View
9 lib/jeweler/generator.rb
@@ -160,7 +160,14 @@ def create_files
output_template_in_target '.gitignore'
- output_template_in_target 'Rakefile'
+
+ case options[:scripting_framework]
+ when :rake
+ output_template_in_target 'Rakefile'
+ when :thor
+ output_template_in_target 'Thorfile'
+ end
+
output_template_in_target 'LICENSE'
output_template_in_target 'README.rdoc'
output_template_in_target '.document'
View
147 lib/jeweler/templates/Rakefile
@@ -1,149 +1,4 @@
require 'rubygems'
require 'rake'
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "<%= project_name %>"
- gem.summary = %Q{<%= summary %>}
- gem.description = %Q{<%= description %>}
- gem.email = "<%= user_email %>"
- gem.homepage = "<%= homepage %>"
- gem.authors = ["<%= user_name %>"]
-<% if should_setup_rubyforge %>
- gem.rubyforge_project = "<%= project_name %>"
-<% end %>
-<% development_dependencies.each do |name, version| %>
- gem.add_development_dependency "<%= name %>", "<%= version %>"
-<% end %>
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
- end
-<% if should_setup_gemcutter %>
- Jeweler::GemcutterTasks.new
-<% end %>
-<% if should_setup_rubyforge %>
- Jeweler::RubyforgeTasks.new do |rubyforge|
- rubyforge.doc_task = "<%= doc_task %>"
- end
-<% end %>
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
-end
-
-<% case testing_framework %>
-<% when :rspec %>
-require 'spec/rake/spectask'
-Spec::Rake::SpecTask.new(:<%= test_task %>) do |<%= test_task %>|
- <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
- <%= test_task %>.spec_files = FileList['<%= test_pattern %>']
-end
-<% when :micronaut %>
-require 'micronaut/rake_task'
-Micronaut::RakeTask.new(<%= test_task %>) do |<%= test_task %>|
- <%= test_task %>.pattern = '<%= test_pattern %>'
- <%= test_task %>.ruby_opts << '-Ilib -I<%= test_dir %>'
-end
-<% else %>
-require 'rake/testtask'
-Rake::TestTask.new(:<%= test_task %>) do |<%= test_task %>|
- <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
- <%= test_task %>.pattern = '<%= test_pattern %>'
- <%= test_task %>.verbose = true
-end
-<% end %>
-
-<% case testing_framework %>
-<% when :rspec %>
-Spec::Rake::SpecTask.new(:rcov) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.pattern = '<%= test_pattern %>'
- spec.rcov = true
-end
-<% when :micronaut %>
-Micronaut::RakeTask.new(:rcov) do |examples|
- examples.pattern = '<%= test_pattern %>'
- examples.rcov_opts = '-Ilib -I<%= test_dir %>'
- examples.rcov = true
-end
-<% else %>
-begin
- require 'rcov/rcovtask'
- Rcov::RcovTask.new do |<%= test_task %>|
- <%= test_task %>.libs << '<%= test_dir %>'
- <%= test_task %>.pattern = '<%= test_pattern %>'
- <%= test_task %>.verbose = true
- end
-rescue LoadError
- task :rcov do
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
- end
-end
-<% end %>
-
-task :<%= test_task %> => :check_dependencies
-
-<% if should_use_cucumber %>
-begin
- require 'cucumber/rake/task'
- Cucumber::Rake::Task.new(:features)
-
- task :features => :check_dependencies
-rescue LoadError
- task :features do
- abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
- end
-end
-<% end %>
-
-<% if should_use_reek %>
-begin
- require 'reek/rake_task'
- Reek::RakeTask.new do |t|
- t.fail_on_error = true
- t.verbose = false
- t.source_files = 'lib/**/*.rb'
- end
-rescue LoadError
- task :reek do
- abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
- end
-end
-<% end %>
-
-<% if should_use_roodi %>
-begin
- require 'roodi'
- require 'roodi_task'
- RoodiTask.new do |t|
- t.verbose = false
- end
-rescue LoadError
- task :roodi do
- abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
- end
-end
-<% end %>
-
-task :default => :<%= default_task %>
-
-<% case documentation_framework %>
-<% when :rdoc %>
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
-
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "<%= project_name %> #{version}"
- rdoc.rdoc_files.include('README*')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
-<% when :yard %>
-begin
- require 'yard'
- YARD::Rake::YardocTask.new
-rescue LoadError
- task :yardoc do
- abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
- end
-end
-<% end %>
+<%= render_template 'tasks.erb' %>
View
11 lib/jeweler/templates/Thorfile
@@ -0,0 +1,11 @@
+require 'thor/rake_compat'
+require 'spec/rake/spectask'
+
+GEM_NAME = 'thor'
+EXTRA_RDOC_FILES = ["README.rdoc", "LICENSE", "CHANGELOG.rdoc", "VERSION", "Thorfile"]
+
+class Default < Thor
+ include Thor::RakeCompat
+
+ <%= render_template 'tasks.erb' %>
+end
View
147 lib/jeweler/templates/tasks.erb
@@ -0,0 +1,147 @@
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.name = "<%= project_name %>"
+ gem.summary = %Q{<%= summary %>}
+ gem.description = %Q{<%= description %>}
+ gem.email = "<%= user_email %>"
+ gem.homepage = "<%= homepage %>"
+ gem.authors = ["<%= user_name %>"]
+<% if should_setup_rubyforge %>
+ gem.rubyforge_project = "<%= project_name %>"
+<% end %>
+<% development_dependencies.each do |name, version| %>
+ gem.add_development_dependency "<%= name %>", "<%= version %>"
+<% end %>
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
+ end
+<% if should_setup_gemcutter %>
+ Jeweler::GemcutterTasks.new
+<% end %>
+<% if should_setup_rubyforge %>
+ Jeweler::RubyforgeTasks.new do |rubyforge|
+ rubyforge.doc_task = "<%= doc_task %>"
+ end
+<% end %>
+rescue LoadError
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
+end
+
+<% case testing_framework %>
+<% when :rspec %>
+require 'spec/rake/spectask'
+Spec::Rake::SpecTask.new(:<%= test_task %>) do |<%= test_task %>|
+ <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
+ <%= test_task %>.spec_files = FileList['<%= test_pattern %>']
+end
+<% when :micronaut %>
+require 'micronaut/rake_task'
+Micronaut::RakeTask.new(<%= test_task %>) do |<%= test_task %>|
+ <%= test_task %>.pattern = '<%= test_pattern %>'
+ <%= test_task %>.ruby_opts << '-Ilib -I<%= test_dir %>'
+end
+<% else %>
+require 'rake/testtask'
+Rake::TestTask.new(:<%= test_task %>) do |<%= test_task %>|
+ <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
+ <%= test_task %>.pattern = '<%= test_pattern %>'
+ <%= test_task %>.verbose = true
+end
+<% end %>
+
+<% case testing_framework %>
+<% when :rspec %>
+Spec::Rake::SpecTask.new(:rcov) do |spec|
+ spec.libs << 'lib' << 'spec'
+ spec.pattern = '<%= test_pattern %>'
+ spec.rcov = true
+end
+<% when :micronaut %>
+Micronaut::RakeTask.new(:rcov) do |examples|
+ examples.pattern = '<%= test_pattern %>'
+ examples.rcov_opts = '-Ilib -I<%= test_dir %>'
+ examples.rcov = true
+end
+<% else %>
+begin
+ require 'rcov/rcovtask'
+ Rcov::RcovTask.new do |<%= test_task %>|
+ <%= test_task %>.libs << '<%= test_dir %>'
+ <%= test_task %>.pattern = '<%= test_pattern %>'
+ <%= test_task %>.verbose = true
+ end
+rescue LoadError
+ task :rcov do
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
+ end
+end
+<% end %>
+
+task :<%= test_task %> => :check_dependencies
+
+<% if should_use_cucumber %>
+begin
+ require 'cucumber/rake/task'
+ Cucumber::Rake::Task.new(:features)
+
+ task :features => :check_dependencies
+rescue LoadError
+ task :features do
+ abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
+ end
+end
+<% end %>
+
+<% if should_use_reek %>
+begin
+ require 'reek/rake_task'
+ Reek::RakeTask.new do |t|
+ t.fail_on_error = true
+ t.verbose = false
+ t.source_files = 'lib/**/*.rb'
+ end
+rescue LoadError
+ task :reek do
+ abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
+ end
+end
+<% end %>
+
+<% if should_use_roodi %>
+begin
+ require 'roodi'
+ require 'roodi_task'
+ RoodiTask.new do |t|
+ t.verbose = false
+ end
+rescue LoadError
+ task :roodi do
+ abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
+ end
+end
+<% end %>
+
+task :default => :<%= default_task %>
+
+<% case documentation_framework %>
+<% when :rdoc %>
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "<%= project_name %> #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+<% when :yard %>
+begin
+ require 'yard'
+ YARD::Rake::YardocTask.new
+rescue LoadError
+ task :yardoc do
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
+ end
+end
+<% end %>
+

0 comments on commit b3b83db

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