hx 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/hx.rb +10 -2
  3. data/lib/hx/commandline.rb +1 -0
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
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.mkpath()
568
- pathname.open("wb") { |stream| stream << content.to_s }
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
 
@@ -42,6 +42,7 @@ Usage: hx [--config CONFIG_FILE] [upgen]
42
42
  hx [--config CONFIG_FILE] regen
43
43
  hx [--config CONFIG_FILE] post[up] SOURCE:PATH
44
44
  hx [--config CONFIG_FILE] edit[up] SOURCE:PATH
45
+
45
46
  EOS
46
47
 
47
48
  opts.on("-c", "--config CONFIG_FILE",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MenTaLguY