qed 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/History.rdoc +15 -0
  2. data/eg/hello_world.rdoc +15 -0
  3. data/eg/view_error.rdoc +21 -0
  4. data/eg/website.rdoc +12 -0
  5. data/lib/qed/advice.rb +4 -3
  6. data/lib/qed/command.rb +2 -3
  7. data/lib/qed/core_ext/instance_exec.rb +36 -0
  8. data/lib/qed/demo.rb +0 -1
  9. data/lib/qed/evaluator.rb +75 -36
  10. data/lib/qed/extensions/filefixtures.rb +27 -0
  11. data/lib/qed/extensions/shell_session.rb +2 -0
  12. data/lib/qed/meta/data.rb +29 -0
  13. data/lib/qed/meta/gemfile +10 -0
  14. data/{PROFILE → lib/qed/meta/profile} +0 -0
  15. data/lib/qed/parser.rb +148 -74
  16. data/lib/qed/reporter/abstract.rb +175 -25
  17. data/lib/qed/reporter/bullet.rb +14 -10
  18. data/lib/qed/reporter/dotprogress.rb +26 -9
  19. data/lib/qed/reporter/verbatim.rb +36 -15
  20. data/lib/qed/scope.rb +18 -8
  21. data/lib/qed/session.rb +2 -2
  22. data/meta/data.rb +29 -0
  23. data/meta/gemfile +10 -0
  24. data/{lib/qed/profile.yml → meta/profile} +0 -0
  25. data/{demo → qed}/01_demos.rdoc +7 -13
  26. data/{demo → qed}/02_advice.rdoc +7 -7
  27. data/{demo → qed}/03_helpers.rdoc +2 -2
  28. data/{demo → qed}/04_samples.rdoc +0 -0
  29. data/{demo → qed}/05_quote.rdoc +0 -0
  30. data/{demo → qed}/07_toplevel.rdoc +0 -0
  31. data/{demo → qed}/08_cross_script.rdoc +0 -2
  32. data/{demo → qed}/09_cross_script.rdoc +5 -3
  33. data/{demo → qed}/10_constant_lookup.rdoc +0 -0
  34. data/{demo → qed}/applique/constant.rb +0 -0
  35. data/{demo → qed}/applique/env.rb +0 -0
  36. data/{demo → qed}/applique/fileutils.rb +0 -0
  37. data/{demo → qed}/applique/markup.rb +0 -0
  38. data/{demo → qed}/applique/quote.rb +0 -0
  39. data/{demo → qed}/applique/toplevel.rb +0 -0
  40. data/{demo → qed}/helpers/advice.rb +0 -0
  41. data/{demo → qed}/helpers/sample.rb +0 -0
  42. data/{demo → qed}/helpers/toplevel.rb +0 -0
  43. data/{demo → qed}/samples/data.txt +0 -0
  44. data/{demo → qed}/samples/table.yml +0 -0
  45. metadata +43 -38
  46. data/REQUIRE +0 -7
  47. data/VERSION +0 -5
  48. data/lib/qed/package.yml +0 -5
  49. data/script/qedoc +0 -2
  50. data/script/test +0 -4
@@ -5,7 +5,7 @@ module QED
5
5
  # Scope is the context in which QED documents are run.
6
6
  #
7
7
  class Scope < Module
8
-
8
+
9
9
  #
10
10
  def self.new(applique, file)
11
11
  @_applique = applique
@@ -25,6 +25,7 @@ module QED
25
25
 
26
26
  extend self
27
27
  extend applique # TODO: extend or include applique or none ?
28
+ include applique
28
29
  #extend DSLi
29
30
 
30
31
  # TODO: custom extends?
@@ -34,19 +35,29 @@ module QED
34
35
 
35
36
  # This turns out to be the key to proper scoping.
36
37
  def __create_clean_binding_method__
37
- define_method(:__binding__) do
38
- @__binding__ ||= binding
39
- end
38
+ #define_method(:__binding__) do
39
+ # @__binding__ ||= binding
40
+ #end
41
+ module_eval %{
42
+ def __binding__
43
+ @__binding__ ||= binding
44
+ end
45
+ }
40
46
  end
41
47
 
