hx 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/hx.rb +10 -2
- data/lib/hx/commandline.rb +1 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
data/lib/hx.rb
CHANGED
@@ -25,6 +25,7 @@ require 'rubygems'
|
|
25
25
|
require 'thread'
|
26
26
|
require 'set'
|
27
27
|
require 'pathname'
|
28
|
+
require 'tempfile'
|
28
29
|
require 'yaml'
|
29
30
|
|
30
31
|
module Hx
|
@@ -564,8 +565,15 @@ def self.refresh_file(pathname, content, update_time)
|
|
564
565
|
end
|
565
566
|
|
566
567
|
def self.write_file(pathname, content)
|
567
|
-
pathname.parent
|
568
|
-
|
568
|
+
parent = pathname.parent
|
569
|
+
parent.mkpath()
|
570
|
+
tempfile = Tempfile.new('.hx-out', parent.to_s)
|
571
|
+
begin
|
572
|
+
File.open(tempfile.path, "wb") { |stream| stream << content.to_s }
|
573
|
+
File.rename(tempfile.path, pathname.to_s)
|
574
|
+
ensure
|
575
|
+
tempfile.unlink
|
576
|
+
end
|
569
577
|
nil
|
570
578
|
end
|
571
579
|
|
data/lib/hx/commandline.rb
CHANGED