Skip to content
This repository
Browse code

Support generating a thorfile.

  • Loading branch information...
commit b3b83db6e6b255b64a6d1182c83fb249efc8ba89 1 parent 9dcbb46
Josh Nichols authored
9 lib/jeweler/generator.rb
@@ -160,7 +160,14 @@ def create_files
160 160
161 161
162 162 output_template_in_target '.gitignore'
163   - output_template_in_target 'Rakefile'
  163 +
  164 + case options[:scripting_framework]
  165 + when :rake
  166 + output_template_in_target 'Rakefile'
  167 + when :thor
  168 + output_template_in_target 'Thorfile'
  169 + end
  170 +
164 171 output_template_in_target 'LICENSE'
165 172 output_template_in_target 'README.rdoc'
166 173 output_template_in_target '.document'
147 lib/jeweler/templates/Rakefile
... ... @@ -1,149 +1,4 @@
1 1 require 'rubygems'
2 2 require 'rake'
3 3
4   -begin
5   - require 'jeweler'
6   - Jeweler::Tasks.new do |gem|
7   - gem.name = "<%= project_name %>"
8   - gem.summary = %Q{<%= summary %>}
9   - gem.description = %Q{<%= description %>}
10   - gem.email = "<%= user_email %>"
11   - gem.homepage = "<%= homepage %>"
12   - gem.authors = ["<%= user_name %>"]
13   -<% if should_setup_rubyforge %>
14   - gem.rubyforge_project = "<%= project_name %>"
15   -<% end %>
16   -<% development_dependencies.each do |name, version| %>
17   - gem.add_development_dependency "<%= name %>", "<%= version %>"
18   -<% end %>
19   - # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20   - end
21   -<% if should_setup_gemcutter %>
22   - Jeweler::GemcutterTasks.new
23   -<% end %>
24   -<% if should_setup_rubyforge %>
25   - Jeweler::RubyforgeTasks.new do |rubyforge|
26   - rubyforge.doc_task = "<%= doc_task %>"
27   - end
28   -<% end %>
29   -rescue LoadError
30   - puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
31   -end
32   -
33   -<% case testing_framework %>
34   -<% when :rspec %>
35   -require 'spec/rake/spectask'
36   -Spec::Rake::SpecTask.new(:<%= test_task %>) do |<%= test_task %>|
37   - <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
38   - <%= test_task %>.spec_files = FileList['<%= test_pattern %>']
39   -end
40   -<% when :micronaut %>
41   -require 'micronaut/rake_task'
42   -Micronaut::RakeTask.new(<%= test_task %>) do |<%= test_task %>|
43   - <%= test_task %>.pattern = '<%= test_pattern %>'
44   - <%= test_task %>.ruby_opts << '-Ilib -I<%= test_dir %>'
45   -end
46   -<% else %>
47   -require 'rake/testtask'
48   -Rake::TestTask.new(:<%= test_task %>) do |<%= test_task %>|
49   - <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
50   - <%= test_task %>.pattern = '<%= test_pattern %>'
51   - <%= test_task %>.verbose = true
52   -end
53   -<% end %>
54   -
55   -<% case testing_framework %>
56   -<% when :rspec %>
57   -Spec::Rake::SpecTask.new(:rcov) do |spec|
58   - spec.libs << 'lib' << 'spec'
59   - spec.pattern = '<%= test_pattern %>'
60   - spec.rcov = true
61   -end
62   -<% when :micronaut %>
63   -Micronaut::RakeTask.new(:rcov) do |examples|
64   - examples.pattern = '<%= test_pattern %>'
65   - examples.rcov_opts = '-Ilib -I<%= test_dir %>'
66   - examples.rcov = true
67   -end
68   -<% else %>
69   -begin
70   - require 'rcov/rcovtask'
71   - Rcov::RcovTask.new do |<%= test_task %>|
72   - <%= test_task %>.libs << '<%= test_dir %>'
73   - <%= test_task %>.pattern = '<%= test_pattern %>'
74   - <%= test_task %>.verbose = true
75   - end
76   -rescue LoadError
77   - task :rcov do
78   - abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
79   - end
80   -end
81   -<% end %>
82   -
83   -task :<%= test_task %> => :check_dependencies
84   -
85   -<% if should_use_cucumber %>
86   -begin
87   - require 'cucumber/rake/task'
88   - Cucumber::Rake::Task.new(:features)
89   -
90   - task :features => :check_dependencies
91   -rescue LoadError
92   - task :features do
93   - abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
94   - end
95   -end
96   -<% end %>
97   -
98   -<% if should_use_reek %>
99   -begin
100   - require 'reek/rake_task'
101   - Reek::RakeTask.new do |t|
102   - t.fail_on_error = true
103   - t.verbose = false
104   - t.source_files = 'lib/**/*.rb'
105   - end
106   -rescue LoadError
107   - task :reek do
108   - abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
109   - end
110   -end
111   -<% end %>
112   -
113   -<% if should_use_roodi %>
114   -begin
115   - require 'roodi'
116   - require 'roodi_task'
117   - RoodiTask.new do |t|
118   - t.verbose = false
119   - end
120   -rescue LoadError
121   - task :roodi do
122   - abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
123   - end
124   -end
125   -<% end %>
126   -
127   -task :default => :<%= default_task %>
128   -
129   -<% case documentation_framework %>
130   -<% when :rdoc %>
131   -require 'rake/rdoctask'
132   -Rake::RDocTask.new do |rdoc|
133   - version = File.exist?('VERSION') ? File.read('VERSION') : ""
134   -
135   - rdoc.rdoc_dir = 'rdoc'
136   - rdoc.title = "<%= project_name %> #{version}"
137   - rdoc.rdoc_files.include('README*')
138   - rdoc.rdoc_files.include('lib/**/*.rb')
139   -end
140   -<% when :yard %>
141   -begin
142   - require 'yard'
143   - YARD::Rake::YardocTask.new
144   -rescue LoadError
145   - task :yardoc do
146   - abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
147   - end
148   -end
149   -<% end %>
  4 +<%= render_template 'tasks.erb' %>
