qed 2.9.0 → 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.index +69 -0
  2. data/.yardopts +3 -2
  3. data/{HISTORY.rdoc → HISTORY.md} +44 -32
  4. data/LICENSE.txt +25 -0
  5. data/{README.rdoc → README.md} +60 -51
  6. data/{qed/01_demos.rdoc → demo/01_demos.md} +3 -3
  7. data/{qed/02_advice.rdoc → demo/02_advice.md} +17 -17
  8. data/{qed/03_helpers.rdoc → demo/03_helpers.md} +10 -10
  9. data/{qed/04_samples.rdoc → demo/04_samples.md} +5 -5
  10. data/{qed/05_quote.rdoc → demo/05_quote.md} +7 -7
  11. data/{qed/07_toplevel.rdoc → demo/07_toplevel.md} +11 -11
  12. data/{qed/08_cross_script.rdoc → demo/08_cross_script.md} +9 -9
  13. data/{qed/09_cross_script.rdoc → demo/09_cross_script.md} +13 -14
  14. data/demo/10_constant_lookup.md +16 -0
  15. data/{qed/11_embedded_rules.rdoc → demo/11_embedded_rules.md} +13 -13
  16. data/{qed/99_issues/02_topcode.rdoc → demo/99_issues/02_topcode.md} +0 -0
  17. data/{qed → demo}/applique/ae.rb +0 -0
  18. data/{qed → demo}/applique/constant.rb +0 -0
  19. data/{qed → demo}/applique/env.rb +0 -0
  20. data/{qed → demo}/applique/fileutils.rb +0 -0
  21. data/{qed → demo}/applique/markup.rb +0 -0
  22. data/demo/applique/quote.md +8 -0
  23. data/{qed → demo}/applique/toplevel.rb +0 -0
  24. data/{qed → demo}/helpers/advice.rb +0 -0
  25. data/{qed → demo}/helpers/toplevel.rb +0 -0
  26. data/{qed → demo}/samples/data.txt +0 -0
  27. data/{qed → demo}/samples/table.yml +0 -0
  28. data/lib/qed.yml +41 -42
  29. data/lib/qed/cli.rb +2 -4
  30. data/lib/qed/cli/qed.rb +30 -3
  31. data/lib/qed/evaluator.rb +4 -1
  32. data/lib/qed/reporter/abstract.rb +1 -1
  33. data/lib/qed/session.rb +9 -2
  34. data/lib/qed/settings.rb +6 -122
  35. data/lib/qed/utils.rb +125 -0
  36. metadata +80 -56
  37. data/.config.rb +0 -24
  38. data/.ruby +0 -70
  39. data/COPYING.rdoc +0 -31
  40. data/lib/qed/rc.rb +0 -12
  41. data/qed/10_constant_lookup.rdoc +0 -16
  42. data/qed/applique/quote.rdoc +0 -8
@@ -0,0 +1,8 @@
1
+ ## Applique: Quote
2
+
3
+ This applique simply provide support to `05_quote.md` demo.
4
+
5
+ When "we want to make an example out of the following text" do |text|
6
+ @quote_text = text
7
+ end
8
+
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,70 +1,69 @@
1
1
  ---
2
- source:
2
+ revision: 2013
3
+ type: ruby
4
+ sources:
3
5
  - var
4
6
  authors:
5
7
  - name: Trans
6
8
  email: transfire@gmail.com
7
- copyrights:
8
- - holder: Thomas Sawyer, Rubyworks
9
- year: '2006'
10
- license: BSD-2-Clause
9
+ organizations: []
11
10
  requirements:
12
11
  - name: ansi
13
12
  - name: brass
14
- - name: facets
15
- version: 2.8+
16
- - name: courtier
17
- groups:
18
- - optional
19
- development: true
20
- - name: blankslate
21
- groups:
13
+ - version: 2.8+
14
+ name: facets
15
+ - groups:
22
16
  - optional
23
17
  - test
24
18
  development: true
25
- - name: ae
26
- groups:
19
+ name: blankslate
20
+ - groups:
27
21
  - test
28
22
  development: true
29
- - name: detroit
30
- groups:
23
+ name: ae
24
+ - groups:
31
25
  - build
32
26
  development: true
33
- - name: fire
34
- groups:
27
+ name: detroit
28
+ - groups:
35
29
  - build
