Skip to content

Commit 0b9dde5

Browse files
committedNov 30, 2022
Use Tempfile
1 parent fadc712 commit 0b9dde5

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed
 

Diff for: ‎lib/rdoc/rd/block_parser.ry

+4-7
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ end
230230

231231
# :stopdoc:
232232

233-
TMPFILE = ["rdtmp", $$, 0]
234-
235233
MARK_TO_LEVEL = {
236234
'=' => 1,
237235
'==' => 2,
@@ -360,11 +358,10 @@ def next_token # :nodoc:
360358
if @tree.filter[@in_part].mode == :rd # if output is RD formatted
361359
subtree = parse_subtree(part_out.to_a)
362360
else # if output is target formatted
363-
basename = TMPFILE.join('.')
364-
TMPFILE[-1] += 1
365-
tmpfile = open(@tree.tmp_dir + "/" + basename + ".#{@in_part}", "w")
366-
tmpfile.print(part_out)
367-
tmpfile.close
361+
basename = Tempfile.create(["rdtmp", ".#{@in_part}"], @tree.tmp_dir) do |tmpfile|
362+
tmpfile.print(part_out)
363+
File.basename(tmpfile.path)
364+
end
368365
subtree = parse_subtree(["=begin\n", "<<< #{basename}\n", "=end\n"])
369366
end
370367
@in_part = nil

0 commit comments

Comments
 (0)