summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2023-09-21 01:28:33 +0900
committerNobuyoshi Nakada <[email protected]>2023-09-21 12:19:00 +0900
commit7ba88e13e00720a3190aca3bda3e7b50b390b096 (patch)
tree5a6563d8530e0bdff2c4081fd06641359102b005
parent2b41df247794103a4d392c763156b02451772237 (diff)
Make `clean.create` to accept a block
Like `File.open`, yield an IO to write the file.
-rwxr-xr-xtool/make-snapshot19
1 files changed, 16 insertions, 3 deletions
diff --git a/tool/make-snapshot b/tool/make-snapshot
index 3e5689e873..eb26a87cc4 100755
--- a/tool/make-snapshot
+++ b/tool/make-snapshot
@@ -384,8 +384,21 @@ def package(vcs, rev, destdir, tmp = nil)
puts $colorize.fail("patching failed")
return
end
- def (clean = []).add(n) push(n); n end
- def clean.create(file, content = "") File.binwrite(add(file), content) end
+
+ class << (clean = [])
+ def add(n) push(n)
+ n
+ end
+ def create(file, content = "", &block)
+ add(file)
+ if block
+ File.open(file, "wb", &block)
+ else
+ File.binwrite(file, content)
+ end
+ end
+ end
+
Dir.chdir(v) do
unless File.exist?("ChangeLog")
vcs.export_changelog(url, nil, revision, "ChangeLog")
@@ -406,7 +419,7 @@ def package(vcs, rev, destdir, tmp = nil)
puts
end
- File.open(clean.add("cross.rb"), "w") do |f|
+ clean.create("cross.rb") do |f|
f.puts "Object.__send__(:remove_const, :CROSS_COMPILING) if defined?(CROSS_COMPILING)"
f.puts "CROSS_COMPILING=true"
f.puts "Object.__send__(:remove_const, :RUBY_PLATFORM)"