42
- # Evaluate code in the context of the scope's special
43
- # binding.
48
+ # Expanded dirname of +file+.
49
+ def demo_directory
50
+ @_demo_directory ||= File.expand_path(File.dirname(@_file))
51
+ end
52
+
53
+ # Evaluate code in the context of the scope's special binding.
44
54
  def eval(code, binding=nil)
45
- super(code, binding || __binding__)
55
+ super(code, binding || __binding__, @_file)
46
56
  end
47
57
 
48
58
  # Define "when" advice.
49
59
  def When(*patterns, &procedure)
60
+ patterns = patterns.map{ |pat| pat == :text ? :desc : pat }
50
61
  @_applique.When(*patterns, &procedure)
51
62
  end
52
63
 
@@ -120,4 +131,3 @@ module QED
120
131
  end#class Scope
121
132
 
122
133
  end#module QED
123
-
@@ -123,7 +123,7 @@ module QED
123
123
  applique
124
124
  end
125
125
 
126
- #
126
+ # SCM: reverse order of applique so topmost directory comes first
127
127
  def applique_scripts
128
128
  locs = []
129
129
  files.each do |file|
@@ -135,7 +135,7 @@ module QED
135
135
  end
136
136
  end
137
137
  end
138
- envs = locs.map{ |loc| Dir[File.join(loc,'**/*.rb')] }
138
+ envs = locs.reverse.map{ |loc| Dir[File.join(loc,'**/*.rb')] }
139
139
  envs.flatten.compact.uniq
140
140
  end
141
141
 
@@ -0,0 +1,29 @@
1
+ Object.__send__(:remove_const, :VERSION) if Object.const_defined?(:VERSION) # becuase Ruby 1.8~ gets in the way
2
+
3
+ module QED
4
+
5
+ def self.__DIR__
6
+ File.dirname(__FILE__)
7
+ end
8
+
9
+ def self.gemfile
10
+ @gemfile ||= (
11
+ require 'yaml'
12
+ YAML.load(File.new(__DIR__ + '/gemfile'))
13
+ )
14
+ end
15
+
16
+ def self.profile
17
+ @profile ||= (
18
+ require 'yaml'
19
+ YAML.load(File.new(__DIR__ + '/profile'))
20
+ )
21
+ end
22
+
23
+ def self.const_missing(name)
24
+ key = name.to_s.downcase
25
+ gemfile[key] || profile[key] || super(name)
26
+ end
27
+
28
+ end
29
+
@@ -0,0 +1,10 @@
1
+ name: qed
2
+ version: 2.4.0
3
+ date: 2010-09-02
4
+
5
+ requires:
6
+ - ansi
7
+ - facets
8
+ - ae (test)
9
+ - syckle (build)
10
+
File without changes
@@ -1,16 +1,16 @@
1
1
  = Demonstrations
2
2
 
3
- == Standard Sections
3
+ == Steps
4
4
 
5
5
  QED demos are light-weight specification documents, highly suitable
6
6
  to interface-driven design. The documents are divided up into
7
- clauses separated by blank lines. Clauses that are flush to the
8
- left margin are always explanation or comment clauses. Indented
9
- clauses are always executable code.
7
+ steps separated by blank lines. Steps that are flush to the
8
+ left margin are always explanatory comments. Indented steps are
9
+ either executable code or plain text samples.
10
10
 
11
- Each code section is executed in order of appearance, within a
12
- rescue wrapper that captures any failures or errors. If neither
13
- a failure or error occur then the code gets a "pass".
11
+ Each step is executed in order of appearance within a rescue wrapper
12
+ that captures any failures or errors. If neither a failure or error
13
+ occur then the step gets a "pass".
14
14
 
15
15
  For example, the following passes.
16
16
 
@@ -29,12 +29,6 @@ And this would have raised a NameError.
29
29
  nobody_knows_method
30
30
  end
31
31
 
32
- == Neutral Code Blocks
33
-
34
- There is no means of specifying that a code clause is neutral code,
35
- i.e. that it should be executed but not tested. Thus far, such a
36
- feature has proven to be a YAGNI.
37
-
38
32
  == Defining Custom Assertions
39
33
 
40
34
  The context in which the QED code is run is a self-extended module, thus