36
30
  development: true
37
- dependencies: []
38
- alternatives: []
31
+ name: ergo
39
32
  conflicts: []
33
+ alternatives: []
34
+ resources:
35
+ - type: home
36
+ uri: http://rubyworks.github.com/qed
37
+ label: Homepage
38
+ - type: code
39
+ uri: http://github.com/rubyworks/qed
40
+ label: Source Code
41
+ - type: mail
42
+ uri: http://groups.google.com/groups/rubyworks-mailinglist
43
+ label: Mailing List
44
+ - type: bugs
45
+ uri: http://github.com/rubyworks/qed/issues
46
+ label: Issue Tracker
40
47
  repositories:
41
- - uri: git://github.com/rubyworks/qed.git
48
+ - name: upstream
42
49
  scm: git
43
- name: upstream
44
- resources:
45
- - uri: http://rubyworks.github.com/qed
46
- name: home
47
- type: home
48
- - uri: http://github.com/rubyworks/qed
49
- name: code
50
- type: code
51
- - uri: http://groups.google.com/groups/rubyworks-mailinglist
52
- name: mail
53
- type: mail
54
- - uri: http://github.com/rubyworks/qed/issues
55
- name: bugs
56
- type: bugs
57
- extra: {}
58
- load_path:
59
- - lib
60
- revision: 0
50
+ uri: git://github.com/rubyworks/qed.git
51
+ categories: []
52
+ copyrights:
53
+ - holder: Thomas Sawyer, Rubyworks
54
+ year: '2006'
55
+ license: BSD-2-Clause
56
+ customs: []
57
+ paths:
58
+ lib:
59
+ - lib
61
60
  created: '2009-06-16'
62
61
  summary: Quod Erat Demonstrandum
63
62
  title: QED
64
- version: 2.9.0
63
+ version: 2.9.1
65
64
  name: qed
66
65
  webcvs: http://github.com/rubyworks/qed/blob/master/
67
66
  description: ! 'QED (Quality Ensured Demonstrations) is a TDD/BDD framework
68
67
 
69
68
  utilizing Literate Programming techniques.'
70
- date: '2012-04-14'
69
+ date: '2013-02-18'
@@ -1,12 +1,10 @@
1
1
  if RUBY_VERSION < '1.9'
2
- require 'qed/rc' unless ENV['norc']
3
2
  require 'qed/configure'
4
3
  require 'qed/cli/qed'
5
4
  require 'qed/cli/qedoc'
6
5
  else
7
- require_relative 'rc' unless ENV['norc']
8
6
  require_relative 'configure'
9
- require_relative('cli/qed')
10
- require_relative('cli/qedoc')
7
+ require_relative 'cli/qed'
8
+ require_relative 'cli/qedoc'
11
9
  end
12
10
 
@@ -17,6 +17,33 @@ module QED
17
17
  #
18
18
  # Command line interface for running demos.
19
19
  #
20
+ # When running `qed` on the command line tool, QED can use
21
+ # either a automatic configuration file, via the RC library,
22
+ # or setup configuration via an explicitly required file.
23
+ #
24
+ # Using a master configuraiton file, add a `config :qed` entry.
25
+ # For example:
26
+ #
27
+ # config :qed, :profile=>:simplecov do
28
+ # require 'simplecov'
29
+ # SimpleCov.start do
30
+ # coverage_dir 'log/coverage'
31
+ # end
32
+ # end
33
+ #
34
+ # To not use RC, just create a requirable file such as `config/qed-coverage.rb`
35
+ #
36
+ # QED.configure do |qed|
37
+ # require 'simplecov'
38
+ # SimpleCov.start do
39
+ # coverage_dir 'log/coverage'
40
+ # end
41
+ # end
42
+ #
43
+ # Then when running qed use:
44
+ #
45
+ # $ qed -r ./config/qed-coverage.rb
46
+ #
20
47
  def self.cli(*argv)
21
48
  require 'optparse'
22
49
  require 'shellwords'
@@ -25,12 +52,12 @@ module QED
25
52
  # (actually, this is really not a problem anymore, but we'll leave it for now)
26
53
  require 'qed/session'
27
54
 
28
- # If RC config file is available.
29
- #RC.commit_configuration
55
+ Utils.load_config
30
56
 