11 lib/jeweler/templates/Thorfile
... ... @@ -0,0 +1,11 @@
  1 +require 'thor/rake_compat'
  2 +require 'spec/rake/spectask'
  3 +
  4 +GEM_NAME = 'thor'
  5 +EXTRA_RDOC_FILES = ["README.rdoc", "LICENSE", "CHANGELOG.rdoc", "VERSION", "Thorfile"]
  6 +
  7 +class Default < Thor
  8 + include Thor::RakeCompat
  9 +
  10 + <%= render_template 'tasks.erb' %>
  11 +end
147 lib/jeweler/templates/tasks.erb
... ... @@ -0,0 +1,147 @@
  1 +begin
  2 + require 'jeweler'
  3 + Jeweler::Tasks.new do |gem|
  4 + gem.name = "<%= project_name %>"
  5 + gem.summary = %Q{<%= summary %>}
  6 + gem.description = %Q{<%= description %>}
  7 + gem.email = "<%= user_email %>"
  8 + gem.homepage = "<%= homepage %>"
  9 + gem.authors = ["<%= user_name %>"]
  10 +<% if should_setup_rubyforge %>
  11 + gem.rubyforge_project = "<%= project_name %>"
  12 +<% end %>
  13 +<% development_dependencies.each do |name, version| %>
  14 + gem.add_development_dependency "<%= name %>", "<%= version %>"
  15 +<% end %>
  16 + # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
  17 + end
  18 +<% if should_setup_gemcutter %>
  19 + Jeweler::GemcutterTasks.new
  20 +<% end %>
  21 +<% if should_setup_rubyforge %>
  22 + Jeweler::RubyforgeTasks.new do |rubyforge|
  23 + rubyforge.doc_task = "<%= doc_task %>"
  24 + end
  25 +<% end %>
  26 +rescue LoadError
  27 + puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
  28 +end
  29 +
  30 +<% case testing_framework %>
  31 +<% when :rspec %>
  32 +require 'spec/rake/spectask'
  33 +Spec::Rake::SpecTask.new(:<%= test_task %>) do |<%= test_task %>|
  34 + <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
  35 + <%= test_task %>.spec_files = FileList['<%= test_pattern %>']
  36 +end
  37 +<% when :micronaut %>
  38 +require 'micronaut/rake_task'
  39 +Micronaut::RakeTask.new(<%= test_task %>) do |<%= test_task %>|
  40 + <%= test_task %>.pattern = '<%= test_pattern %>'
  41 + <%= test_task %>.ruby_opts << '-Ilib -I<%= test_dir %>'
  42 +end
  43 +<% else %>
  44 +require 'rake/testtask'
  45 +Rake::TestTask.new(:<%= test_task %>) do |<%= test_task %>|
  46 + <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
  47 + <%= test_task %>.pattern = '<%= test_pattern %>'
  48 + <%= test_task %>.verbose = true
  49 +end
  50 +<% end %>
  51 +
  52 +<% case testing_framework %>
  53 +<% when :rspec %>
  54 +Spec::Rake::SpecTask.new(:rcov) do |spec|
  55 + spec.libs << 'lib' << 'spec'
  56 + spec.pattern = '<%= test_pattern %>'
  57 + spec.rcov = true
  58 +end
  59 +<% when :micronaut %>
  60 +Micronaut::RakeTask.new(:rcov) do |examples|
  61 + examples.pattern = '<%= test_pattern %>'
  62 + examples.rcov_opts = '-Ilib -I<%= test_dir %>'
  63 + examples.rcov = true
  64 +end
  65 +<% else %>
  66 +begin
  67 + require 'rcov/rcovtask'
  68 + Rcov::RcovTask.new do |<%= test_task %>|
  69 + <%= test_task %>.libs << '<%= test_dir %>'
  70 + <%= test_task %>.pattern = '<%= test_pattern %>'
  71 + <%= test_task %>.verbose = true
  72 + end
  73 +rescue LoadError
  74 + task :rcov do
  75 + abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
  76 + end
  77 +end
  78 +<% end %>
  79 +
  80 +task :<%= test_task %> => :check_dependencies
  81 +
  82 +<% if should_use_cucumber %>
  83 +begin
  84 + require 'cucumber/rake/task'
  85 + Cucumber::Rake::Task.new(:features)
  86 +
  87 + task :features => :check_dependencies
  88 +rescue LoadError
  89 + task :features do
  90 + abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
  91 + end
  92 +end
  93 +<% end %>
  94 +
  95 +<% if should_use_reek %>
  96 +begin
  97 + require 'reek/rake_task'
  98 + Reek::RakeTask.new do |t|
  99 + t.fail_on_error = true
  100 + t.verbose = false
  101 + t.source_files = 'lib/**/*.rb'
  102 + end
  103 +rescue LoadError
  104 + task :reek do
  105 + abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
  106 + end
  107 +end
  108 +<% end %>
  109 +
  110 +<% if should_use_roodi %>
  111 +begin
  112 + require 'roodi'
  113 + require 'roodi_task'
  114 + RoodiTask.new do |t|
  115 + t.verbose = false
  116 + end
  117 +rescue LoadError
  118 + task :roodi do
  119 + abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
  120 + end
  121 +end
  122 +<% end %>
  123 +
  124 +task :default => :<%= default_task %>
  125 +
  126 +<% case documentation_framework %>
  127 +<% when :rdoc %>
  128 +require 'rake/rdoctask'
  129 +Rake::RDocTask.new do |rdoc|
  130 + version = File.exist?('VERSION') ? File.read('VERSION') : ""
  131 +
  132 + rdoc.rdoc_dir = 'rdoc'
  133 + rdoc.title = "<%= project_name %> #{version}"
  134 + rdoc.rdoc_files.include('README*')
  135 + rdoc.rdoc_files.include('lib/**/*.rb')
  136 +end
  137 +<% when :yard %>
  138 +begin
  139 + require 'yard'
  140 + YARD::Rake::YardocTask.new
  141 +rescue LoadError
  142 + task :yardoc do
  143 + abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
  144 + end
  145 +end
  146 +<% end %>
  147 +

0 comments on commit b3b83db

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