qed 2.8.5 → 2.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ # Confection based configuration.
2
+
3
+ config :qed do
4
+ # default configuration
5
+ end
6
+
7
+ config :qed, :profile=>:simplecov do
8
+ require 'simplecov'
9
+ SimpleCov.start do
10
+ coverage_dir 'log/coverage'
11
+ #add_group "Label", "lib/qed/directory"
12
+ end
13
+ end
14
+
15
+ config :qed, :profile=>:example do
16
+ puts ("*" * 78)
17
+ puts
18
+
19
+ at_exit do
20
+ puts
21
+ puts ("*" * 78)
22
+ end
23
+ end
24
+
data/.ruby CHANGED
@@ -41,7 +41,7 @@ revision: 0
41
41
  created: '2009-06-16'
42
42
  summary: Quod Erat Demonstrandum
43
43
  title: QED
44
- version: 2.8.5
44
+ version: 2.8.6
45
45
  name: qed
46
46
  webcvs: http://github.com/rubyworks/qed/blob/master/
47
47
  description: ! 'QED (Quality Ensured Demonstrations) is a TDD/BDD framework
@@ -1,5 +1,26 @@
1
1
  = RELEASE HISTORY
2
2
 
3
+ == 2.8.6 | 2012-03-15
4
+
5
+ This release simply make the configuration more versitile by supporting
6
+ Confection, task directory and traditional `.qed` configuration.
7
+
8
+ Changes:
9
+
10
+ * Support variety of configuration systems.
11
+
12
+
13
+ == 2.8.5 | 2012-03-14 19:00
14
+
15
+ Minor release simply make sure configuration file(s) were distributed
16
+ with package. Part of the new idea that configurations can be
17
+ reusable.
18
+
19
+ Changes:
20
+
21
+ * Include configuration files in distribution.
22
+
23
+
3
24
  == 2.8.4 | 2012-03-14 18:06
4
25
 
5
26
  Just a fix of a method that should have been renamed. Nothing to see here.
@@ -41,7 +41,7 @@ revision: 0
41
41
  created: '2009-06-16'
42
42
  summary: Quod Erat Demonstrandum
43
43
  title: QED
44
- version: 2.8.5
44
+ version: 2.8.6
45
45
  name: qed
46
46
  webcvs: http://github.com/rubyworks/qed/blob/master/
47
47
  description: ! 'QED (Quality Ensured Demonstrations) is a TDD/BDD framework
@@ -9,6 +9,15 @@ module QED
9
9
 
10
10
  class Session
11
11
 
12
+ #
13
+ # Session settings are passed to `Session.new`.
14
+ #
15
+ def self.settings
16
+ @settings ||= Settings.new
17
+ end
18
+
19
+ #
20
+ # Command line interface for running demos.
12
21
  #
13
22
  def self.cli(*argv)
14
23
  require 'optparse'
@@ -21,13 +30,15 @@ module QED
21
30
  # exit -1
22
31
  #end
23
32
 
24
- session = Session.new(files, options)
33
+ session = Session.new(settings)
25
34
  success = session.run
26
35
 
27
36
  exit -1 unless success
28
37
  end
29
38
 
30
- # Instance of OptionParser
39
+ #
40
+ # Build an instance of OptionParser.
41
+ #
31
42
  def self.cli_parse(argv)
32
43
  options = {}
33
44
  options_parser = OptionParser.new do |opt|
@@ -39,10 +50,10 @@ module QED
39
50
  # options[:format] = :dotprogress
40
51
  #end
41
52
  opt.on('--verbatim', '-v', "shortcut for verbatim reporter") do
42
- options[:format] = :verbatim
53
+ settings.format = :verbatim
43
54
  end
44
55
  opt.on('--tapy', '-y', "shortcut for TAP-Y reporter") do
45
- options[:format] = :tapy
56
+ settings.format = :tapy
46
57
  end
47
58
  #opt.on('--bullet', '-b', "use bullet-point reporter") do
48
59
  # options[:format] = :bullet
@@ -54,25 +65,25 @@ module QED
54
65
  # options[:format] = :script # psuedo-reporter
