/
Rakefile.rb
130 lines (111 loc) · 4.08 KB
/
Rakefile.rb
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
($:.unshift File.expand_path(File.join( File.dirname(__FILE__), 'lib' ))).uniq!
require "lobby"
default_tasks = Array.new
# =======================
# = Gem packaging tasks =
# =======================
begin
require 'echoe'
default_tasks << :'package:manifest' unless ENV['CI']
default_tasks << :'package:verify'
task :install => :'package:install'
task :package => :'package:package'
task :manifest => :'package:manifest'
namespace :package do
Echoe.new('lobby', LobbyConstructor::Version) do |g|
g.author = ['elliottcable']
g.email = ["Lobby@elliottcable.com"]
g.summary = "Welcome to Ruby. Enjoy your stay. Here's a chair."
g.url = 'http://github.com/elliottcable/lobby'
g.runtime_dependencies = []
g.development_dependencies = ['echoe >= 3.0.2', 'rspec', 'rcov', 'yard']
g.manifest_name = '.manifest'
g.retain_gemspec = true
g.rakefile_name = 'Rakefile.rb'
g.ignore_pattern = /^\.git\/|^meta\/|\.gemspec/
end
desc 'Tests packaged files to ensure they are all present'
task :verify => :package do
# An error message will be displayed if files are missing
if system %(ruby -e "require 'rubygems'; require 'pkg/lobby-#{LobbyConstructor::Version}/lib/lobby'")
puts "\nThe library files are present."
end
end
end
rescue LoadError => exception
raise exception unless exception.message =~ /(echoe)$/
desc '!! You need the `echoe` gem to package or install this project!'
task :package
end
# =======================
# = Spec/Coverage tasks =
# =======================
begin
require 'spec'
require 'rcov'
require 'spec/rake/spectask'
default_tasks << :'coverage:run'
default_tasks << :'coverage:open' unless ENV['CI']
task :coverage => :'coverage:run'
namespace :coverage do
Spec::Rake::SpecTask.new(:run) do |t|
t.spec_opts = ["--format", "specdoc"]
t.spec_opts << "--colour" unless ENV['CI']
t.spec_files = Dir[File.join('spec', '**', '*_spec.rb')].sort
t.libs = ['lib']
t.rcov = true
t.rcov_opts = ['--exclude-only', '".*"', '--include-file', '"^lib"',
'--sort', 'loc', '--sort-reverse',
'--comments', '--profile', '--text-report', '-w' ]
t.rcov_dir = File.join('meta', 'coverage')
end
task :open do
system 'open ' + File.join('meta', 'coverage', 'index.html')
end if RUBY_PLATFORM =~ /darwin/
end
rescue LoadError => exception
raise exception unless exception.message =~ /(rcov|spec)$/
desc '!! You need the `rcov` and `rspec` gems to run specs or coverage!'
task :coverage
end
# =======================
# = Documentation tasks =
# =======================
begin
require 'yard'
require 'yard/rake/yardoc_task'
default_tasks << :'documentation:generate'
default_tasks << :'documentation:open' unless ENV['CI']
task :documentation => :'documentation:generate'
namespace :documentation do
YARD::Rake::YardocTask.new :generate do |t|
t.files = [File.join('lib', '**', '*.rb')]
t.options = ['--output-dir', File.join('meta', 'documentation'),
'--readme', 'README.markdown']
end
YARD::Rake::YardocTask.new :yardoc do |t|
t.files = [File.join('lib', '**', '*.rb')]
t.options = ['--no-output',
'--readme', 'README.markdown']
end
task :open do
system 'open ' + File.join('meta', 'documentation', 'index.html')
end if RUBY_PLATFORM =~ /darwin/
end
rescue LoadError => exception
raise exception unless exception.message =~ /(yard)$/
desc '!! You need the `yard` gem to generate documentation!'
task :documentation
end
# =================
# = Miscellaneous =
# =================
desc 'Removes all meta producs'
task :clobber do
`rm -rf #{File.expand_path(File.join( File.dirname(__FILE__), 'meta' ))} #{File.expand_path(File.join( File.dirname(__FILE__), 'pkg' ))}`
end
desc 'Run all default tasks'
task :default => default_tasks do
puts "** Successfully ran the following tasks:"
puts "** #{Rake.application.tasks.select {|t| t.name == 'default' }.first.prerequisites.join(', ')}"
end