qed 3.0.1 → 3.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0919807f2f9306df109a4e07d4a8af55e2189c2ffa9aa4c28e0ca3d522e53699'
4
- data.tar.gz: 3c3a57484b48d528a7a92d9d51c6fb2b1bdffffb979be268479503cdec7f5fb4
3
+ metadata.gz: 1e859a8b406be860b774e565210d752764d661c8f699a8877a15697f206e413a
4
+ data.tar.gz: 23633b17dffb15a02824df4d64900f2c20cda6212f211cffe81fb72eaa2983a0
5
5
  SHA512:
6
- metadata.gz: 6ef62a1cca8766764df08ebc9ed14841d4171768ff3d59fb072ebaf7c491860da59f681911a051b9bbd39d02282a2f704988533759ec2fe904dbd698a857e725
7
- data.tar.gz: 903f2cfabdbbbfb9aae12251d1a2a84c44a34b6d46e2fd651a2b94841a27ca48ae56e7da697e3bf4e7ce6eee1e40b993bcec8998f96ace011e540b37b8c22302
6
+ metadata.gz: c612dfba89c214c1fc2bed469f43da2d2a2ec5d85a94c16973f1e6706f2467db49955f4cda4d61443b2be0f2114a62a0bc876df99c94f38b373c1157302510a7
7
+ data.tar.gz: 3883aed91cb2ff8b5a69d4837184a348d06b954bebd7d6f15689b9cea105249315a81426b49b297c90137836cc4a072b10c8b4990567335e2cd457c1ec5be2e4
data/HISTORY.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # RELEASE HISTORY
2
2
 
3
+ ## 3.0.2 | 2026-11-29
4
+
5
+ Bug Fixes:
6
+
7
+ * The `clear_working_directory!` helper works again. It raised a TypeError
8
+ ("no implicit conversion of nil into String"), as the directory it was
9
+ to clear was never set. It now clears the temporary directory the
10
+ demonstrations are run in, hidden files included, and raises an error
11
+ if they are being run from the project's root (`--rooted`), where there
12
+ is no temporary directory.
13
+
3
14
  ## 3.0.1 | 2026-11-13
4
15
 
5
16
  Bug Fixes:
@@ -0,0 +1,41 @@
1
+ # Working Directory
2
+
3
+ Demonstrations are run in a temporary directory, `tmp/qed` in the project,
4
+ so that the files they make are kept out of the way.
5
+
6
+ File.basename(Dir.pwd).assert == 'qed'
7
+
8
+ Let's make a few files there, one of them hidden and one in a directory
9
+ of its own.
10
+
11
+ require 'fileutils'
12
+
13
+ File.write('example.txt', 'An example.')
14
+ File.write('.hidden', 'Hidden.')
15
+
16
+ FileUtils.mkdir_p('sub/dir')
17
+ File.write('sub/dir/deep.txt', 'Deep.')
18
+
19
+ The directory is cleared before a session starts. To clear it at other
20
+ times, say before each demonstration, there is the `clear_working_directory!`
21
+ helper.
22
+
23
+ clear_working_directory!
24
+
25
+ Everything in it is gone,
26
+
27
+ Dir.children('.').assert == []
28
+
29
+ and the directory itself remains, with us still in it.
30
+
31
+ File.assert.directory?(Dir.pwd)
32
+
33
+ It is usually called from an applique file, like so:
34
+
35
+ Before :demo do
36
+ clear_working_directory!
37
+ end
38
+
39
+ When demonstrations are run from the project's root instead, with the
40
+ `--rooted` option, there is no temporary directory, and the helper raises
41
+ an error in place of clearing the project.
data/lib/qed/evaluator.rb CHANGED
@@ -27,13 +27,21 @@ module QED
27
27
  @demo = demo
28
28
  @steps = demo.steps
29
29
 
30
- #@settings = options[:settings]
30
+ @settings = options[:settings]
31
31
  @applique = options[:applique] # BOOLEAN FLAG
32
32
 
33
33
  @observers = options[:observers].to_a
34
34
  @observers += applique_observers
35
35
 
36
- @scope = options[:scope] || Scope.new(demo)
36
+ @scope = options[:scope] || Scope.new(demo, :tmpdir=>temporary_directory)
37
+ end
38
+
39
+ # The temporary directory the demos are run in, or nil when they are
40
+ # run from the project's root (--rooted) or outside of a session.
41
+ def temporary_directory
42
+ return nil unless @settings
43
+ return nil if @settings.rooted
44
+ @settings.tmpdir
37
45
  end
38
46
 
39
47
  # Collect applique all the signal-based advice and wrap their evaluation
data/lib/qed/scope.rb CHANGED
@@ -16,7 +16,7 @@ module QED
16
16
  @_applique = demo.applique_prime
17
17
 
18
18
  @_file = demo.file
19
- @_root = options[:root] || $ROOT # FIXME
19
+ @_tmpdir = options[:tmpdir]
20
20
 
21
21
  @_features = []
22
22
 
@@ -164,29 +164,35 @@ module QED
164
164
  end
165
165
  end
166
166
 
167
- # Helper method to clear temporary work directory.
167
+ # Helper method to clear the temporary work directory, the one the
168
+ # demos are run in (usually `tmp/qed` in the project). Everything in
169
+ # it is removed, hidden files included; the directory itself stays.
170
+ #
171
+ # It is an error to call it when the demos are not being run in a
172
+ # temporary directory, as with the `--rooted` option, since the
173
+ # directory cleared would then be the project itself.
168
174
  #
169
175
  def clear_working_directory!
170
- dir = @_root
171
- dir = File.expand_path(dir)
176
+ unless @_tmpdir
177
+ raise "No temporary directory to clear: " \
178
+ "the demos are being run from the project's root."
179
+ end
180
+
181
+ dir = File.expand_path(@_tmpdir)
172
182
 
173
- if dir == '/' or dir == File.expand_path('~')
174
- abort "DANGER! Trying to use home or root as a temporary directory!"
183
+ if dir == '/' or dir == File.expand_path('~') or dir == File.expand_path(Utils.root)
184
+ abort "DANGER! Trying to use home, root or the project as a temporary directory!"
175
185
  end
176
186
 
177
- entries = Dir.glob(File.join(dir, '**/*'))
187
+ return unless File.directory?(dir)
178
188
 
179
- dirs, files = entries.partition{ |f| File.directory?(f) }
189
+ require 'fileutils'
180
190
 
181
- files.each { |file| FileUtils.rm(file) }
182
- dirs.each { |dir| FileUtils.rmdir(dir) }
191
+ Dir.children(dir).each do |entry|
192
+ FileUtils.rm_rf(File.join(dir, entry))
193
+ end
183
194
  end
184
195
 
185
- # TODO: Project's root directory.
186
- #def rootdir
187
- # @_root
188
- #end
189
-
190
196
  # Redirect constant missing to toplevel (i.e. Object). This is
191
197
  # to allow the evaluation scope to emulate the toplevel.
192
198
  def const_missing(const)
data/lib/qed/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module QED
2
- VERSION = '3.0.1'
2
+ VERSION = '3.0.2'
3
3
  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: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - trans
@@ -93,6 +93,7 @@ files:
93
93
  - demo/11_embedded_rules.md
94
94
  - demo/13_fenced_code_blocks.md
95
95
  - demo/14_comment_mode.md
96
+ - demo/15_working_directory.md
96
97
  - demo/99_issues/02_topcode.md
97
98
  - demo/applique/ae.rb
98
99
  - demo/applique/constant.rb