55
66
  #end
56
67
  opt.on('--format', '-f FORMAT', "use custom reporter") do |format|
57
- options[:format] = format.to_sym
68
+ settings.format = format.to_sym
58
69
  end
59
70
 
60
71
  opt.separator("Control Options:")
61
72
 
62
73
  opt.on('-p', '--profile NAME', "load runtime profile") do |name|
63
- options[:profile] = name.to_sym
74
+ settings.profile = name.to_sym
64
75
  end
65
76
  opt.on('--comment', '-c', "run comment code") do
66
- options[:mode] = :comment
77
+ settings.mode = :comment
67
78
  end
68
79
  opt.on('--loadpath', "-I PATH", "add paths to $LOAD_PATH") do |paths|
69
- options[:loadpath] = paths.split(/[:;]/).map{|d| File.expand_path(d)}
80
+ settings.loadpath = paths.split(/[:;]/).map{|d| File.expand_path(d)}
70
81
  end
71
82
  opt.on('--require', "-r LIB", "require library") do |paths|
72
- options[:requires] = paths.split(/[:;]/)
83
+ settings.requires = paths.split(/[:;]/)
73
84
  end
74
85
  opt.on('--rooted', '-R', "run from project root instead of temporary directory") do
75
- options[:rooted] = true
86
+ settings.rooted = true
76
87
  end
77
88
  opt.on('--trace', '-t [COUNT]', "number of backtraces for exceptions (0 for all)") do |cnt|
78
89
  #options[:trace] = true
@@ -101,8 +112,9 @@ module QED
101
112
  unless settings.profiles.empty?
102
113
  puts "Available Profiles:"
103
114
  require 'confection'
104
- Confection.profiles(:qed).each do |name|
105
- puts " #{name}"
115
+ settings.profiles.each do |name|
116
+ next if name.strip == ''
117
+ puts " -p #{name}"
106
118
  end
107
119
  end
108
120
 
@@ -115,17 +127,6 @@ module QED
115
127
  return argv, options
116
128
  end
117
129
 
118
- #
119
- #def self.profiles
120
- # Settings.profiles
121
- #end
122
-
123
- # TODO: Pass to Session class, instead of acting global.
124
- # It is used at the class level to get profiles for the cli.
125
- #def self.settings
126
- # @settings ||= Settings.new([])
127
- #end
128
-
129
130
  end
130
131
 
131
132
  end
@@ -19,10 +19,16 @@ module QED
19
19
  attr :settings
20
20
 
21
21
  # New Session
22
- def initialize(files, options={})
22
+ def initialize(settings, options={})
23
23
  require_reporters
24
24
 
25
- @settings = Settings.new(files, options)
25
+ case settings
26
+ when Settings
27
+ @settings = settings
28
+ else
29
+ options[:files] = settings
30
+ @settings = Settings.new(options)
31
+ end
26
32
  end
27
33
 
28
34
  # Demonstration files (or globs).
@@ -2,7 +2,10 @@ module QED
2
2
 
3
3
  # Settings ecapsulates setup code for running QED.
4
4
  #
5
- # By convention, configuration for QED is placed in `task/qed.rb`.
5
+ # QED can use Confection-based configuration, if a Confile is present.
6
+ #
7
+ # QED also supports configuration files placed in `task/<profile>.qed`.
8
+ #
6
9
  # Configuration may also be placed at project root level in `qed.rb`,
7
10
  # or if you're old-school, a `.qed` hidden file can still be used. If you
8
11
  # don't like any of these choices, QED supports configuration file mapping
@@ -24,22 +27,9 @@ module QED
24
27
  #
25
28
  class Settings
26
29
 
27
- #
28
- # Because QED usese the Confection library, but Confection also
29
- # uses QED for testing, a special configuration exception needed
30
- # be sliced out so Confection's test could run without QED using
31
- # it. We handle this via a environment variable `config`. Set
32
- # it to 'none' to deactivate the use of Confection.
33
- #
34
- def self.configless?
35
- ENV['config'] == 'none'
36
- end
37
-
38
30
  require 'tmpdir'
