|
1 | 1 | require 'bundler/setup'
|
2 | 2 |
|
3 |
| -require 'rspec/core/rake_task' |
4 |
| -require 'yard' |
5 |
| - |
6 |
| -RSpec::Core::RakeTask.new(:spec) |
7 |
| - |
8 |
| -task :default => :spec |
9 |
| - |
10 |
| -namespace :yard do |
11 |
| - yard_files = [ |
12 |
| - # Ruby source files first |
13 |
| - 'lib/msf/**/*.rb', |
14 |
| - 'lib/rex/**/*.rb', |
15 |
| - # Anything after '-' is a normal documentation, not source |
16 |
| - '-', |
17 |
| - 'COPYING', |
18 |
| - 'HACKING', |
19 |
| - 'THIRD-PARTY.md' |
20 |
| - ] |
21 |
| - yard_options = [ |
22 |
| - # include documentation for protected methods for developers extending the code. |
23 |
| - '--protected' |
24 |
| - ] |
25 |
| - |
26 |
| - YARD::Rake::YardocTask.new(:doc) do |t| |
27 |
| - t.files = yard_files |
28 |
| - # --no-stats here as 'stats' task called after will print fuller stats |
29 |
| - t.options = yard_options + ['--no-stats'] |
30 |
| - |
31 |
| - t.after = Proc.new { |
32 |
| - Rake::Task['yard:stats'].execute |
33 |
| - } |
34 |
| - end |
35 |
| - |
36 |
| - desc "Shows stats for YARD Documentation including listing undocumented modules, classes, constants, and methods" |
37 |
| - task :stats => :environment do |
38 |
| - stats = YARD::CLI::Stats.new |
39 |
| - yard_arguments = yard_options + ['--compact', '--list-undoc'] + yard_files |
40 |
| - stats.run(*yard_arguments) |
41 |
| - end |
| 3 | +require 'metasploit_data_models' |
| 4 | + |
| 5 | +print_without = false |
| 6 | + |
| 7 | +begin |
| 8 | + require 'rspec/core/rake_task' |
| 9 | +rescue LoadError |
| 10 | + puts "rspec not in bundle, so can't set up spec tasks. " \ |
| 11 | + "To run specs ensure to install the development and test groups." |
| 12 | + |
| 13 | + print_without = true |
| 14 | +else |
| 15 | + RSpec::Core::RakeTask.new(:spec) |
| 16 | + |
| 17 | + task :default => :spec |
| 18 | +end |
| 19 | + |
| 20 | +begin |
| 21 | + require 'yard' |
| 22 | +rescue LoadError |
| 23 | + puts "yard not in bundle, so can't set up yard tasks. " \ |
| 24 | + "To generate documentation ensure to install the development group." |
| 25 | + |
| 26 | + print_without = true |
42 | 27 | end
|
43 | 28 |
|
44 |
| -# @todo Figure out how to just clone description from yard:doc |
45 |
| -desc "Generate YARD documentation" |
46 |
| -# allow calling namespace to as a task that goes to default task for namespace |
47 |
| -task :yard => ['yard:doc'] |
| 29 | +metasploit_data_models_task_glob = MetasploitDataModels.root.join( |
| 30 | + 'lib', |
| 31 | + 'tasks', |
| 32 | + '**', |
| 33 | + '*.rake' |
| 34 | +).to_s |
| 35 | + |
| 36 | +# include tasks from metasplioit_data_models, such as `rake yard`. |
| 37 | +# metasploit-framework specific yard options are in .yardopts |
| 38 | +Dir.glob(metasploit_data_models_task_glob) do |path| |
| 39 | + load path |
| 40 | +end |
| 41 | + |
| 42 | +if print_without |
| 43 | + puts "Bundle currently installed " \ |
| 44 | + "'--without #{Bundler.settings.without.join(' ')}'." |
| 45 | + puts "To clear the without option do `bundle install --without ''` " \ |
| 46 | + "(the --without flag with an empty string) or " \ |
| 47 | + "`rm -rf .bundle` to remove the .bundle/config manually and " \ |
| 48 | + "then `bundle install`" |
| 49 | +end |
0 commit comments