qed 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +19 -3
- data/README.rdoc +8 -5
- data/lib/qed/advice.rb +13 -7
- data/lib/qed/applique.rb +65 -31
- data/lib/qed/command.rb +107 -71
- data/lib/qed/{core_ext/instance_exec.rb → core_ext.rb} +2 -0
- data/lib/qed/demo.rb +49 -34
- data/lib/qed/evaluator.rb +110 -3
- data/lib/qed/helpers/file_fixtures.rb +35 -0
- data/lib/qed/{extensions → helpers}/shell_session.rb +0 -0
- data/lib/qed/meta/data.rb +8 -10
- data/lib/qed/meta/{gemfile → package} +3 -3
- data/lib/qed/reporter/abstract.rb +5 -1
- data/lib/qed/reporter/verbatim.rb +3 -3
- data/lib/qed/scope.rb +56 -14
- data/lib/qed/session.rb +4 -62
- data/lib/qedoc/document.rb +33 -32
- data/lib/qedoc/document/markup.rb +46 -41
- data/lib/qedoc/document/template.rhtml +33 -33
- data/meta/data.rb +8 -10
- data/meta/{gemfile → package} +3 -3
- data/qed/04_samples.rdoc +3 -3
- metadata +10 -12
- data/Diary.rdoc +0 -117
- data/lib/qed/config.rb +0 -60
- data/lib/qed/extensions/filefixtures.rb +0 -27
data/lib/qed/session.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
module QED
|
2
2
|
|
3
3
|
#require 'qed/config'
|
4
|
-
require 'qed/applique'
|
5
4
|
require 'qed/demo'
|
6
5
|
|
7
|
-
# = Runtime Session
|
8
|
-
#
|
9
6
|
# The Session class encapsulates a set of demonstrations
|
10
7
|
# and the procedure for looping through them and running
|
11
8
|
# each in turn.
|
@@ -33,17 +30,6 @@ module QED
|
|
33
30
|
@mode = options[:mode]
|
34
31
|
@trace = options[:trace] || false
|
35
32
|
@format = options[:format] || :dotprogress
|
36
|
-
|
37
|
-
#options.each do |k,v|
|
38
|
-
# __send__("#{k}=", v) if v
|
39
|
-
#end
|
40
|
-
|
41
|
-
@applique = create_applique
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
def applique
|
46
|
-
@applique
|
47
33
|
end
|
48
34
|
|
49
35
|
# Top-level configuration.
|
@@ -66,14 +52,9 @@ module QED
|
|
66
52
|
)
|
67
53
|
end
|
68
54
|
|
69
|
-
#
|
70
|
-
#def scope
|
71
|
-
# @scope ||= Scope.new
|
72
|
-
#end
|
73
|
-
|
74
|
-
# TODO: switch order of applique and file.
|
55
|
+
# Returns an Array of Demo instances.
|
75
56
|
def demos
|
76
|
-
@demos ||= files.map{ |file| Demo.new(file,
|
57
|
+
@demos ||= files.map{ |file| Demo.new(file, :mode=>mode) }
|
77
58
|
end
|
78
59
|
|
79
60
|
#
|
@@ -85,13 +66,11 @@ module QED
|
|
85
66
|
def run
|
86
67
|
#profile.before_session(self)
|
87
68
|
reporter.before_session(self)
|
88
|
-
#demos.each do |demo|
|
89
|
-
# script = Demo.new(demo, report)
|
90
69
|
demos.each do |demo|
|
91
70
|
demo.run(*observers)
|
92
|
-
#pid = fork {
|
71
|
+
#pid = fork { demo.run(*observers) }
|
93
72
|
#Process.detach(pid)
|
94
|
-
|
73
|
+
end
|
95
74
|
reporter.after_session(self)
|
96
75
|
#profile.after_session(self)
|
97
76
|
end
|
@@ -103,43 +82,6 @@ module QED
|
|
103
82
|
# end
|
104
83
|
#end
|
105
84
|
|
106
|
-
# TODO: associate scripts to there applique ?
|
107
|
-
def create_applique
|
108
|
-
applique = Applique.new
|
109
|
-
#eval "include QED::DomainLanguage", TOPLEVEL_BINDING
|
110
|
-
applique_scripts.each do |file|
|
111
|
-
#next if @loadlist.include?(file)
|
112
|
-
#case File.extname(file)
|
113
|
-
#when '.rb'
|
114
|
-
# since scope is just TOPLEVEL now
|
115
|
-
#require(file)
|
116
|
-
applique.module_eval(File.read(file), file)
|
117
|
-
#eval(File.read(file), scope.__binding__, file) # TODO: for each script!? Nay.
|
118
|
-
#else
|
119
|
-
# Script.new(file, scope).run
|
120
|
-
#end
|
121
|
-
#@loadlist << file
|
122
|
-
end
|
123
|
-
applique
|
124
|
-
end
|
125
|
-
|
126
|
-
# SCM: reverse order of applique so topmost directory comes first
|
127
|
-
def applique_scripts
|
128
|
-
locs = []
|
129
|
-
files.each do |file|
|
130
|
-
Dir.ascend(File.dirname(file)) do |path|
|
131
|
-
break if path == Dir.pwd
|
132
|
-
dir = File.join(path, 'applique')
|
133
|
-
if File.directory?(dir)
|
134
|
-
locs << dir
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
envs = locs.reverse.map{ |loc| Dir[File.join(loc,'**/*.rb')] }
|
139
|
-
envs.flatten.compact.uniq
|
140
|
-
end
|
141
|
-
|
142
85
|
end#class Session
|
143
86
|
|
144
87
|
end#module QED
|
145
|
-
|
data/lib/qedoc/document.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'fileutils'
|
3
|
-
require '
|
4
|
-
require 'nokogiri'
|
3
|
+
#require 'nokogiri'
|
5
4
|
|
6
5
|
module QED
|
7
6
|
|
@@ -46,8 +45,10 @@ module QED
|
|
46
45
|
# Demo files.
|
47
46
|
def demo_files
|
48
47
|
@demo_files ||= (
|
49
|
-
glob = paths.map
|
50
|
-
|
48
|
+
glob = paths.map do |f|
|
49
|
+
File.directory?(f) ? Dir[File.join(f,'**/*')] : Dir[f]
|
50
|
+
end
|
51
|
+
glob = glob.flatten.select do |f|
|
51
52
|
File.file?(f) && f !~ /fixtures\/|helpers\// && f !~ /\.rb$/
|
52
53
|
end
|
53
54
|
glob.sort
|
@@ -81,18 +82,18 @@ module QED
|
|
81
82
|
#iotext = strio.string
|
82
83
|
#strio.close
|
83
84
|
|
84
|
-
|
85
|
-
|
85
|
+
ext = File.extname(file)
|
86
|
+
txt = File.read(file)
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
if ext == '.qed'
|
89
|
+
ext = file_type(txt)
|
90
|
+
end
|
90
91
|
|
91
|
-
text = Tilt.new(file).render
|
92
|
-
html = Nokogiri::HTML(text)
|
93
|
-
body = html.css("body")
|
92
|
+
#text = Tilt.new(file).render
|
93
|
+
#html = Nokogiri::HTML(text)
|
94
|
+
#body = html.css("body")
|
94
95
|
|
95
|
-
=
|
96
|
+
text = ""
|
96
97
|
case ext
|
97
98
|
#when '.qed'
|
98
99
|
# require_qedoc
|
@@ -100,17 +101,17 @@ module QED
|
|
100
101
|
# text << markup.to_html
|
101
102
|
when '.rd', '.rdoc'
|
102
103
|
require_rdoc
|
103
|
-
|
104
|
-
|
104
|
+
require_qedoc
|
105
|
+
markup = Markup.new(txt)
|
106
|
+
text << markup.to_html
|
105
107
|
#text << markup.convert(iotext, formatter)
|
106
108
|
when '.md', '.markdown'
|
107
109
|
require_rdiscount
|
108
110
|
markdown = RDiscount.new(txt)
|
109
111
|
text << markdown.to_html
|
110
112
|
end
|
111
|
-
=end
|
112
113
|
|
113
|
-
output << "#{
|
114
|
+
output << "#{text}\n"
|
114
115
|
end
|
115
116
|
|
116
117
|
temp = Template.new(template, output, title, css)
|
@@ -155,24 +156,24 @@ module QED
|
|
155
156
|
private
|
156
157
|
|
157
158
|
#
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
159
|
+
def file_type(text)
|
160
|
+
rdoc = text.index(/^\=/)
|
161
|
+
markdown = text.index(/^\#/)
|
162
|
+
if markdown && rdoc
|
163
|
+
rdoc < markdown ? '.rdoc' : '.markdown'
|
164
|
+
elsif rdoc
|
165
|
+
'.rdoc'
|
166
|
+
elsif markdown
|
167
|
+
'.markdown'
|
168
|
+
else # fallback to rdoc
|
169
|
+
'.rdoc'
|
170
|
+
end
|
171
|
+
end
|
171
172
|
|
172
173
|
#
|
173
174
|
def require_qedoc
|
174
|
-
@
|
175
|
-
require '
|
175
|
+
@require_qedoc ||= (
|
176
|
+
require 'qedoc/document/markup'
|
176
177
|
true
|
177
178
|
)
|
178
179
|
end
|
@@ -1,53 +1,58 @@
|
|
1
|
-
require 'rdoc/markup
|
2
|
-
require 'rdoc/markup/
|
1
|
+
require 'rdoc/markup'
|
2
|
+
require 'rdoc/markup/to_html'
|
3
3
|
|
4
4
|
module QED
|
5
|
-
class Document
|
6
|
-
|
7
|
-
# = QED Document Markup
|
8
|
-
#
|
9
|
-
# QED Document Markup is based on RDoc's SimpleMarkup format but adds
|
10
|
-
# some additional features.
|
11
|
-
#
|
12
|
-
# * `[no-spaces]` produces <code>[no-space]</code>.
|
13
|
-
#
|
14
|
-
class Markup
|
15
|
-
|
16
|
-
def initialize(text, options={})
|
17
|
-
@text = text
|
18
|
-
end
|
19
5
|
|
20
|
-
|
21
|
-
parser.convert(@text, formatter)
|
22
|
-
end
|
6
|
+
class Document
|
23
7
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
8
|
+
# = QED Document Markup
|
9
|
+
#
|
10
|
+
# QED Document Markup is based on RDoc's SimpleMarkup format but adds
|
11
|
+
# some additional features.
|
12
|
+
#
|
13
|
+
# * `[no-spaces]` produces <code>[no-space]</code>.
|
14
|
+
#
|
15
|
+
# FIXME: Can't get `brackets` to work.
|
16
|
+
class Markup
|
34
17
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
18
|
+
def initialize(text, options={})
|
19
|
+
@text = text
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_html
|
23
|
+
parser.convert(@text, formatter)
|
24
|
+
end
|
42
25
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
def parser
|
27
|
+
@parser ||= (
|
28
|
+
m = RDoc::Markup.new
|
29
|
+
#p.add_word_pair("{", "}", :STRIKE)
|
30
|
+
#p.add_html("no", :STRIKE)
|
31
|
+
#p.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
|
32
|
+
#m.add_word_pair('`', '`', :CODE)
|
33
|
+
m.add_special(/\`(\b.*?)\`/, :CODE)
|
34
|
+
m
|
35
|
+
)
|
47
36
|
end
|
37
|
+
|
38
|
+
def formatter
|
39
|
+
@formatter ||= (
|
40
|
+
f = ToHTML.new
|
41
|
+
#f.add_tag(:STRIKE, "<strike>", "</strike>")
|
42
|
+
f.add_tag(:CODE, "<code>", "</code>")
|
43
|
+
f
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Formatter
|
48
|
+
class ToHTML < RDoc::Markup::ToHtml
|
49
|
+
def handle_special_CODE(special)
|
50
|
+
"<code>" + special.text.sub('`','').chomp('`') + "</code>"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
48
54
|
end
|
49
55
|
|
50
56
|
end
|
51
57
|
|
52
58
|
end
|
53
|
-
end
|
@@ -7,60 +7,60 @@
|
|
7
7
|
<style>
|
8
8
|
#container{ margin: 0 auto; width: 800px; }
|
9
9
|
|
10
|
-
/* Debug borders */
|
10
|
+
/* Debug borders */
|
11
11
|
/* p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { border: 1px solid red; } */
|
12
|
-
|
13
|
-
body { font-size: 14px; line-height: 20px; margin: 1em 5% 1em 5%; font-family: Verdana, Arial, Helvetica, sans-serif; }
|
14
|
-
a { color: #336; text-decoration: underline; }
|
15
|
-
a:visited { color: #334; }
|
16
|
-
em { font-style: italic; }
|
17
|
-
strong { font-weight: bold; }
|
18
|
-
tt { color: navy; }
|
19
|
-
|
20
|
-
h1, h2, h3, h4, h5, h6 { color: #223; margin-top: 1.2em; margin-bottom: 0.5em; line-height: 1.3; }
|
12
|
+
|
13
|
+
body { font-size: 14px; line-height: 20px; margin: 1em 5% 1em 5%; font-family: Verdana, Arial, Helvetica, sans-serif; }
|
14
|
+
a { color: #336; text-decoration: underline; }
|
15
|
+
a:visited { color: #334; }
|
16
|
+
em { font-style: italic; }
|
17
|
+
strong { font-weight: bold; }
|
18
|
+
tt { color: navy; }
|
19
|
+
|
20
|
+
h1, h2, h3, h4, h5, h6 { color: #223; margin-top: 1.2em; margin-bottom: 0.5em; line-height: 1.3; }
|
21
21
|
h1 { border-bottom: 2px solid silver; }
|
22
|
-
h2 { border-bottom: 2px solid silver; padding-top: 0.5em; }
|
22
|
+
h2 { border-bottom: 2px solid silver; padding-top: 0.5em; }
|
23
23
|
|
24
|
-
hr { color: #ccc; margin-top: 1.6em; }
|
24
|
+
hr { color: #ccc; margin-top: 1.6em; }
|
25
25
|
|
26
|
-
p { color: #222; text-align: justify; margin-top: 0.5em; margin-bottom: 0.5em; line-height: 1.4em; }
|
26
|
+
p { color: #222; text-align: justify; margin-top: 0.5em; margin-bottom: 0.5em; line-height: 1.4em; }
|
27
27
|
|
28
28
|
/* pre { padding: 10; margin: 0; font-family: monospace; font-size: 0.9em; } */
|
29
29
|
|
30
30
|
pre.pass { color: green; }
|
31
31
|
pre.fail { color: red; }
|
32
32
|
pre.error { color: red; font-weight: bold; }
|
33
|
-
|
34
|
-
span#author { color: #527bbd; font-weight: bold; font-size: 1.1em; }
|
33
|
+
|
34
|
+
span#author { color: #527bbd; font-weight: bold; font-size: 1.1em; }
|
35
35
|
span#email { }
|
36
36
|
span#revision { }
|
37
|
-
|
37
|
+
|
38
38
|
div#footer { font-size: small; border-top: 2px solid silver; padding-top: 0.5em; margin-top: 4.0em; }
|
39
39
|
div#footer-text { float: left; padding-bottom: 0.5em; }
|
40
|
-
div#footer-badges { float: right; padding-bottom: 0.5em; }
|
40
|
+
div#footer-badges { float: right; padding-bottom: 0.5em; }
|
41
41
|
|
42
42
|
/* Block element content. */
|
43
|
-
div.content { padding: 0; }
|
43
|
+
div.content { padding: 0; }
|
44
44
|
|
45
|
-
/* Block element titles. */
|
46
|
-
h1.title { font-weight: bold; text-align: left; font-size: 3em; margin-top: 1.0em; margin-bottom: 0.5em; }
|
45
|
+
/* Block element titles. */
|
46
|
+
h1.title { font-weight: bold; text-align: left; font-size: 3em; margin-top: 1.0em; margin-bottom: 0.5em; }
|
47
47
|
|
48
|
-
/* Block element titles. */
|
49
|
-
div.title, caption.title { font-weight: bold; text-align: left; margin-top: 1.0em; margin-bottom: 0.5em; }
|
50
|
-
div.title + * { margin-top: 0; }
|
51
|
-
td div.title:first-child { margin-top: 0.0em; }
|
52
|
-
div.content div.title:first-child { margin-top: 0.0em; }
|
53
|
-
div.content + div.title { margin-top: 0.0em; }
|
54
|
-
div.sidebarblock > div.content { background: #ffffee; border: 1px solid silver; padding: 0.5em; }
|
48
|
+
/* Block element titles. */
|
49
|
+
div.title, caption.title { font-weight: bold; text-align: left; margin-top: 1.0em; margin-bottom: 0.5em; }
|
50
|
+
div.title + * { margin-top: 0; }
|
51
|
+
td div.title:first-child { margin-top: 0.0em; }
|
52
|
+
div.content div.title:first-child { margin-top: 0.0em; }
|
53
|
+
div.content + div.title { margin-top: 0.0em; }
|
54
|
+
div.sidebarblock > div.content { background: #ffffee; border: 1px solid silver; padding: 0.5em; }
|
55
55
|
|
56
|
-
img { border-style: none; }
|
56
|
+
img { border-style: none; }
|
57
57
|
|
58
|
-
dl { margin-top: 0.8em; margin-bottom: 0.8em; }
|
59
|
-
dt { margin-top: 0.5em; margin-bottom: 0; font-style: italic; }
|
60
|
-
dd > *:first-child { margin-top: 0; }
|
61
|
-
ul, ol { list-style-position: outside; }
|
58
|
+
dl { margin-top: 0.8em; margin-bottom: 0.8em; }
|
59
|
+
dt { margin-top: 0.5em; margin-bottom: 0; font-style: italic; }
|
60
|
+
dd > *:first-child { margin-top: 0; }
|
61
|
+
ul, ol { list-style-position: outside; }
|
62
62
|
|
63
|
-
thead { font-weight: bold; }
|
63
|
+
thead { font-weight: bold; }
|
64
64
|
tfoot { font-weight: bold; }
|
65
65
|
|
66
66
|
*{margin:0;padding:0;}
|
data/meta/data.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
|
-
Object.__send__(:remove_const, :VERSION) if Object.const_defined?(:VERSION) # becuase Ruby 1.8~ gets in the way
|
2
|
-
|
3
1
|
module QED
|
4
2
|
|
5
|
-
|
6
|
-
File.dirname(__FILE__)
|
7
|
-
end
|
3
|
+
DIRECTORY = File.dirname(__FILE__)
|
8
4
|
|
9
|
-
def self.
|
10
|
-
@
|
5
|
+
def self.package
|
6
|
+
@package ||= (
|
11
7
|
require 'yaml'
|
12
|
-
YAML.load(File.new(
|
8
|
+
YAML.load(File.new(DIRECTORY + '/package'))
|
13
9
|
)
|
14
10
|
end
|
15
11
|
|
16
12
|
def self.profile
|
17
13
|
@profile ||= (
|
18
14
|
require 'yaml'
|
19
|
-
YAML.load(File.new(
|
15
|
+
YAML.load(File.new(DIRECTORY + '/profile'))
|
20
16
|
)
|
21
17
|
end
|
22
18
|
|
23
19
|
def self.const_missing(name)
|
24
20
|
key = name.to_s.downcase
|
25
|
-
|
21
|
+
package[key] || profile[key] || super(name)
|
26
22
|
end
|
27
23
|
|
28
24
|
end
|
29
25
|
|
26
|
+
# becuase Ruby 1.8~ gets in the way
|
27
|
+
Object.__send__(:remove_const, :VERSION) if Object.const_defined?(:VERSION)
|