39
31
  require 'fileutils'
40
32
 
41
- require 'confection' unless configless?
42
-
43
33
  # If files are not specified than these directories
44
34
  # will be searched.
45
35
  DEFAULT_FILES = ['qed', 'demo', 'spec']
@@ -60,50 +50,75 @@ module QED
60
50
  OMIT_PATHS = %w{applique helpers support sample samples fixture fixtures}
61
51
 
62
52
  #
53
+ # Initialize new Settings instance.
63
54
  #
64
- #
65
- def initialize(files, options={})
66
- @files = [files].flatten.compact
67
- @files = [DEFAULT_FILES.find{ |d| File.directory?(d) }] if @files.empty?
68
- @files = @files.compact
69
-
70
- @format = options[:format] || :dot
71
- @trace = options[:trace] || false
72
- @mode = options[:mode] || nil
73
- @profile = options[:profile] || :default
74
- @loadpath = options[:loadpath] || ['lib']
75
- @requires = options[:requires] || []
55
+ def initialize(options={})
56
+ initialize_defaults
57
+ initialize_configuration
76
58
 
77
- @omit = OMIT_PATHS # TODO: eventually make configurable
59
+ options.each do |key, val|
60
+ send("#{key}=", val) if val
61
+ end
62
+ end
78
63
 
79
- @rootless = options[:rootless]
80
- #@profiles = {}
64
+ #
65
+ def initialize_defaults
66
+ @files = nil
67
+ @format = :dot
68
+ @trace = false
69
+ @mode = nil
70
+ @profile = ENV['profile'] || :default
71
+ @loadpath = ['lib']
72
+ @requires = []
73
+ @omit = OMIT_PATHS # TODO: eventually make configurable
74
+ @rootless = false
75
+ end
81
76
 
82
- @root = @rootless ? system_tmpdir : find_root
77
+ #
78
+ # QED can use either the Confection library for configuration,
79
+ # task-style configuration files in the form of `task/<profile>.qed`,
80
+ # or a traditional master `.qed` file.
81
+ #
82
+ # Note, that setting `ENV['confectionless']` will force Confection
83
+ # not to be used. This is used by the Confection library so it can
84
+ # run QED demos too.
85
+ #
86
+ def initialize_configuration
87
+ @profiles = {}
83
88
 
84
- # Set global. TODO: find away to not need this ?
85
- $ROOT = @root
89
+ if confection_file && !ENV['confectionless']
90
+ require 'confection'
91
+ Confection.profiles(:qed).each do |name|
92
+ @profiles[name.to_s] = lambda{ load_profile_from_confection(name) }
93
+ end
94
+ end
86
95
 
87
- initialize_configuration
96
+ Dir.glob(File.join(root, 'task/*.qed')).map do |file|
97
+ name = File.basename(file).chomp('.qed')
98
+ @profiles[name.to_s] = lambda{ load_profile_from_file(file) }
99
+ end
88
100
 
89
- #profile = options[:profile]
90
- #confection(:qed, profile)
101
+ Dir.glob(File.join(root, '{.qed,.qed.rb,qed.rb,Qedfile}')).map do |file|
102
+ @profiles[nil] = lambda{ load_profile_from_file(file) }
103
+ end
91
104
  end
92
105
 
93
- #
94
- # Because QED uses the Confection library, but Confection also
95
- # uses QED for testing, a special configuration exception needed
96
- # be sliced out so Confection's demos could run without QED using
97
- # it. We handle this via a `.qed` config file. Add this file
98
- # to a project and it will deactivate the use of Confection,
99
- # and load the contents of the file instead.
100
- #
101
- def initialize_configuration
102
- require 'confection' unless configless?
106
+ # Lookup Confection config file.
107
+ def confection_file
108
+ Dir.glob(File.join(root, '{,.}confile{.rb,}'), File::FNM_CASEFOLD).first
103
109
  end
104
110
 
105
111
  # Demonstration files (or globs).