@@ -85,12 +85,12 @@ an object just magically appear.
85
85
 
86
86
  == Event Targets
87
87
 
88
- There is a small set of advice targets that do not come before
89
- or after an event, rather they occur *upon* a particular event.
90
- These include +:load+ and +:unload+ for when a new helper is loaded;
91
- +:pass+, +:fail+ and +:error+ for when a code block passes, fails or
92
- raises an error; and +:text+ and +:code+ which target the immediate
93
- processing of a text block and code excecution.
88
+ There is a small set of advice targets that do not come before or after,
89
+ rather they occur *upon* a particular event. These include +:load+
90
+ and +:unload+ for when a new helper is loaded; +:pass+, +:fail+ and +:error+
91
+ for when a code block passes, fails or raises an error; and +:head+, +:desc:+,
92
+ +:code+ and +:data:+ which targets the immediate processing of a text block
93
+ and code excecution.
94
94
 
95
95
  These event targets can be advised by calling the +When+ method
96
96
  with the target type as an argument along with the code block
@@ -99,7 +99,7 @@ to be run when the event is triggered.
99
99
  x = []
100
100
 
101
101
  When(:text) do |section|
102
- section.commentary.scan(/^\*(.*?)$/) do |m|
102
+ section.text.scan(/^\*(.*?)$/) do |m|
103
103
  x << $1.strip
104
104
  end
105
105
  end
@@ -30,8 +30,8 @@ No where in the demonstration have we defined +pudding+, but
30
30
  it has been defined for us in the advice.rb helper script.
31
31
 
32
32
  We can also see that the generic When clause in our advice
33
- helper is keeping count of sections. Since the helper
34
- script was loaded two paragraphs section back, the curent count
33
+ helper is keeping count of decriptive paragraphs. Since the
34
+ helper script was loaded two paragraphs back, the next count
35
35
  will be 3.
36
36
 
37
37
  count.assert == 3
File without changes
File without changes
File without changes
@@ -23,5 +23,3 @@ And a method.
23
23
  "common"
24
24
  end
25
25
 
26
-
27
-
@@ -20,8 +20,10 @@ Method definitions also do not cross QED scripts.
20
20
  cross_script_method
21
21
  end
22
22
 
23
- Constants, on the other hand, like global variables do make
24
- their way across.
23
+ Since each demo is encapsulated in a separated class scope, constants also
24
+ do not make their way across.
25
25
 
26
- CROSS_SCRIPT_CONSTANT.assert == "cross?"
26
+ expect NameError do
27
+ CROSS_SCRIPT_CONSTANT
28
+ end
27
29
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
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: 3
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 2.3.0
10
+ version: 2.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Sawyer <transfire@gmail.com>
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-14 00:00:00 -04:00
18
+ date: 2010-09-02 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: ae
22
+ name: ansi
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
@@ -33,7 +33,7 @@ dependencies:
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: ansi
36
+ name: facets
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
@@ -47,7 +47,7 @@ dependencies:
47
47
  type: :runtime
48
48
  version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- name: facets
50
+ name: ae
51
51
  prerelease: false
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
@@ -58,7 +58,7 @@ dependencies:
58
58
  segments:
59
59
  - 0
60
60
  version: "0"
61
- type: :runtime
61
+ type: :development
62
62
  version_requirements: *id003
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: syckle
@@ -75,7 +75,7 @@ dependencies:
75
75
  type: :development
76
76
  version_requirements: *id004
77
77
  description: QED (Quality Ensured Demonstrations) is a TDD/BDD framework utilizing Literate Programming techniques.
78
- email:
78
+ email: ""
79
79
  executables:
80
80
  - qedoc
81
81
  - qed
@@ -86,35 +86,22 @@ extra_rdoc_files:
86
86
  files:
87
87
  - bin/qed
88
88
  - bin/qedoc
