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/meta/{gemfile → package}
RENAMED
data/qed/04_samples.rdoc
CHANGED
@@ -6,12 +6,12 @@ When creating testable demonstrations, there are times when sizable
|
|
6
6
|
chunks of data are needed. It is convenient to store such data in
|
7
7
|
separate files. The +Data+ method makes is easy to utilize them.
|
8
8
|
|
9
|
-
Data('
|
9
|
+
Data('qed/samples/data.txt').assert =~ /dolor/
|
10
10
|
|
11
11
|
The +Data+ method can also take a block which passes the data
|
12
12
|
as the block's only argument.
|
13
13
|
|
14
|
-
Data('
|
14
|
+
Data('qed/samples/data.txt') do |data|
|
15
15
|
data.assert =~ /dolor/
|
16
16
|
end
|
17
17
|
|
@@ -32,7 +32,7 @@ the coded step. Consider the following example.
|
|
32
32
|
Every row in the {table.yml table}[table.yml] will be assigned to
|
33
33
|
the block parameters and run through the subsequent assertion.
|
34
34
|
|
35
|
-
Table '
|
35
|
+
Table 'qed/samples/table.yml' do |x, y|
|
36
36
|
x.upcase.assert == y
|
37
37
|
end
|
38
38
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Thomas Sawyer <transfire@gmail.com>
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-07 01:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
segments:
|
59
59
|
- 0
|
60
60
|
version: "0"
|
61
|
-
type: :
|
61
|
+
type: :runtime
|
62
62
|
version_requirements: *id003
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: syckle
|
@@ -92,14 +92,13 @@ files:
|
|
92
92
|
- lib/qed/advice.rb
|
93
93
|
- lib/qed/applique.rb
|
94
94
|
- lib/qed/command.rb
|
95
|
-
- lib/qed/
|
96
|
-
- lib/qed/core_ext/instance_exec.rb
|
95
|
+
- lib/qed/core_ext.rb
|
97
96
|
- lib/qed/demo.rb
|
98
97
|
- lib/qed/evaluator.rb
|
99
|
-
- lib/qed/
|
100
|
-
- lib/qed/
|
98
|
+
- lib/qed/helpers/file_fixtures.rb
|
99
|
+
- lib/qed/helpers/shell_session.rb
|
101
100
|
- lib/qed/meta/data.rb
|
102
|
-
- lib/qed/meta/
|
101
|
+
- lib/qed/meta/package
|
103
102
|
- lib/qed/meta/profile
|
104
103
|
- lib/qed/parser.rb
|
105
104
|
- lib/qed/reporter/abstract.rb
|
@@ -116,7 +115,7 @@ files:
|
|
116
115
|
- lib/qedoc/document/template.rhtml
|
117
116
|
- lib/qedoc/document.rb
|
118
117
|
- meta/data.rb
|
119
|
-
- meta/
|
118
|
+
- meta/package
|
120
119
|
- meta/profile
|
121
120
|
- qed/01_demos.rdoc
|
122
121
|
- qed/02_advice.rdoc
|
@@ -140,7 +139,6 @@ files:
|
|
140
139
|
- qed/samples/table.yml
|
141
140
|
- test/integration/topcode.rdoc
|
142
141
|
- LICENSE
|
143
|
-
- Diary.rdoc
|
144
142
|
- README.rdoc
|
145
143
|
- History.rdoc
|
146
144
|
has_rdoc: true
|
data/Diary.rdoc
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
= Diary
|
2
|
-
|
3
|
-
== 2010-06-06 / HTML Won't Do
|
4
|
-
|
5
|
-
There have proven to be significant issues associated with translating markup to HTML and having QED evalute the HTML, rather than plain text. To begin with different markup engines translate special characeters in differnt ways. RDoc for instance will translate astrisks around a word into 'b' tags, whereas Textile translates them to 'em' tags. Still other characters are translated into HTML escape codes, eg. <code>\&#8216;</code>. There are a variety of these and each markup language will translate them according to it's own rules (or not at all). This means pattern matches in advice have to take these translations into account. Instead of matching on an asterisk we might need to match on +<b>+. A minor naggle perhaps, but it means being exceptionally aware of all translaterions that occur, and moreover, that applique may not be portable across markup languages.
|
6
|
-
|
7
|
-
There are other discrepencies as well such as the translation of code blocks to \<pre> vs. \<pre>\<code> tags, but all this aside, while perhaps annoying, it can be managed. A normalization procedure can help mitage the issues. However, the ultimate problem is your classic YAGNI, the fact that little, if anything, is gained by using HTML as the defacto document format. And this is simply because everyone will write there documents in a text-based markup, none of which fully support the HTML that QED could utilize. For instance RDoc and Markdown do not have a notation for tables (although extended Markdown might). Textile does not have a clean notation for \<pre> blocks --you have to use \<pre>! And ASCIIDoc, while a very capable documentation system has a verbose syntax that is not particullary suited to reading in plain text. Perhaps if all the available markdown languages were equally as capable, it would be worth the additional effort. But lacking this I beleive more advantage can ultimately be gained by allowing QED to have it's own markup syntax one suited best to it's purpose.
|
8
|
-
|
9
|
-
|
10
|
-
== 2010-02-03 / Some Determinations
|
11
|
-
|
12
|
-
In the end I have decided on loading helpers on the fly via
|
13
|
-
special AHREF links. We still need a plan for loading global
|
14
|
-
helpers though.
|
15
|
-
|
16
|
-
Also, per last entry, Before and After stays b/c When doesn't
|
17
|
-
quite cover the usecase. However, I definately encourge the use
|
18
|
-
of helper methods in place of Before and After clauses.
|
19
|
-
|
20
|
-
|
21
|
-
== 2010-01-28 / Before and After
|
22
|
-
|
23
|
-
Wouldn't it better to allow helpers to define methods, which
|
24
|
-
can be called in the steps for setting things up, rather than
|
25
|
-
using "magic" Before and After clauses which give no indication
|
26
|
-
that something has happened?
|
27
|
-
|
28
|
-
= Examples
|
29
|
-
|
30
|
-
== Example #1
|
31
|
-
|
32
|
-
For example #1 we will use example1[helper/example1] support file.
|
33
|
-
First we need to prepare the example. It is a complex process, so we
|
34
|
-
have made a special method for it. See the helper[helper/example1]
|
35
|
-
file for details.
|
36
|
-
|
37
|
-
ex = prepare_example1
|
38
|
-
|
39
|
-
Now we can show that the example is hip.
|
40
|
-
|
41
|
-
ex.assert.hip == true
|
42
|
-
|
43
|
-
So we could get rid of Before(:step) and After(:step) definitions this
|
44
|
-
way, and it's not such a big loss, b/c we still have #When, and
|
45
|
-
After(:Step) is of very rare utility which can be worked around.
|
46
|
-
|
47
|
-
|
48
|
-
== 2010-01-30 / The Best Way to Handle Helpers
|
49
|
-
|
50
|
-
1) Should helpers be stored in a special location relative
|
51
|
-
to the demo file, from which all helpers in that location
|
52
|
-
are loaded automatically. This simplifies loading, but it
|
53
|
-
makes support for per-demo helpers more awkward.
|
54
|
-
This option also means taking special consideration for
|
55
|
-
helpers when documenting --any reference to them will have
|
56
|
-
to be tacked-on rather then be an integral part of the document
|
57
|
-
itself.
|
58
|
-
|
59
|
-
We might do something like this:
|
60
|
-
|
61
|
-
demos/
|
62
|
-
demo1.rdoc
|
63
|
-
demo1/
|
64
|
-
helper.rb
|
65
|
-
demo2.rdoc
|
66
|
-
demo2/
|
67
|
-
helper.rb
|
68
|
-
share/
|
69
|
-
helper.rb
|
70
|
-
|
71
|
-
Such that demo1/helper.rb only applies to demo1.rdoc, and
|
72
|
-
likewise for demo2, but both use share/helper.rb.
|
73
|
-
|
74
|
-
2) Or, should the demo be able to specify which helpers to
|
75
|
-
load via href links. This allows full flexability it selecting
|
76
|
-
behavior for the demo. It also means the documentation will
|
77
|
-
have references to helpers built-in (although they will have
|
78
|
-
to be augmented when documenting to ensure the hrefs link
|
79
|
-
correctly). But session-oriented advice doesn't make much
|
80
|
-
sense in a per-demo context. We could ignore that, or place
|
81
|
-
session advice in a separate location. While this option
|
82
|
-
is more flexible, it also means demos may be more difficult
|
83
|
-
to follow, because one must scan the links in the document
|
84
|
-
to determine which helpers are being used.
|
85
|
-
|
86
|
-
An example demo might look like:
|
87
|
-
|
88
|
-
== Examples
|
89
|
-
|
90
|
-
== Example 1
|
91
|
-
|
92
|
-
For example #1 we will use example1[helper/example1] support file.
|
93
|
-
|
94
|
-
... and so on ...
|
95
|
-
|
96
|
-
== Example 2
|
97
|
-
|
98
|
-
For example #2 we will use example2[helper/example2] support file.
|
99
|
-
|
100
|
-
... and so on ...
|
101
|
-
|
102
|
-
In which case it seems prudent to load these helpers as they are
|
103
|
-
evaluated, rather than all at once at the start. However this insinuates
|
104
|
-
that there is only one before and after advice at a time, and when
|
105
|
-
would before advice for the entire demo run, upon loading the helper?
|
106
|
-
|
107
|
-
I think it would be better to use When clauses. Then the helpers could
|
108
|
-
be loaded all at once at the start and it would not matter. And instead of
|
109
|
-
<code>Before do</code> use <code>When /*/ do</code> for general before
|
110
|
-
clauses.
|
111
|
-
|
112
|
-
However, if referenced helpers are to be loaded all at once at the start,
|
113
|
-
it seems almost silly to even allow helpers to be referenced in the
|
114
|
-
document. With the exception of using them as footnotes, it conveys too
|
115
|
-
much positional indication. So either load them when they are encountered,
|
116
|
-
or use option #1.
|
117
|
-
|
data/lib/qed/config.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
module QED
|
2
|
-
|
3
|
-
=begin
|
4
|
-
# Setup global configuration.
|
5
|
-
#
|
6
|
-
# QED.config do
|
7
|
-
#
|
8
|
-
# Before(:session) do
|
9
|
-
# # ...
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
# After(:session) do
|
13
|
-
# # ...
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
def self.configure(&block)
|
19
|
-
@config ||= Profile.new #(nil)
|
20
|
-
@config.instance_eval(&block) if block
|
21
|
-
@config
|
22
|
-
end
|
23
|
-
=end
|
24
|
-
|
25
|
-
#
|
26
|
-
class Profile
|
27
|
-
|
28
|
-
#
|
29
|
-
def initialize
|
30
|
-
#@local = ['test/demos', 'demos', 'qed']
|
31
|
-
|
32
|
-
@before = { :session=>[], :demo=>[], :step=>[] }
|
33
|
-
@after = { :session=>[], :demo=>[], :step=>[] }
|
34
|
-
|
35
|
-
#if file = Dir.glob('{.,}config/qed.{yml,yaml}').first
|
36
|
-
# YAML.load(File.new(file)).each do |k,v|
|
37
|
-
# __send__("#{k}=", v)
|
38
|
-
# end
|
39
|
-
#end
|
40
|
-
end
|
41
|
-
|
42
|
-
#
|
43
|
-
#attr_accessor :local
|
44
|
-
|
45
|
-
#
|
46
|
-
def Before(type=:session, &procedure)
|
47
|
-
@before[type] << procedure if procedure
|
48
|
-
@before[type]
|
49
|
-
end
|
50
|
-
|
51
|
-
#
|
52
|
-
def After(type=:session, &procedure)
|
53
|
-
@after[type] << procedure if procedure
|
54
|
-
@after[type]
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# This extension provides a simple means for
|
2
|
-
# create file-system fixtures.
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
# Set global temporary directory.
|
7
|
-
$tmpdir = 'tmp'
|
8
|
-
|
9
|
-
#
|
10
|
-
def copy_fixture(name, tmpdir=$tmpdir)
|
11
|
-
FileUtils.mkdir(tmpdir)
|
12
|
-
srcdir = File.join(demo_directory, 'fixtures', name)
|
13
|
-
paths = Dir.glob(File.join(srcdir, '**', '*'), File::FNM_DOTMATCH)
|
14
|
-
paths.each do |path|
|
15
|
-
basename = File.basename(path)
|
16
|
-
next if basename == '.'
|
17
|
-
next if basename == '..'
|
18
|
-
dest = File.join(tmpdir, path.sub(srcdir+'/', ''))
|
19
|
-
if File.directory?(path)
|
20
|
-
FileUtils.mkdir(dest)
|
21
|
-
else
|
22
|
-
text = ERB.new(File.read(path)).result
|
23
|
-
File.open(dest, 'w'){ |f| f << text }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|