106
- attr_reader :files
112
+ def files
113
+ @files ||= (
114
+ [DEFAULT_FILES.find{ |d| File.directory?(d) }].compact
115
+ )
116
+ end
117
+
118
+ #
119
+ def files=(files)
120
+ @files = Array(files).flatten.compact
121
+ end
107
122
 
108
123
  # File patterns to omit.
109
124
  attr_accessor :omit
@@ -118,25 +133,20 @@ module QED
118
133
  attr_accessor :mode
119
134
 
120
135
  # Paths to be added to $LOAD_PATH.
121
- attr_reader :loadpath
136
+ attr_accessor :loadpath
122
137
 
123
138
  # Libraries to be required.
124
- attr_reader :requires
139
+ attr_accessor :requires
125
140
 
126
141
  # Operate from project root?
127
142
  attr_accessor :rooted
128
143
 
144
+ # Operate from system temporary directory?
145
+ attr_accessor :rootless
146
+
129
147
  # Selected profile.
130
148
  attr_accessor :profile
131
149
 
132
- #
133
- # If Environment varible is set to 'none' then COnfection will not be
134
- # used for configuration.
135
- #
136
- def configless?
137
- self.class.configless?
138
- end
139
-
140
150
  #
141
151
  # Operate relative to project root directory, or use system's location.
142
152
  #
@@ -147,14 +157,14 @@ module QED
147
157
  #
148
158
  # Project's root directory.
149
159
  #
150
- def root_directory
151
- @root
160
+ def root
161
+ @root ||= find_root
152
162
  end
153
163
 
154
164
  #
155
- # Shorthand for `#root_directory`.
165
+ # Alias for `#root`.
156
166
  #
157
- alias_method :root, :root_directory
167
+ alias_method :root_directory, :root
158
168
 
159
169
  #
160
170
  # Temporary directory. If `#rootless?` return true then this will be
@@ -207,57 +217,27 @@ module QED
207
217
  # confection is deactivated via the override file.
208
218
  #
209
219
  def profiles
210
- return [] if configless?
211
- Confection.profiles(:qed)
212
- end
213
-
214
- =begin
215
- #
216
- # Keeps a list of defined profiles.
217
- #
218
- attr_accessor :profiles
219
-
220
- # Profile configurations.
221
- #def profiles
222
- # @profiles ||= (
223
- # files = Dir["#{settings_directory}/*.rb"]
224
- # files.map do |file|
225
- # File.basename(file).chomp('.rb')
226
- # end
227
- # )
228
- #end
229
-
230
- #
231
- # Load QED profile (from -e option).
232
- #
233
- def load_profile(name)
234
- if profile = profiles[name.to_s]
235
- instance_eval(&profile)
236
- #eval('self', TOPLEVEL_BINDING).instance_eval(&prof)
237
- end
238
- #return unless settings_directory
239
- #if file = Dir["#{settings_directory}/#{profile}.rb"].first
240
- # require(file)
241
- #end
220
+ @profiles.keys
242
221
  end
243
- =end
244
222
 
245
223
  #
246
- # Load QED configuration profile. QED configurations are defined
247
- # via standards of the Confection library, unless otherwise
248
- # deativated via the `.qed` file.
224
+ # Load QED configuration profile. The load procedure is stored as
225
+ # a Proc object in a hash b/c different configuration systems
226
+ # can be used.
249
227
  #
250
228
  def load_profile(profile)
251
- return if configless?
252
- config = confection(:qed, profile.to_sym)
253
- config.exec
229
+ profile = @profiles[profile.to_s]
230
+ profile.call if profile
254
231
  end
255
232
 
233
+ private
234
+
235
+ # TODO: find away to not need $ROOT global.
236
+
256
237
  #
257
238
  # Locate project's root directory. This is done by searching upward
258
239
  # in the file heirarchy for the existence of one of the following:
259
240
  #
260
- # .map
261
241
  # .ruby
262
242
  # .git/
263
243
  # .hg/
@@ -274,6 +254,8 @@ module QED
274
254
  # and sets `rootless` to true.
275
255
  #
276
256
  def find_root(path=nil)
