Skip to content

Commit

Permalink
Use Tempfile
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Nov 30, 2022
1 parent fadc712 commit 0b9dde5
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/rdoc/rd/block_parser.ry
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ end

# :stopdoc:

TMPFILE = ["rdtmp", $$, 0]

MARK_TO_LEVEL = {
'=' => 1,
'==' => 2,
Expand Down Expand Up @@ -360,11 +358,10 @@ def next_token # :nodoc:
if @tree.filter[@in_part].mode == :rd # if output is RD formatted
subtree = parse_subtree(part_out.to_a)
else # if output is target formatted
basename = TMPFILE.join('.')
TMPFILE[-1] += 1
tmpfile = open(@tree.tmp_dir + "/" + basename + ".#{@in_part}", "w")
tmpfile.print(part_out)
tmpfile.close
basename = Tempfile.create(["rdtmp", ".#{@in_part}"], @tree.tmp_dir) do |tmpfile|
tmpfile.print(part_out)
File.basename(tmpfile.path)
end
subtree = parse_subtree(["=begin\n", "<<< #{basename}\n", "=end\n"])
end
@in_part = nil
Expand Down

0 comments on commit 0b9dde5

Please sign in to comment.