qed 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,155 @@
1
+ module QED
2
+
3
+ # Ecapsulate confiduration information needed for QED
4
+ # run and set user and project options.
5
+ class Settings
6
+
7
+ require 'tmpdir'
8
+ require 'fileutils'
9
+
10
+ # Configuration directory `.qed`, `.config/qed` or `config/qed`.
11
+ # In this directory special configuration files can be placed
12
+ # to autmatically effect qed execution. In particular you can
13
+ # add a `profiles.yml` file to setup convenient execution
14
+ # scenarios.
15
+ CONFIG_PATTERN = "{.,.set/,set/.config/,config/}qed"
16
+
17
+ # Glob pattern used to search for project's root directory.
18
+ ROOT_PATTERN = '{.ruby,.git/,.hg/,_darcs/,.qed/,.set/qed/,set/qed/.config/qed/,config/qed/}'
19
+
20
+ # Home directory.
21
+ HOME = File.expand_path('~')
22
+
23
+ #
24
+ def initialize(options={})
25
+ @rootless = options[:rootless]
26
+ end
27
+
28
+ #
29
+ def rootless?
30
+ @rootless
31
+ end
32
+
33
+ # Project's root directory.
34
+ def root_directory
35
+ @root_directory ||= find_root
36
+ end
37
+
38
+ # Project's QED configuration directory.
39
+ # TODO: rename to `config_directory` ?
40
+ def settings_directory
41
+ @settings_directory ||= find_settings
42
+ end
43
+
44
+ #
45
+ def temporary_directory
46
+ @temporary_directory ||= (
47
+ if rootless?
48
+ File.join(Dir.tmpdir, 'qed', File.filename(Dir.pwd), Time.new.strftime("%Y%m%d%H%M%S"))
49
+ else
50
+ File.join(root_directory, 'tmp', 'qed')
51
+ end
52
+ #FileUtils.mkdir_p(dir) unless File.directory?(dir)
53
+ )
54
+ end
55
+
56
+ #
57
+ alias_method :tmpdir, :temporary_directory
58
+
59
+ # Remove and recreate temporary working directory.
60
+ def clear_directory
61
+ FileUtils.rm_r(tmpdir) if File.exist?(tmpdir)
62
+ FileUtils.mkdir_p(tmpdir)
63
+ end
64
+
65
+ # Profile configurations.
66
+ def profiles
67
+ @profiles ||= (
68
+ files = Dir["#{settings_directory}/*.rb"]
69
+ files.map do |file|
70
+ File.basename(file).chomp('.rb')
71
+ end
72
+ )
73
+ end
74
+
75
+ # Require requirement file (from -e option).
76
+ def require_profile(profile)
77
+ return unless settings_directory
78
+ if file = Dir["#{settings_directory}/#{profile}.rb"].first
79
+ require(file)
80
+ end
81
+ end
82
+
83
+ # Locate project's root directory. This is done by searching upward
84
+ # in the file heirarchy for the existence of one of the following
85
+ # path names, each group being tried in turn.
86
+ #
87
+ # * .git/
88
+ # * .hg/
89
+ # * _darcs/
90
+ # * .config/qed/
91
+ # * config/qed/
92
+ # * .qed/
93
+ # * .ruby
94
+ #
95
+ # Failing to find any of these locations, resort to the fallback:
96
+ #
97
+ # * lib/
98
+ #
99
+ def find_root(path=nil)
100
+ path = File.expand_path(path || Dir.pwd)
101
+ path = File.dirname(path) unless File.directory?(path)
102
+
103
+ root = lookup(ROOT_PATTERN, path)
104
+ return root if root
105
+
106
+ #root = lookup(path, '{.qed,.config/qed,config/qed}/')
107
+ #return root if root
108
+
109
+ #root = lookup(path, '{qed,demo,demos}/')
110
+ #return root if root
111
+
112
+ root = lookup('lib/', path)
113
+
114
+ return root if root
115
+
116
+ abort "QED failed to resolve project's root location.\n" +
117
+ "QED looks for following entries to identify the root:\n" +
118
+ " .set/qed/\n" +
119
+ " set/qed/\n" +
120
+ " .config/qed/\n" +
121
+ " config/qed/\n" +
122
+ " .qed/\n" +
123
+ " .ruby\n" +
124
+ " lib/\n" +
125
+ "Please add one of them to your project to proceed."
126
+ end
127
+
128
+ # Locate configuration directory by seaching up the
129
+ # file hierachy relative to the working directory
130
+ # for one of the following paths:
131
+ #
132
+ # * .config/qed/
133
+ # * config/qed/
134
+ # * .qed/
135
+ #
136
+ def find_settings
137
+ Dir[File.join(root_directory,CONFIG_PATTERN)].first
138
+ end
139
+
140
+ # Lookup path +glob+, searching each higher directory
141
+ # in turn until just before the users home directory
142
+ # is reached or just before the system's root directory.
143
+ #
144
+ # TODO: include HOME directory in search?
145
+ def lookup(glob, path=Dir.pwd)
146
+ until path == HOME or path == '/' # until home or root
147
+ mark = Dir.glob(File.join(path,glob), File::FNM_CASEFOLD).first
148
+ return path if mark
149
+ path = File.dirname(path)
150
+ end
151
+ end
152
+
153
+ end
154
+
155
+ end
data/lib/qed.rb CHANGED
@@ -1,26 +1,27 @@
1
- require 'yaml'
2
-
3
1
  module QED
