compresslog 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/compresslog.gemspec +15 -0
- data/lib/compresslog.rb +53 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b65e1ad93dc3534a114c9ea5f1a23f5ef3cc909d
|
4
|
+
data.tar.gz: 89d10fcd80d41b4e46a66e8fd2eeb362a23b39bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f1b730419ea93d1df56a7813a2301457c925aafbaef5a617daa8c2fbe1a291d9a5f9dc27faf25752369847eed633bcd9666b053abada1ee45b1b4906762dfcf
|
7
|
+
data.tar.gz: 13a925835e7d9094ecee660f1078d239c73cbbbf6588efb910c98c97cf35de969c967c45712fa738bef5e5ce19a3740dc98b25d98e169efee1414074ca963a71
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/compresslog.gemspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "compresslog"
|
3
|
+
s.version = "0.2.2"
|
4
|
+
s.description = "Gem compress to log application"
|
5
|
+
s.summary = "compress log"
|
6
|
+
s.author = "Samuel Blum Vorpagel"
|
7
|
+
s.email = "sbvorpagel@gmail.com"
|
8
|
+
s.homepage = "https://github.com/sbvorpagel/rails-compresslog"
|
9
|
+
|
10
|
+
s.files = Dir["{lib/**/*.rb,README.rdoc,test/**/*.rb,Rakefile,*.gemspec}"]
|
11
|
+
|
12
|
+
s.add_runtime_dependency "zip-zip", "= 0.3"
|
13
|
+
s.add_runtime_dependency "rubyzip", "= 1.1.6"
|
14
|
+
|
15
|
+
end
|
data/lib/compresslog.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'zip'
|
2
|
+
|
3
|
+
def backutp_is_needed?
|
4
|
+
dir = Dir.entries("#{Rails.root.join("log")}").grep /^#{Rails.env}.log./
|
5
|
+
return !dir.empty?
|
6
|
+
end
|
7
|
+
|
8
|
+
def log_compress
|
9
|
+
data = Time.new.strftime("%Y%m%d_%H%M%S")
|
10
|
+
folder = Rails.root.join("log")
|
11
|
+
input_filenames = Dir.entries("#{folder}").grep /^#{Rails.env}.log./
|
12
|
+
zipfile_name = "#{folder}/#{data}.zip"
|
13
|
+
|
14
|
+
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
15
|
+
input_filenames.each do |filename|
|
16
|
+
zipfile.add(filename, "#{folder}/#{filename}")
|
17
|
+
end
|
18
|
+
zipfile.get_output_stream("README") { |os| os.write "O backup, dos logs, foi realizado com sucesso em: #{Time.now}" }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def log_delete
|
23
|
+
|
24
|
+
data = Time.new.strftime("%Y%m%d_%H%M%S")
|
25
|
+
folder = Rails.root.join("log")
|
26
|
+
input_filenames = Dir.entries("#{folder}").grep /^#{Rails.env}.log./
|
27
|
+
zipfile_name = "#{folder}/#{data}.zip"
|
28
|
+
|
29
|
+
input_filenames.each do |i|
|
30
|
+
File.delete("#{folder}/#{i}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def log_compress_full
|
35
|
+
data = Time.new.strftime("%Y%m%d_%H%M%S")
|
36
|
+
folder = Rails.root.join("log")
|
37
|
+
input_filenames = Dir.entries("#{folder}").grep /^#{Rails.env}.log./
|
38
|
+
zipfile_name = "#{folder}/#{data}.zip"
|
39
|
+
unless (input_filenames.empty?)
|
40
|
+
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
41
|
+
input_filenames.each do |filename|
|
42
|
+
zipfile.add(filename, "#{folder}/#{filename}")
|
43
|
+
end
|
44
|
+
zipfile.get_output_stream("README") { |os| os.write "O backup, dos logs, foi realizado com sucesso em: #{Time.now}" }
|
45
|
+
end
|
46
|
+
|
47
|
+
input_filenames.each do |i|
|
48
|
+
File.delete("#{folder}/#{i}")
|
49
|
+
end
|
50
|
+
else
|
51
|
+
"backup desnecessário"
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compresslog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Blum Vorpagel
|
@@ -43,7 +43,10 @@ email: sbvorpagel@gmail.com
|
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
|
-
files:
|
46
|
+
files:
|
47
|
+
- Rakefile
|
48
|
+
- compresslog.gemspec
|
49
|
+
- lib/compresslog.rb
|
47
50
|
homepage: https://github.com/sbvorpagel/rails-compresslog
|
48
51
|
licenses: []
|
49
52
|
metadata: {}
|