31
57
  options = cli_parse(argv)
32
58
 
33
- session = Session.new(options)
59
+ settings = Settings.new(options)
60
+ session = Session.new(settings)
34
61
  success = session.run
35
62
 
36
63
  exit -1 unless success
@@ -105,6 +105,9 @@ module QED
105
105
  advise!(:after_step, step)
106
106
  end
107
107
 
108
+ # TODO: We may deprecate link helpers --it's probably not a good idea
109
+ # to have per-demo rules any way.
110
+
108
111
  # TODO: Not sure how to handle loading links in --comment runner mode.
109
112
 
110
113
  # TODO: Should scope be reused by imported demo ?
@@ -114,7 +117,7 @@ module QED
114
117
  #
115
118
  # @macro step
116
119
  def evaluate_links(step)
117
- step.text.scan(/\[qed:\/\/(.*?)\]/) do |match|
120
+ step.text.scan(/(?:\(|\[)qed:\/\/(.*?)(?:\)|\])/) do |match|
118
121
  file = $1
119
122
  # relative to demo demo
120
123
  if File.exist?(File.join(@demo.directory,file))
@@ -257,7 +257,7 @@ module Reporter
257
257
  vars
258
258
  end
259
259
 
260
- #
260
+ # TODO: Use global standard for backtrace exclusions.
261
261
  INTERNALS = /(lib|bin)[\\\/](qed|ae)/
262
262
 
263
263
  #
@@ -3,6 +3,13 @@ module QED
3
3
  require 'qed/settings'
4
4
  require 'qed/demo'
5
5
 
6
+ def self.run!(name=nil, &block)
7
+ configure(name, &block) if block
8
+ session = Session.new(:profile=>name)
9
+ success = session.run
10
+ exit -1 unless success
11
+ end
12
+
6
13
  # The Session class encapsulates a set of demonstrations
7
14
  # and the procedure for looping through them and running
8
15
  # each in turn.
@@ -85,7 +92,7 @@ module QED
85
92
  # QED.config
86
93
  #end
87
94
 
88
- # TODO: Ultimately use Plugin library to support custom reporters?
95
+ # TODO: Ultimately use a plugin library to support custom reporters?
89
96
 
90
97
  # Require all reporters.
91
98
  def require_reporters
@@ -158,7 +165,7 @@ module QED
158
165
 
159
166
  # Set $ASSERTION_COUNTS to zero point.
160
167
  def reset_assertion_counts
161
- $ASSERTION_COUNTS = Hash.new{|h,k| h[k] = 0 }
168
+ $ASSERTION_COUNTS = Hash.new{ |h,k| h[k] = 0 }
162
169
  end
163
170
 
164
171
  # Add to load path (from -I option).
@@ -1,36 +1,10 @@
1
1
  require 'qed/configure'
2
+ require 'qed/utils'
2
3
 
3
4
  module QED
4
5
 
5
6
  # Settings ecapsulates setup configuration for running QED.
6
7
  #
7
- # When running `qed` on the command line tool, QED can use
8
- # either a automatic configuration file, via the RC library,
9
- # or setup configuration via an explicitly required file.
10
- #
11
- # Using a master configuraiton file, add a `config :qed` entry.
12
- # For example:
13
- #
14
- # config :qed, :simplecov, :preset=>true do
15
- # require 'simplecov'
16
- # SimpleCov.start do
17
- # coverage_dir 'log/coverage'
18
- # end
19
- # end
20
- #
21
- # To not use RC, just create a requirable file such as `config/qed-coverage.rb`
22
- #
23
- # QED.configure do |qed|
24
- # require 'simplecov'
25
- # SimpleCov.start do
26
- # coverage_dir 'log/coverage'
27
- # end
28
- # end
29
- #
30
- # Then when running qed use:
31
- #
32
- # $ qed -r ./config/qed-coverage.rb
33
- #
34
8
  class Settings
35
9
 
36
10
  require 'tmpdir'
@@ -40,24 +14,18 @@ module QED
40
14
  # will be searched.
41
15
  DEFAULT_FILES = ['qed', 'demo', 'spec']
42
16
 
43
- # Glob pattern used to search for project's root directory.
44
- ROOT_PATTERN = '{.map,.ruby,.git/,.hg/,_darcs/}'
45
-
46
- # Home directory.
47
- HOME = File.expand_path('~')
48
-
49
17
  # Directory names to omit from automatic selection.
