Skip to content
Snippets Groups Projects
Commit 123f7cd0 authored by Max Howell's avatar Max Howell Committed by Adam Vandenberg
Browse files

Pathname.ensure_writable

Yields after chmoding (if necessary), once block is complete restores permissions.
parent 55bd25ff
No related branches found
No related tags found
No related merge requests found
......@@ -238,6 +238,16 @@ class Pathname
def / that
join that.to_s
end
def ensure_writable
saved_perms = unless writable?
chmod 0644
stat.mode
end
yield
ensure
chmod saved_perms if saved_perms
end
end
# sets $n and $d so you can observe creation of stuff
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment