forked from matschaffer/knife-solo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
100 lines (84 loc) · 2.62 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
require 'bundler/gem_tasks'
require 'rake/testtask'
require File.join(File.dirname(__FILE__), 'lib', 'knife-solo', 'info')
MANIFEST_IGNORES = %w[
.travis.yml
.gitignore
.gitmodules
Gemfile
Gemfile.lock
Manifest.txt
README.md
knife-solo.gemspec
script/newb
script/test
]
namespace :manifest do
desc 'Checks for outstanding changes to the manifest'
task :verify => :update do
changes = `git status --porcelain Manifest.txt`
raise "Manifest has not been updated" unless changes.empty?
end
desc 'Updates Manifest.txt with a list of files from git'
task :update do
git_files = `git ls-files`.split("\n")
submodule_files = `git submodule foreach -q 'for f in $(git ls-files); do echo $path/$f; done'`.split("\n")
File.open('Manifest.txt', 'w') do |f|
f.puts((git_files + submodule_files - MANIFEST_IGNORES).join("\n"))
end
end
end
desc 'Alias to manifest:update'
task :manifest => 'manifest:update'
# Returns the parsed RDoc for a single file as HTML
# Somewhat gnarly, but does the job.
def parsed_rdoc file
options = RDoc::Options.new
options.template_dir = options.template_dir_for 'darkfish'
rdoc = RDoc::RDoc.current = RDoc::RDoc.new
rdoc.options = options
rdoc.generator = RDoc::Generator::Darkfish.new(options)
parsed = rdoc.parse_files([file])
parsed.first.description
end
desc 'Renerates gh-pages from project'
task 'gh-pages' do
require 'tmpdir'
gem 'rdoc'; require 'rdoc/rdoc'
Dir.mktmpdir do |clone|
sh "git clone -b gh-pages git@github.com:matschaffer/knife-solo.git #{clone}"
File.open(clone + "/index.html", 'w') do |f|
f.puts '---'
f.puts 'layout: default'
f.puts '---'
f.puts parsed_rdoc("README.rdoc")
end
rev = `git rev-parse HEAD`[0..7]
Dir.chdir(clone) do
sh "git commit --allow-empty -m 'Update index for v#{KnifeSolo.version} from README.rdoc rev #{rev}' index.html"
sh "git push origin gh-pages"
end
end
end
namespace :test do
Rake::TestTask.new(:performance) do |t|
t.libs << "test"
t.test_files = FileList['test/performance/*_test.rb']
end
Rake::TestTask.new(:integration) do |t|
t.libs << "test"
t.test_files = FileList['test/integration/*_test.rb']
end
Rake::TestTask.new(:units) do |t|
t.libs << "test"
t.test_files = FileList['test/*_test.rb']
end
desc 'Run both unit and integration tests'
task :all => [:units, :integration]
end
desc 'Alias for test:units'
task :test => 'test:units'
task :default => :test
task :default => 'manifest:verify'
task :release => :manifest
task :release => 'gh-pages' unless KnifeSolo.prerelease?