89
- - demo/01_demos.rdoc
90
- - demo/02_advice.rdoc
91
- - demo/03_helpers.rdoc
92
- - demo/04_samples.rdoc
93
- - demo/05_quote.rdoc
94
- - demo/07_toplevel.rdoc
95
- - demo/08_cross_script.rdoc
96
- - demo/09_cross_script.rdoc
97
- - demo/10_constant_lookup.rdoc
98
- - demo/applique/constant.rb
99
- - demo/applique/env.rb
100
- - demo/applique/fileutils.rb
101
- - demo/applique/markup.rb
102
- - demo/applique/quote.rb
103
- - demo/applique/toplevel.rb
104
- - demo/helpers/advice.rb
105
- - demo/helpers/sample.rb
106
- - demo/helpers/toplevel.rb
107
- - demo/samples/data.txt
108
- - demo/samples/table.yml
89
+ - eg/hello_world.rdoc
90
+ - eg/view_error.rdoc
91
+ - eg/website.rdoc
109
92
  - lib/qed/advice.rb
110
93
  - lib/qed/applique.rb
111
94
  - lib/qed/command.rb
112
95
  - lib/qed/config.rb
96
+ - lib/qed/core_ext/instance_exec.rb
113
97
  - lib/qed/demo.rb
114
98
  - lib/qed/evaluator.rb
115
- - lib/qed/package.yml
99
+ - lib/qed/extensions/filefixtures.rb
100
+ - lib/qed/extensions/shell_session.rb
101
+ - lib/qed/meta/data.rb
102
+ - lib/qed/meta/gemfile
103
+ - lib/qed/meta/profile
116
104
  - lib/qed/parser.rb
117
- - lib/qed/profile.yml
118
105
  - lib/qed/reporter/abstract.rb
119
106
  - lib/qed/reporter/bullet.rb
120
107
  - lib/qed/reporter/dotprogress.rb
@@ -128,20 +115,38 @@ files:
128
115
  - lib/qedoc/document/markup.rb
129
116
  - lib/qedoc/document/template.rhtml
130
117
  - lib/qedoc/document.rb
131
- - script/qedoc
132
- - script/test
118
+ - meta/data.rb
119
+ - meta/gemfile
120
+ - meta/profile
121
+ - qed/01_demos.rdoc
122
+ - qed/02_advice.rdoc
123
+ - qed/03_helpers.rdoc
124
+ - qed/04_samples.rdoc
125
+ - qed/05_quote.rdoc
126
+ - qed/07_toplevel.rdoc
127
+ - qed/08_cross_script.rdoc
128
+ - qed/09_cross_script.rdoc
129
+ - qed/10_constant_lookup.rdoc
130
+ - qed/applique/constant.rb
131
+ - qed/applique/env.rb
132
+ - qed/applique/fileutils.rb
133
+ - qed/applique/markup.rb
134
+ - qed/applique/quote.rb
135
+ - qed/applique/toplevel.rb
136
+ - qed/helpers/advice.rb
137
+ - qed/helpers/sample.rb
138
+ - qed/helpers/toplevel.rb
139
+ - qed/samples/data.txt
140
+ - qed/samples/table.yml
133
141
  - test/integration/topcode.rdoc
134
- - PROFILE
135
142
  - LICENSE
136
143
  - Diary.rdoc
137
144
  - README.rdoc
138
- - REQUIRE
139
- - VERSION
140
145
  - History.rdoc
141
146
  has_rdoc: true
142
147
  homepage: http://proutils.github.com/qed
143
- licenses: []
144
-
148
+ licenses:
149
+ - ""
145
150
  post_install_message:
146
151
  rdoc_options:
147
152
  - --title
data/REQUIRE DELETED
@@ -1,7 +0,0 @@
1
- runtime:
2
- - ae
3
- - ansi
4
- - facets
5
-
6
- development:
7
- - syckle
data/VERSION DELETED
@@ -1,5 +0,0 @@
1
- name : qed
2
- major: 2
3
- minor: 3
4
- patch: 0
5
- date : 2010-07-14
@@ -1,5 +0,0 @@
1
- name : qed
2
- major: 2
3
- minor: 3
4
- patch: 0
5
- date : 2010-07-14
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env sh
2
- qedoc -o doc/qedoc/ -t "QED Demonstrandum" qed/*.rdoc
@@ -1,4 +0,0 @@
1
- #!/usr/bin/ruby
2
- pass1 = system "ruby -Ilib -- bin/qed demo/*.rdoc"
3
- pass2 = system "ruby -Ilib -- bin/qed test/integration/*.rdoc"
4
- exit -1 unless pass1 && pass2