4
- DIRECTORY = File.dirname(__FILE__) + '/qed'
5
-
6
- PROFILE = YAML.load(File.new(DIRECTORY + '/profile.yml')) rescue {}
7
- PACKAGE = YAML.load(File.new(DIRECTORY + '/package.yml')) rescue {}
8
2
 
9
- VERSION = PACKAGE.values_at('major','minor','patch','build').compact.join('.')
3
+ # Access to project metadata.
4
+ def self.metadata
5
+ @metadata ||= (
6
+ require 'yaml'
7
+ YAML.load(File.new(File.dirname(__FILE__) + '/qed.yml')) rescue {}
8
+ )
9
+ end
10
10
 
11
- #
11
+ # Access to project metadata as constants.
12
12
  def self.const_missing(name)
13
13
  key = name.to_s.downcase
14
- if PACKAGE.key?(key)
15
- PACKAGE[key]
16
- elsif PROFILE.key?(key)
17
- PROFILE[key]
18
- else
19
- super(name)
20
- end
14
+ metadata[key] || super(name)
15
+ end
16
+
17
+ # TODO: Only b/c of Ruby 1.8.x bug.
18
+ VERSION = metadata['version']
19
+
20
+ #
21
+ def self.cli(*argv)
22
+ Session.cli(*argv)
21
23
  end
24
+
22
25
  end
23
26
 
24
- require 'qed/command'
25
27
  require 'qed/session'
26
-
data/lib/qed.yml ADDED
@@ -0,0 +1,47 @@
1
+ ---
2
+ spec_version: 1.0.0
3
+ replaces: []
4
+
5
+ loadpath:
6
+ - lib
7
+ name: qed
8
+ repositories:
9
+ public: git://github.com/proutils/qed.git
10
+ conflicts: []
11
+
12
+ engine_check: []
13
+
14
+ title: QED
15
+ resources:
16
+ home: http://proutils.github.com/qed
17
+ work: http://github.com/proutils/qed
18
+ maintainers: []
19
+
20
+ requires:
21
+ - group: []
22
+
23
+ name: ansi
24
+ version: 0+
25
+ - group: []
26
+
27
+ name: facets
28
+ version: 2.8+
29
+ - group: []
30
+
31
+ name: ae
32
+ version: 0+
33
+ - group:
34
+ - build
35
+ name: syckle
36
+ version: 0+
37
+ manifest: Manifest
38
+ version: 2.5.1
39
+ licenses: []
40
+
41
+ copyright: Copyright (c) 2006 Thomas Sawyer
42
+ authors:
43
+ - Thomas Sawyer <transfire@gmail.com>
44
+ organization: RubyWorks
45
+ description: QED (Quality Ensured Demonstrations) is a TDD/BDD framework utilizing Literate Programming techniques.
46
+ summary: Quod Erat Demonstrandum
47
+ created: 2006-12-16
data/lib/yard-qed.rb ADDED
@@ -0,0 +1 @@
1
+ # TODO: Create a YARD plugin for QED.
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: 27
5
- prerelease: false
4
+ hash: 25
5
+ prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 5
9
- - 0
10
- version: 2.5.0
9
+ - 1
10
+ version: 2.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Sawyer <transfire@gmail.com>
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-07 01:00:00 -04:00
19
- default_executable:
18
+ date: 2011-06-08 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: ansi
@@ -40,10 +39,11 @@ dependencies:
40
39
  requirements:
41
40
  - - ">="
42
41
  - !ruby/object:Gem::Version
43
- hash: 3
42
+ hash: 19
44
43
  segments:
45
- - 0
46
- version: "0"
44
+ - 2
45
+ - 8
46
+ version: "2.8"
47
47
  type: :runtime
48
48
  version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
@@ -84,22 +84,16 @@ extensions: []
84
84
  extra_rdoc_files:
85
85
  - README.rdoc
86
86
  files:
87
+ - .ruby
87
88
  - bin/qed
88
89
  - bin/qedoc
89
- - eg/hello_world.rdoc
90
- - eg/view_error.rdoc
91
- - eg/website.rdoc
92
90
  - lib/qed/advice.rb
93
91
  - lib/qed/applique.rb
94
- - lib/qed/command.rb
95
92
  - lib/qed/core_ext.rb
96
93
  - lib/qed/demo.rb
97
94
  - lib/qed/evaluator.rb
98
95
  - lib/qed/helpers/file_fixtures.rb
99
96
  - lib/qed/helpers/shell_session.rb
100
- - lib/qed/meta/data.rb
101
- - lib/qed/meta/package
102
- - lib/qed/meta/profile
103
97
  - lib/qed/parser.rb
104
98
  - lib/qed/reporter/abstract.rb
105
99
  - lib/qed/reporter/bullet.rb
@@ -108,15 +102,15 @@ files:
108
102
  - lib/qed/reporter/verbatim.rb
109
103
  - lib/qed/scope.rb
110
104
  - lib/qed/session.rb
105
+ - lib/qed/settings.rb
111
106
  - lib/qed.rb
107
+ - lib/qed.yml
112
108
  - lib/qedoc/command.rb
113
109
  - lib/qedoc/document/jquery.js
114
110
  - lib/qedoc/document/markup.rb
115
111
  - lib/qedoc/document/template.rhtml
116
112
  - lib/qedoc/document.rb
117
- - meta/data.rb
118
- - meta/package
119
- - meta/profile
113
+ - lib/yard-qed.rb
120
114
  - qed/01_demos.rdoc
121
115
  - qed/02_advice.rdoc
122
116
  - qed/03_helpers.rdoc
@@ -140,11 +134,9 @@ files:
140
134
  - test/integration/topcode.rdoc
141
135
  - LICENSE
142
136
  - README.rdoc
143
- - History.rdoc
144
- has_rdoc: true
145
137
  homepage: http://proutils.github.com/qed
146
- licenses:
147
- - ""
138
+ licenses: []
139
+
148
140
  post_install_message:
149
141
  rdoc_options:
150
142
  - --title
@@ -174,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
166
  requirements: []
175
167
 
176
168
  rubyforge_project: qed
177
- rubygems_version: 1.3.7
169
+ rubygems_version: 1.8.2
178
170
  signing_key:
179
171
  specification_version: 3
180
172
  summary: Quod Erat Demonstrandum