50
18
  OMIT_PATHS = %w{applique helpers support sample samples fixture fixtures}
51
19
 
52
20
  #
53
21
  # Initialize new Settings instance.
54
22
  #
55
- def initialize(options={})
23
+ def initialize(options={}, &block)
56
24
  initialize_defaults
57
25
 
58
26
  @profile = (options.delete(:profile) || default_profile).to_s
59
27
 
60
- load_profile
28
+ load_profile(&block)
61
29
 
62
30
  options.each do |key, val|
63
31
  send("#{key}=", val) if val
@@ -131,7 +99,7 @@ module QED
131
99
  # a Proc object in a hash b/c different configuration systems
132
100
  # can be used.
133
101
  #
134
- def load_profile
102
+ def load_profile(&block)
135
103
  config = QED.profiles[@profile]
136
104
  config.call(self) if config
137
105
  end
@@ -155,7 +123,7 @@ module QED
155
123
  # Project's root directory.
156
124
  #
157
125
  def root
158
- @root ||= find_root
126
+ Utils.root
159
127
  end
160
128
 
161
129
  #
@@ -171,7 +139,7 @@ module QED
171
139
  def temporary_directory
172
140
  @temporary_directory ||= (
173
141
  if rootless?
174
- system_tmpdir
142
+ Utils.system_tmpdir
175
143
  else
176
144
  File.join(root_directory, 'tmp', 'qed')
177
145
  end
@@ -214,81 +182,6 @@ module QED
214
182
 
215
183
  private
216
184
 
217
- # TODO: find a way to not need $ROOT global.
218
-
219
- #
220
- # Locate project's root directory. This is done by searching upward
221
- # in the file heirarchy for the existence of one of the following:
222
- #
223
- # .ruby
224
- # .git/
225
- # .hg/
226
- # _darcs/
227
- # .qed
228
- # .qed.rb
229
- # qed.rb
230
- #
231
- # Failing to find any of these locations, resort to the fallback:
232
- #
233
- # lib/
234
- #
235
- # If that isn't found, then returns a temporary system location.
236
- # and sets `rootless` to true.
237
- #
238
- def find_root(path=nil)
239
- return ($ROOT = system_tmpdir) if @rootless
240
-
241
- path = File.expand_path(path || Dir.pwd)
242
- path = File.dirname(path) unless File.directory?(path)
243
-
244
- root = lookup(ROOT_PATTERN, path) || lookup(CONFIG_PATTERN, path)
245
- return root if root
246
-
247
- #root = lookup(path, '{qed,demo,spec}/')
248
- #return root if root
249
-
250
- root = lookup('lib/', path)
251
-
252
- if !root
253
- warn "QED is running rootless."
254
- system_tmpdir
255
- @rootless = true
256
- else
257
- root
258
- end
259
-
260
- $ROOT = root
261
-
262
- #abort "QED failed to resolve project's root location.\n" +
263
- # "QED looks for following entries to identify the root:\n" +
264
- # ROOT_PATTERN +
265
- # "Please add one of them to your project to proceed."
266
- end
267
-
268
- # TODO: Use Dir.ascend from Ruby Facets ?
269
-
270
- #
271
- # Lookup path +glob+, searching each higher directory
272
- # in turn until just before the users home directory
273
- # is reached or just before the system's root directory.
274
- #
275
- def lookup(glob, path=Dir.pwd)
276
- until path == HOME or path == '/' # until home or root
277
- mark = Dir.glob(File.join(path,glob), File::FNM_CASEFOLD).first
278
- return path if mark
279
- path = File.dirname(path)
280
- end
281
- end
282
-
283
- #
284
- # System-wide temporary directory for QED executation.
285
- #
286
- def system_tmpdir
287
- @system_tmpdir ||= (
288
- File.join(Dir.tmpdir, 'qed', File.basename(Dir.pwd), Time.new.strftime("%Y%m%d%H%M%S"))
289
- )
290
- end
291
-
292
185
  # TODO: Support .map in future ?
293
186
 
294
187
  ##
@@ -317,15 +210,6 @@ module QED
317
210
  # config.exec
318
211
  #end
319
212
 
320
- #
321
- #def load_profile_from_file(file)
322
- # if File.exist?(file)
323
- # instance_eval(File.read(file), file)
324
- # else
325
- # # raise "no profile -- #{profile}"
326
- # end
327
- #end
328
-
329
213
  end
330
214
 
331
215
  end
@@ -0,0 +1,125 @@
1
+ module QED
2
+
3
+ # Glob pattern used to search for project's root directory.
4
+ ROOT_PATTERN = '{.ruby*,.git/,.hg/,_darcs/}'
5
+
6
+ # Glob pattern for standard config file.
7
+ CONFIG_PATTERN = '{etc/qed.rb,config/qed.rb,Qedfile,.qed}'
8
+
9
+ # Home directory.
10
+ HOME = File.expand_path('~')
11
+
12
+ #
13
+ module Utils
14
+ extend self
15
+
16
+ #
17
+ def load_config
18
+ load_etc unless ENV['noetc']
19
+ load_rc unless ENV['norc']
20
+ end
21
+
22
+ #
23
+ def load_rc
24
+ rc_file= File.join(root, '.rubyrc')
25
+ if File.exist?(rc_file)
26
+ begin
27
+ require 'rc/api'
28
+ RC.profile_switch 'qed', '-p', '--profile'
29
+ RC.configure 'qed' do |config|
30
+ QED.configure(config.profile, &config)
31
+ end
32
+ rescue LoadError
33
+ end
34
+ end
35
+ end
36
+
37
+ #
38
+ def load_etc
39
+ file = Dir.glob(File.join(root, CONFIG_PATTERN)).first
40
+ if file
41
+ load file
42
+ end
43
+ end
44
+
45
+ #
46
+ def root
47
+ @root ||= find_root
48
+ end
49
+
50
+ # TODO: find a way to not need $ROOT global.
51
+
52
+ #
53
+ # Locate project's root directory. This is done by searching upward
54
+ # in the file heirarchy for the existence of one of the following:
55
+ #
56
+ # .ruby
57
+ # .git/
58
+ # .hg/
59
+ # _darcs/
60
+ # .qed
61
+ # .qed.rb
62
+ # qed.rb
63
+ #
64
+ # Failing to find any of these locations, resort to the fallback:
65
+ #
66
+ # lib/
67
+ #
68
+ # If that isn't found, then returns a temporary system location.
69
+ # and sets `rootless` to true.
70
+ #
71
+ def find_root(path=nil)
72
+ return ($ROOT = system_tmpdir) if @rootless
73
+
74
+ path = File.expand_path(path || Dir.pwd)
75
+ path = File.dirname(path) unless File.directory?(path)
76
+
77
+ root = lookup(ROOT_PATTERN, path) || lookup(CONFIG_PATTERN, path)
78
+ return root if root
79
+
80
+ #root = lookup(path, '{qed,demo,spec}/')
81
+ #return root if root
82
+
83
+ root = lookup('lib/', path)
84
+
85
+ if !root
86
+ warn "QED is running rootless."
87
+ system_tmpdir
88
+ @rootless = true
89
+ else
90
+ root
91
+ end
92
+
93
+ $ROOT = root
94
+
95
+ #abort "QED failed to resolve project's root location.\n" +
96
+ # "QED looks for following entries to identify the root:\n" +
97
+ # ROOT_PATTERN +
98
+ # "Please add one of them to your project to proceed."
99
+ end
100
+
101
+ #
102
+ # Lookup path +glob+, searching each higher directory
103
+ # in turn until just before the users home directory
104
+ # is reached or just before the system's root directory.
105
+ #
106
+ def lookup(glob, path=Dir.pwd)
107
+ until path == HOME or path == '/' # until home or root
108
+ mark = Dir.glob(File.join(path,glob), File::FNM_CASEFOLD).first
109
+ return path if mark
110
+ path = File.dirname(path)
111
+ end
112
+ end
113
+
114
+ #
115
+ # System-wide temporary directory for QED executation.
116
+ #
117
+ def system_tmpdir
118
+ @system_tmpdir ||= (
119
+ File.join(Dir.tmpdir, 'qed', File.basename(Dir.pwd), Time.new.strftime("%Y%m%d%H%M%S"))
120
+ )
121
+ end
122
+
123
+ end
124
+
125
+ end