lib/hx.rb in hx-0.7.2 vs lib/hx.rb in hx-0.7.4
- old
+ new
@@ -123,20 +123,17 @@
Regexp.new("(?:#{patterns.map { |p| pattern_to_re(p) }.join("|")})")
end
private :patterns_to_re
def pattern_to_re(pattern)
- "^#{pattern.scan(/(\*\*)|(\*)|([^*]+)/).map { |s2, s, r|
- case
- when s2
- ".*"
- when s
- "[^/]*"
- when r
- Regexp.quote(r)
+ "^#{pattern.scan(/(\*\*?|[^*]+)/).map { |s,|
+ case s
+ when "**"; ".*"
+ when "*"; "[^/]*"
+ else Regexp.quote(s)
end
- }.join("")}$"
+ }}$"
end
private :pattern_to_re
end
class Overlay
@@ -568,9 +565,10 @@
parent = pathname.parent
parent.mkpath()
tempfile = Tempfile.new('.hx-out', parent.to_s)
begin
File.open(tempfile.path, "wb") { |stream| stream << content.to_s }
+ File.chmod(0666 & ~File.umask, tempfile.path)
File.rename(tempfile.path, pathname.to_s)
ensure
tempfile.unlink
end
nil