data/History.rdoc DELETED
@@ -1,210 +0,0 @@
1
- = RELEASE HISTORY
2
-
3
- == 2.5.0 / 2010-11-04
4
-
5
- The latest release of QED improves on applique loading, such that each
6
- demonstrandum gets it's own localized set. The CLI has also been modified
7
- so that there is no longer a defualt location, the directory or files to run
8
- must be specified.
9
-
10
- Changes:
11
-
12
- * Better handling of Applique.
13
- * Remove Advice class --advice is now stored in Applique.
14
- * Each applique file is it's own module.
15
- * Advice from each applique is applied.
16
- * CLI requires files be specified.
17
-
18
-
19
- == 2.4.0 / 2010-09-02
20
-
21
- All engines go! QED has not been tested against 1.8.6, 1.8.7 and 1.9.2.
22
- Underthehood steps are not organized in doubely-linked lists, which makes
23
- them much more robust and flexible. This release also improves scoping,
24
- test counts, and inline documentation parsing.
25
-
26
- Changes:
27
-
28
- * Use new doubly-linked list step design.
29
- * Fix -r option on command line.
30
- * Provide #instance_exec core extension for Ruby 1.8.6.
31
- * Scope is extended by and includes applique.
32
-
33
-
34
- == 2.3.0 / 2010-07-14
35
-
36
- Bug to the scurry! QED has broken through the code/document ceiling and
37
- is cracking ectoskeletons all the way to the bank. A proverbal can of
38
- Roach-Be-Gone this is! What's that you say? I will exlpain. QED can now
39
- run directly against code comments. Simply slip the qed command the -c
40
- option and feed it some ruby scripts, and presto watch you commnets
41
- fail ;) I think you can figure out what to do next.
42
-
43
- In addition to this coolness QED has been improved under the floor
44
- boards as well. The parser, which is much faster, now blocks commentary
45
- paragraphs and code examples togeher in one-to-one pairings. Not only
46
- does this clean-up the code, but it opens up the potential for Around
47
- advice in a future version.
48
-
49
- Changes:
50
-
51
- * NEW! Ruby script comment run mode.
52
- * Better parsing system uses commentary-example pairs.
53
- * Colon can also be used to specify plain text (along with ellipsis).
54
- * Now distributed under the more permissive Apache 2.0 license.
55
-
56
-
57
- == 2.2.2 / 2010-06-21
58
-
59
- An issue was reported in which the a code block at the very
60
- top of a demo was being ignored. This release fixes this issue
61
- by rewriting the parser (much better now thanks!). At the same
62
- time the Data and Table methods have been polished, both of
63
- which can now pick up sample data relative to the current demo.
64
-
65
- Changes:
66
-
67
- * Rewrite parser and fix top code issue.
68
- * Data method cannot write data, instead executes block.
69
- * Data and Table methods look for file relative to demo first.
70
- * Added -R option to run demos relative to project root.
71
-
72
-
73
- == 2.2.1 / 2010-06-20
74
-
75
- Remove dependencies to Tilt and Nokogiri. Should have
76
- done this in last release but alas --there is so
77
- much to do.
78
-
79
- Changes:
80
-
81
- * Removed HTML parsing dependencies.
82
- * Reduce Advice to a single class.
83
-
84
-
85
- == 2.2.0 / 2010-06-19
86
-
87
- This release returns to a text-based evaluator, rather
88
- then use HTML. Processing HTML proved to have too many
89
- edge cases to be effective --both in implementation
90
- and in end-usage. So to remedy the situation QED has
91
- return to supportting simple markup formats such as
92
- RDoc and Markup.
93
-
94
- This release also adds multi-pattern advice. Instead of
95
- a single pattern, multiple patterns can be matched
96
- sequentially. This make it a easier to match large text
97
- descriptions without restoring to regular expressions.
98
-
99
- In addition QED now supports raw text blocks. By ending
100
- a description section in ellipsis (...), the subsequent
101
- code setion becomes a plain text section and is passed
102
- into the argument list of any matching When advice. This
103
- makes it easy to scaffold fixture files, for example.
104
-
105
- Finally, this release also refines the evaluation scopes.
106
- Where before, a new binding was being created, each was
107
- attached to the TOPLEVEL, and therefore not truly isolated
108
- on a per-dcoument basis. To correct, QED now mocks the
109
- TOPLEVEL providing a new instance of this mock object for
110
- each document.
111
-
112
- Changes:
113
-
114
- * No longer uses HTML for document processing.
115
- * Support for plain text blocks using ellipsis.
116
- * New sequential multi-pattern matches.
117
- * Mock TOPLEVEL at both the demo and applique levels.
118
- * Adjust color support for latest ANSI release.
119
-
120
-
121
- == 2.1.1 / 2010-04-08
122
-
123
- Fixed bug introduced in the last version that executed all
124
- scripts in a single binding. There needed to be a binding
125
- for each script.
126
-
127
- Changes:
128
-
129
- * Fixed cross-script bug by moving binding instantiation into Script class.
130
-
131
-
132
- == 2.1.0 / 2010-04-07
133
-
134
- QED documents are now run in the TOPLEVEL context, rather
135
- than in a subclass of Scope. This ensures code runs as
136
- one would expect it too in the wild.
137
-
138
- Changes:
139
-
140
- * Scope.new redirect to TOPLEVEL.
141
- * DomainLanguage module is added to include into TOPLEVEL.
142
-
143
-
144
- == 2.0.0 / 2010-03-04
145
-
146
- This is a major new release of QED. All demonstration documents
147
- are now converted to HTML via Tilt (http://github.com/tilt) before
148
- being run through the test runner. So QED now supports any markup
149
- format supported by Tilt, as well as ordinary HTML. Simply
150
- stated, QED process <tt>pre</tt> tags as code and everything else
151
- as comments. Nokogiri is used to parse the HTML.
152
-
153
- Changes:
154
-
155
- * HTML serves as a common format.
156
- * New dependencies: Tilt and Nokogiri.
157
- * New system of version numbers.
158
-
159
-
160
- == 1.2.0 / 2009-12-07
161
-
162
- This release adds a significant new feature, Comment Matchers.
163
- These work like Cucumber allowing for background code to
164
- be run when matching comments occur --a much better solution
165
- for setup and teardown.
166
-
167
- Changes:
168
-
169
- * 2 Major Enhancements
170
-
171
- * Added command matchers via #When method.
172
- * All QED methods are now capitalized.
173
-
174
- * 2 Minor Enhancements
175
-
176
- * Use OptionParser for qed exectuable.
177
- * Verbatim reporter is literally verbatim.
178
-
179
-
180
- == 1.1.1 / 2009-09-05
181
-
182
- This release
183
-
184
- Changes:
185
-
186
- * 2 Major Enhancements
187
-
188
- * Helpers are provided by bottom code.
189
- * Added Markdown header support.
190
-
191
- * 2 Minor Enhancements
192
-
193
- * Use Ansi project for color output.
194
- * Use latest RDoc version.
195
-
196
-
197
- == 1.0.0 / 2009-06-30
198
-
199
- QED has found itself. It took some time to really figure out
200
- what this project "was" and how it should best be utilized.
201
- This release is the initial release that puts QED in proper
202
- perpective.
203
-
204
- Changes:
205
-
206
- * 2 Major Enhancement
207
-
208
- * Partial rewrite of a project that was once called "Quarry".
209
- * Now uese AE for assertions.
210
-
data/eg/hello_world.rdoc DELETED
@@ -1,15 +0,0 @@
1
- = Hello World
2
-
3
- Did you know that famous `Hello World` moniker is
4
- eleven characters long?
5
-
6
- "Hello World".size.assert == 11
7
-
8
- To pass a piece of literal text on with a description
9
- we simply need to end it with a ...
10
-
11
- Now this text will appear verbatim.
12
- In the applique arguments.
13
-
14
- That's all.
15
-
data/eg/view_error.rdoc DELETED
@@ -1,21 +0,0 @@
1
- = Examples of Failure
2
-
3
- This document is here simply to demonstrate what
4
- a failed and error raising code steps looks like.
5
-
6
- When run with the -v (verbatim) option, for instance, +qed+
7
- will highlight the following sections in red and give a brief
8
- error message.
9
-
10
- == Failure
11
-
12
- This step demonstrates a failed assertion.
13
-
14
- 1.assert == 2
15
-
16
- == Error
17
-
18
- This step demonstrates a raised error.
19
-
20
- raise "Just because"
21
-
data/eg/website.rdoc DELETED
@@ -1,12 +0,0 @@
1
- = Addition
2
-
3
- require 'calculator'
4
- calculator = Caclulater.new
5
-
6
- A Calculator can add two numbers.
7
-
8
- calculator.push 2
9
- calculator.push 2
10
- calculator.add
11
- calculator.output.assert == 4
12
-