simple_rotate 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf3e13b061ee59983bddd60110493b35b7be8fa2
|
4
|
+
data.tar.gz: cb2c4c5e947b82092798deec43d60e64d21e287a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 325ec9d77167f9a9e9002de74a954a930d7961d8564df404bc93b489c36db5a90e95561924bdd87aed57b7dd45832e63cac91819374a108a977ee8ca2120100d
|
7
|
+
data.tar.gz: cb1fe8acbab5443665cb84215467043e479753abab26dae55fd3720b5131cb2e08ef13e3843586a0a32a205532feb4bde9a249053b9c1ba5e8b8a1eae1fd882e
|
data/lib/simple_rotate/const.rb
CHANGED
data/lib/simple_rotate/core.rb
CHANGED
@@ -24,7 +24,9 @@ class SimpleRotate
|
|
24
24
|
return self if file_name == nil
|
25
25
|
|
26
26
|
@try_limit = 3
|
27
|
-
@@tempf_name = File.dirname(file_name) + File::SEPARATOR + ".
|
27
|
+
@@tempf_name = File.dirname(file_name) + File::SEPARATOR + ".simple_rotate_tempfile_#{File.basename($0)}"
|
28
|
+
# replace whitespaces
|
29
|
+
@@tempf_name.gsub!(/\s/, '_')
|
28
30
|
|
29
31
|
create_tempfile if @enable && !@@scheduled_del_lockfile
|
30
32
|
end
|
@@ -32,19 +34,16 @@ class SimpleRotate
|
|
32
34
|
# Create the temp file for locking
|
33
35
|
private
|
34
36
|
def create_tempfile
|
35
|
-
if File.exist?(@@tempf_name)
|
36
|
-
open_temp_file
|
37
|
-
return nil
|
38
|
-
end
|
39
|
-
|
40
37
|
begin
|
41
|
-
|
38
|
+
if tempf_exists?
|
39
|
+
set_delete_tempfile
|
40
|
+
else
|
41
|
+
@@tempf = File.open(@@tempf_name, File::RDWR|File::CREAT|File::EXCL)
|
42
|
+
set_delete_tempfile
|
43
|
+
end
|
42
44
|
|
43
45
|
rescue
|
44
|
-
SimpleRotate::Error.warning("
|
45
|
-
|
46
|
-
ensure
|
47
|
-
set_delete_tempfile
|
46
|
+
SimpleRotate::Error.warning("Failed to create temp file => #{@@tempf_name}")
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
@@ -58,7 +57,7 @@ class SimpleRotate
|
|
58
57
|
def set_delete_tempfile
|
59
58
|
return true if @@scheduled_del_lockfile
|
60
59
|
|
61
|
-
if
|
60
|
+
if tempf_exists?
|
62
61
|
# is it empty?
|
63
62
|
if File.size(@@tempf_name) == 0
|
64
63
|
delete_at_end
|
@@ -78,7 +77,7 @@ class SimpleRotate
|
|
78
77
|
begin
|
79
78
|
File.delete(@@tempf_name)
|
80
79
|
rescue
|
81
|
-
|
80
|
+
SimpleRotate::Error.warning("Failed to delete temp file => #{@@tempf_name}")
|
82
81
|
end
|
83
82
|
end
|
84
83
|
end
|
@@ -95,7 +94,7 @@ class SimpleRotate
|
|
95
94
|
begin
|
96
95
|
@@tempf = File.open(@@tempf_name, File::RDWR|File::CREAT|File::APPEND)
|
97
96
|
rescue
|
98
|
-
SimpleRotate::Error.warning("
|
97
|
+
SimpleRotate::Error.warning("Failed to open temp file => #{@@tempf_name}")
|
99
98
|
end
|
100
99
|
end
|
101
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_rotate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khotta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Simple and safety logger. http://khotta.github.io/
|
14
14
|
email:
|