logbrarian 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/logbrarian +19 -0
- data/lib/logbrarian/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45b66b2007db632a830cd073b3d669f4f9fb6bd5
|
4
|
+
data.tar.gz: 3b8abbba2d519adb69ff3b7fa558122717028f0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22d1135e9f28601c605438c3f83bf738a7e43bfc22847998cc8293579cf9d114c2cf5cf50a1cc9bf2952364ed24a8cfcfc91ae9c72789e2b87b1ee2f361644aa
|
7
|
+
data.tar.gz: 118ba567f15564ad9f7fe1434d176f8bd82763c189ff68b4f94fdb2b0227d7fb843d520b3252b4d807086d88da08bc363331aaa7f7dac30ce3a45fbd2eec2c9e
|
data/bin/logbrarian
CHANGED
@@ -48,6 +48,21 @@ dir_path = File.dirname(current_path)
|
|
48
48
|
FileUtils.mkdir_p dir_path
|
49
49
|
FileUtils.touch current_path unless File.exist? current_path
|
50
50
|
|
51
|
+
begin
|
52
|
+
birthtime = File.birthtime(current_path)
|
53
|
+
rescue NotImplementedError
|
54
|
+
require 'yaml'
|
55
|
+
store_path = File.expand_path("~/.logbrarian.yml")
|
56
|
+
FileUtils.touch store_path
|
57
|
+
store = YAML.load_file(store_path) || Hash.new
|
58
|
+
birth_string = store[current_path] || Time.now.to_s
|
59
|
+
birthtime = DateTime.parse(birth_string).to_time
|
60
|
+
unless store.key?(current_path)
|
61
|
+
store[current_path] = birthtime
|
62
|
+
File.open(store_path, 'w') {|f| YAML.dump(store,f) }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
51
66
|
if File.birthtime(current_path) < options[:interval].ago
|
52
67
|
# Rotate older file
|
53
68
|
require 'zlib'
|
@@ -62,6 +77,10 @@ if File.birthtime(current_path) < options[:interval].ago
|
|
62
77
|
end
|
63
78
|
FileUtils.rm current_path
|
64
79
|
FileUtils.touch current_path
|
80
|
+
if store
|
81
|
+
store[current_path] = Time.now.to_s
|
82
|
+
File.open(store_path, 'w') {|f| YAML.dump(store,f) }
|
83
|
+
end
|
65
84
|
end
|
66
85
|
|
67
86
|
File.open(current_path, 'a') do |log|
|
data/lib/logbrarian/version.rb
CHANGED