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: be22a3c38d7b281549b2f6f2b782793ba8a6a3ab
4
- data.tar.gz: d19711617196e08109a09c536010ce4296cd886f
3
+ metadata.gz: bf3e13b061ee59983bddd60110493b35b7be8fa2
4
+ data.tar.gz: cb2c4c5e947b82092798deec43d60e64d21e287a
5
5
  SHA512:
6
- metadata.gz: fcb0a5ad487e2f07c82cf6225155958922d3afde9f2cb9fec950c427482843477a1d149c72fe096227d25bda0b56d8d60dae2c7ce91903629d5d759abef1fb38
7
- data.tar.gz: c962cdad590764c25af7f8bbee41beb655b8cae1069890474133e6be1c32a44d9837e1b61466abced8b7a6562f091aa69eb5d7d2680e089af520c3503cda18f3
6
+ metadata.gz: 325ec9d77167f9a9e9002de74a954a930d7961d8564df404bc93b489c36db5a90e95561924bdd87aed57b7dd45832e63cac91819374a108a977ee8ca2120100d
7
+ data.tar.gz: cb1fe8acbab5443665cb84215467043e479753abab26dae55fd3720b5131cb2e08ef13e3843586a0a32a205532feb4bde9a249053b9c1ba5e8b8a1eae1fd882e
@@ -1,6 +1,6 @@
1
1
  class SimpleRotate
2
2
  LIBS_NAME = "simple_rotate"
3
- VERSION = "1.1.1"
3
+ VERSION = "1.2.0"
4
4
  SUMMARY = "Simple and safety logger."
5
5
  HOMEPAGE = "http://khotta.github.io/"
6
6
  DESCRIPTION = "#{SUMMARY} #{HOMEPAGE}"
@@ -78,7 +78,7 @@ class SimpleRotate
78
78
  @psync.unlock
79
79
  end
80
80
 
81
- # if block given, colse IO
81
+ # if block is given, colse IO
82
82
  if defined? yield
83
83
  yield self
84
84
  e
@@ -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 + ".SimpleRotate_tempfile_#{File.basename($0)}"
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
- @@tempf = File.open(@@tempf_name, File::RDWR|File::CREAT|File::EXCL)
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("Couldn't create temp file => #{@@tempf_name}")
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 File.exist?(@@tempf_name)
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
- #SimpleRotate::Error.warning("Couldn't delete temp file => #{@@tempf_name}")
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("Couldn't open temp file => #{@@tempf_name}")
97
+ SimpleRotate::Error.warning("Failed to open temp file => #{@@tempf_name}")
99
98
  end
100
99
  end
101
100
  end
@@ -14,8 +14,6 @@ module ProcessSyncMixin
14
14
 
15
15
  # lock the temp file
16
16
  def lock
17
- create_tempfile if !tempf_exists?
18
-
19
17
  reopen_temp_file
20
18
 
21
19
  cnt = 0
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.1.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: 2016-12-09 00:00:00.000000000 Z
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: