forked from soveran/cuba
-
Notifications
You must be signed in to change notification settings - Fork 141
/
Rakefile
128 lines (101 loc) · 3.13 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
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
require "rake"
require "rake/clean"
require "rdoc/task"
NAME = 'roda'
VERS = lambda do
require_relative 'lib/roda/version'
Roda::RodaVersion
end
CLEAN.include ["#{NAME}-*.gem", "rdoc", "coverage", "www/public/*.html", "www/public/rdoc", "spec/assets/app.*.css", "spec/assets/app.*.js", "spec/assets/app.*.css.gz", "spec/assets/app.*.js.gz", "spec/iv.erb"]
# Gem Packaging and Release
desc "Packages #{NAME}"
task :package=>[:clean] do |p|
sh %{gem build #{NAME}.gemspec}
end
### RDoc
RDOC_OPTS = ["--line-numbers", "--inline-source", '--title', 'Roda: Routing tree web toolkit']
begin
gem 'hanna'
RDOC_OPTS.concat(['-f', 'hanna'])
rescue Gem::LoadError
end
RDOC_OPTS.concat(['--main', 'README.rdoc'])
RDOC_FILES = %w"README.rdoc CHANGELOG doc/CHANGELOG.old MIT-LICENSE lib/**/*.rb" + Dir["doc/*.rdoc"] + Dir['doc/release_notes/*.txt']
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = "rdoc"
rdoc.options += RDOC_OPTS
rdoc.rdoc_files.add RDOC_FILES
end
RDoc::Task.new(:website_rdoc) do |rdoc|
rdoc.rdoc_dir = "www/public/rdoc"
rdoc.options += RDOC_OPTS
rdoc.rdoc_files.add RDOC_FILES
end
### Website
desc "Make local version of website"
task :website_base do
sh %{#{FileUtils::RUBY} -I lib www/make_www.rb}
end
desc "Make local version of website, with rdoc"
task :website => [:website_base, :website_rdoc]
desc "Serve local version of website via rackup"
task :serve => :website do
sh %{#{FileUtils::RUBY} -C www -S rackup}
end
### Specs
spec = proc do |env|
env.each{|k,v| ENV[k] = v}
sh "#{FileUtils::RUBY} #{"-w" if RUBY_VERSION >= '3'} spec/all.rb"
env.each{|k,v| ENV.delete(k)}
if File.directory?('.sass-cache')
require 'fileutils'
FileUtils.rm_r('.sass-cache')
end
end
desc "Run specs"
task "spec" do
spec.call({})
end
task :default=>:spec
desc "Run specs with method visibility checking"
task "spec_vis" do
spec.call('CHECK_METHOD_VISIBILITY'=>'1')
end
desc "Run specs with coverage"
task "spec_cov" do
spec.call('COVERAGE'=>'< 4')
spec.call('COVERAGE'=>'< 3.1')
spec.call('COVERAGE'=>'< 3')
spec.call('COVERAGE'=>'< 1.6', 'RODA_RENDER_COMPILED_METHOD_SUPPORT'=>'no')
end
desc "Run specs with Rack::Lint"
task "spec_lint" do
spec.call('LINT'=>'1')
end
desc "Run specs in CI mode"
task "spec_ci" do
# Use LINT on about half of the tested Ruby versions,
# rotating each day.
spec.call(RUBY_VERSION[2].to_i.odd? ^ Time.now.wday.odd? ? {} : {'LINT'=>'1'})
end
### Other
desc "Print #{NAME} version"
task :version do
puts VERS.call
end
desc "Start an IRB shell using the extension"
task :irb do
require 'rbconfig'
ruby = ENV['RUBY'] || File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
irb = ENV['IRB'] || File.join(RbConfig::CONFIG['bindir'], File.basename(ruby).sub('ruby', 'irb'))
sh %{#{irb} -I lib -r #{NAME}}
end
# Other
desc "Check documentation for plugin files"
task :check_plugin_doc do
text = File.binread('www/pages/documentation.erb')
skip = %w'delay_build'
Dir['lib/roda/plugins/*.rb'].map{|f| File.basename(f).sub('.rb', '') if File.size(f)}.sort.each do |f|
puts f if !f.start_with?('_') && !skip.include?(f) && !text.include?(">#{f}<")
end
end