-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rulebook
122 lines (96 loc) · 2.13 KB
/
Rulebook
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
#!/usr/bin/env ruby
# global ignore
ignore 'pages', 'doc', 'site', 'log'
##
# Default
#
ruleset :default => [:index, :manifest, :demo]
##
# Release
#
# TODO: How to force all tests to be run?
#
ruleset :release => [:index, :demo, :manifest, :doc]
#
# QED Demos
#
ruleset :demo do
desc "run demos"
rule 'demo/**/*.md' => :demo
rule 'lib/**/*.rb' => :demo_all
rule 'demo/test_helper.rb' => :demo_all
def demo(*files)
#files = ["demo/**/*.md"] if files.empty?
shell "bundle exec qed " + files.join(" ")
end
def demo_all
demo "demo/**/*.md"
end
end
#
# Unit Testing
#
ruleset :test do
desc "run unit tests"
rule 'test/case_*.rb' => :test
rule 'test/helper.rb' => :test_all
rule /^lib\/(.*?)\.rb$/ => :test_match
rule /^lib\/ergo\/(.*?)\.rb$/ => :test_match
def test(*paths)
shell "ruby-test #{gem_opt} -Ilib:test #{paths.flatten.join(' ')}"
end
def test_all
test(*Dir['test/**/case_*.rb'])
end
def test_match(m)
test("test/case_#{m[1]}")
end
def gem_opt
defined?(::Gem) ? "-rubygems" : ""
end
end
#
# Update .index file
#
ruleset :index do
desc "update index file"
rule 'INDEX.yml' do
shell "index -u INDEX.yml"
end
end
#
# Update Manifest - this uses the `mast` commandline tool.
#
ruleset :manifest do
desc "update manifest"
rule :manifest_outofdate? => :update_manifest
def manifest_outofdate?
! system "mast --quiet --verify"
end
def update_manifest
shell "mast -u"
end
end
#
# Shomen documentation. (NOT USED PRESENTLY)
#
ruleset :doc do
desc "generate shomen documentation"
rule :shomen_docs_needed? => :update_shomen_docs
def shomen_docs_needed?
files = `mast -b --no-head`.split("\n")
doc_file = "web/doc/#{project.name}-#{project.version}.json"
! FileUtils.uptodate?(doc_file, files)
end
def update_shomen_docs
shell "shomen-yard > web/doc/#{project.name}-#{project.version}.json"
end
end
# Access to project metadata, if needed.
def project
@project ||= (
require 'yaml'
index = YAML.load_file('.index')
Struct.new('Project', *index.keys).new(*index.values)
)
end