file_writer 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/file_writer.rb +11 -5
- data/lib/file_writer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eddfcd731230df1ecb8a42b44c94eb65ce81aec
|
4
|
+
data.tar.gz: 85167825bd894a4af7284fc7c3b37db181df84e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a2993da7a7d9ed78c47a740c77035c64f62dc07aaef5ac9a8fdc68c4d30225ab27ccbd3c2d0c32deacaf0d7568f338cfeed174759d673138757869daa29eba0
|
7
|
+
data.tar.gz: d8d0b398b7fa56970992ca2f8faf0eaedc0dc1a708986664075cdc9ac7012e810945bc20f5e7f31199ab544839984ac830b068cbe355bf36d81be8b0a7f0a24e
|
data/lib/file_writer.rb
CHANGED
@@ -21,12 +21,18 @@ class FileWriter
|
|
21
21
|
#
|
22
22
|
def write(contents)
|
23
23
|
backup = fname + "~"
|
24
|
-
mode = File.stat(fname).mode
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
existing = File.exists?(fname)
|
26
|
+
|
27
|
+
if existing
|
28
|
+
mode = File.stat(fname).mode
|
29
|
+
begin
|
30
|
+
File.rename(fname, backup)
|
31
|
+
rescue SystemCallError
|
32
|
+
FileUtils.cp(fname,fname+"~")
|
33
|
+
end
|
34
|
+
else
|
35
|
+
mode = nil
|
30
36
|
end
|
31
37
|
|
32
38
|
File.open(fname, "wb+", mode) do |f|
|
data/lib/file_writer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_writer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vidar Hokstad
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|