257
+ return ($ROOT = system_tmpdir) if @rootless
258
+
277
259
  path = File.expand_path(path || Dir.pwd)
278
260
  path = File.dirname(path) unless File.directory?(path)
279
261
 
@@ -287,11 +269,13 @@ module QED
287
269
 
288
270
  if !root
289
271
  warn "QED is running rootless."
290
- root = system_tmpdir
272
+ system_tmpdir
291
273
  @rootless = true
274
+ else
275
+ root
292
276
  end
293
277
 
294
- return root
278
+ $ROOT = root
295
279
 
296
280
  #abort "QED failed to resolve project's root location.\n" +
297
281
  # "QED looks for following entries to identify the root:\n" +
@@ -323,15 +307,6 @@ module QED
323
307
  )
324
308
  end
325
309
 
326
- #
327
- # Lookup, cache and return QED config file.
328
- #
329
- def config_override
330
- @config_override ||= (
331
- Dir.glob(File.join(root_directory, '.qed')).first
332
- )
333
- end
334
-
335
310
  ##
336
311
  ## Return cached file map from a project's `.map` file, if it exists.
337
312
  ##
@@ -352,6 +327,21 @@ module QED
352
327
  # @_map_file ||= File.join(root_directory,MAP_FILE)
353
328
  #end
354
329
 
330
+ #
331
+ def load_confection_profile(name)
332
+ config = confection(:qed, name.to_sym)
333
+ config.exec
334
+ end
335
+
336
+ #
337
+ def load_profile_from_file(file)
338
+ if File.exist?(file)
339
+ instance_eval(File.read(file), file)
340
+ else
341
+ # raise "no profile -- #{profile}"
342
+ end
343
+ end
344
+
355
345
  end
356
346
 
357
347
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qed
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.5
4
+ version: 2.8.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ansi
16
- requirement: &25789680 !ruby/object:Gem::Requirement
16
+ requirement: &17814740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *25789680
24
+ version_requirements: *17814740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: facets
27
- requirement: &25788160 !ruby/object:Gem::Requirement
27
+ requirement: &17813900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.8'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *25788160
35
+ version_requirements: *17813900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: brass
38
- requirement: &25787120 !ruby/object:Gem::Requirement
38
+ requirement: &17813280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *25787120
46
+ version_requirements: *17813280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: confection
49
- requirement: &25785800 !ruby/object:Gem::Requirement
49
+ requirement: &17812300 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *25785800
57
+ version_requirements: *17812300
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: detroit
60
- requirement: &25784360 !ruby/object:Gem::Requirement
60
+ requirement: &17811720 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *25784360
68
+ version_requirements: *17811720
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: ae
71
- requirement: &25783020 !ruby/object:Gem::Requirement
71
+ requirement: &17811060 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *25783020
79
+ version_requirements: *17811060
80
80
  description: ! 'QED (Quality Ensured Demonstrations) is a TDD/BDD framework
81
81
 
82
82
  utilizing Literate Programming techniques.'
@@ -91,6 +91,7 @@ extra_rdoc_files:
91
91
  - README.rdoc
92
92
  - COPYING.rdoc
93
93
  files:
94
+ - .confile.rb
94
95
  - .ruby
95
96
  - .yardopts
96
97
  - bin/qed
@@ -144,8 +145,6 @@ files:
144
145
  - qed/helpers/toplevel.rb
145
146
  - qed/samples/data.txt
146
147
  - qed/samples/table.yml
147
- - task/qed-example.rb
148
- - task/qed-simplecov.rb
149
148
  - HISTORY.rdoc
150
149
  - README.rdoc
151
150
  - COPYING.rdoc
@@ -1,10 +0,0 @@
1
- # Just to demonstrate profiles.
2
-
3
- puts ("*" * 78)
4
- puts
5
-
6
- at_exit do
7
- puts
8
- puts ("*" * 78)
9
- end
10
-
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'simplecov'
4
-
5
- SimpleCov.start do
6
- coverage_dir 'log/coverage'
7
- #add_group "Label", "lib/qed/directory"
8
- end
9
-