forked from lsegal/yard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
99 lines (86 loc) · 2.72 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
require File.dirname(__FILE__) + '/lib/yard'
require File.dirname(__FILE__) + '/lib/yard/rubygems/specification'
require 'rbconfig'
YARD::VERSION.replace(ENV['YARD_VERSION']) if ENV['YARD_VERSION']
WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mingw|win32|cygwin/ ? true : false) rescue false
SUDO = WINDOWS ? '' : 'sudo'
task :default => :specs
desc "Builds the gem"
task :gem do
Gem::Builder.new(eval(File.read('yard.gemspec'))).build
end
desc "Installs the gem"
task :install => :gem do
sh "#{SUDO} gem install yard-#{YARD::VERSION}.gem --no-rdoc --no-ri"
end
desc 'Run spec suite'
task :suite do
['ruby186', 'ruby18', 'ruby19', 'ruby192', 'ruby193', 'jruby'].each do |ruby|
2.times do |legacy|
next if legacy == 1 && ruby =~ /^jruby|186/
puts "Running specs with #{ruby}#{legacy == 1 ? ' (in legacy mode)' : ''}"
cmd = "#{ruby} -S rake specs SUITE=1 #{legacy == 1 ? 'LEGACY=1' : ''}"
puts cmd
system(cmd)
end
end
end
task :travis_ci do
status = 0
ENV['SUITE'] = '1'
ENV['CI'] = '1'
system "bundle exec rake specs"
status = 1 if $?.to_i != 0
if RUBY_VERSION >= '1.9' && RUBY_PLATFORM != 'java'
puts ""
puts "Running specs with in legacy mode"
system "bundle exec rake specs LEGACY=1"
status = 1 if $?.to_i != 0
end
exit(status)
end
begin
hide = '_spec\.rb$,spec_helper\.rb$,ruby_lex\.rb$,autoload\.rb$'
if YARD::Parser::SourceParser.parser_type == :ruby
hide += ',legacy\/.+_handler'
else
hide += ',ruby_parser\.rb$,ast_node\.rb$,handlers\/ruby\/[^\/]+\.rb$'
end
require 'rspec'
require 'rspec/core/rake_task'
desc "Run all specs"
RSpec::Core::RakeTask.new("specs") do |t|
$DEBUG = true if ENV['DEBUG']
t.rspec_opts = ENV['SUITE'] ? [] : ['-c']
t.rspec_opts += ["--require", File.join(File.dirname(__FILE__), 'spec', 'spec_helper')]
t.rspec_opts += ['-I', YARD::ROOT]
t.pattern = "spec/**/*_spec.rb"
t.verbose = $DEBUG ? true : false
if ENV['RCOV']
t.rcov = true
t.rcov_opts = ['-x', hide]
end
end
task :spec => :specs
rescue LoadError
begin # Try for rspec 1.x
require 'spec'
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new("specs") do |t|
$DEBUG = true if ENV['DEBUG']
t.spec_opts = ["--format", "specdoc", "--colour"]
t.spec_opts += ["--require", File.join(File.dirname(__FILE__), 'spec', 'spec_helper')]
t.pattern = "spec/**/*_spec.rb"
if ENV['RCOV']
t.rcov = true
t.rcov_opts = ['-x', hide]
end
end
task :spec => :specs
rescue LoadError
warn "warn: RSpec tests not available. `gem install rspec` to enable them."
end
end
YARD::Rake::YardocTask.new do |t|
t.options += ['--title', "YARD #{YARD::VERSION} Documentation"]
end