eac_ruby_utils 0.60.0 → 0.61.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_ruby_utils/fs/logs.rb +63 -0
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a49138197a3fe16cb9a5e1f22326be1240a10f568c3ddc913e9c6f2a7501475
|
4
|
+
data.tar.gz: e218f41a27514ca27c634619ae7eecc3fe4d7442ba546a9c24f584d437ecfe77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3000972a617e1f15500506c4e61909c50418dd9794c6516154962dd5f55b1173b612aa9d1bf0c23dbaee205ccc01abd93b1349f80147c53bc4f3640bb7739e6
|
7
|
+
data.tar.gz: 9a021a5edb6bb22208d22cfc45fd17a486f9cd6c919a8a9495b2afe3b75a51b238172fd350f6977edd02669f7e77beab1ed7e53f7070bd36ebfa058dc52273a4
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string/filters'
|
4
|
+
require 'eac_ruby_utils/fs/temp'
|
5
|
+
require 'filesize'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
module Fs
|
9
|
+
class Logs
|
10
|
+
TRUNCATE_DEFAULT_LENGTH = 1000
|
11
|
+
TRUNCATE_APPEND_TEXT = '(...) '
|
12
|
+
|
13
|
+
def [](label)
|
14
|
+
log_set.fetch(sanitize_label(label))
|
15
|
+
end
|
16
|
+
|
17
|
+
def add(label)
|
18
|
+
log_set[sanitize_label(label)] = ::EacRubyUtils::Fs::Temp.file
|
19
|
+
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def remove_all
|
24
|
+
log_set.each_key { |label| remove(label) }
|
25
|
+
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove(label)
|
30
|
+
log_set.fetch(sanitize_label(label)).remove
|
31
|
+
log_set.delete(sanitize_label(label))
|
32
|
+
end
|
33
|
+
|
34
|
+
def truncate(label, length = TRUNCATE_DEFAULT_LENGTH)
|
35
|
+
content = self[label].read.strip
|
36
|
+
return content if content.length <= TRUNCATE_DEFAULT_LENGTH
|
37
|
+
|
38
|
+
TRUNCATE_APPEND_TEXT + content[content.length - length + TRUNCATE_APPEND_TEXT.length,
|
39
|
+
length - TRUNCATE_APPEND_TEXT.length]
|
40
|
+
end
|
41
|
+
|
42
|
+
def truncate_all(length = TRUNCATE_DEFAULT_LENGTH)
|
43
|
+
s = "Files: #{log_set.length}\n"
|
44
|
+
log_set.each do |label, path|
|
45
|
+
x = truncate(label, length)
|
46
|
+
y = [label, path, ::Filesize.from("#{path.size} B").pretty].join(' / ')
|
47
|
+
s += x.blank? ? ">>> #{y} (Blank) <<<" : ">>> #{y}\n#{x}\n<<< #{y}\n"
|
48
|
+
end
|
49
|
+
s
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def sanitize_label(label)
|
55
|
+
label.to_sym
|
56
|
+
end
|
57
|
+
|
58
|
+
def log_set
|
59
|
+
@log_set ||= {}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_ruby_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.61.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.6.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: filesize
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: net-ssh
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,6 +176,7 @@ files:
|
|
162
176
|
- lib/eac_ruby_utils/fs.rb
|
163
177
|
- lib/eac_ruby_utils/fs/clearable_directory.rb
|
164
178
|
- lib/eac_ruby_utils/fs/extname.rb
|
179
|
+
- lib/eac_ruby_utils/fs/logs.rb
|
165
180
|
- lib/eac_ruby_utils/fs/temp.rb
|
166
181
|
- lib/eac_ruby_utils/fs/temp/directory.rb
|
167
182
|
- lib/eac_ruby_utils/fs/temp/file.rb
|
@@ -276,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
276
291
|
- !ruby/object:Gem::Version
|
277
292
|
version: '0'
|
278
293
|
requirements: []
|
279
|
-
rubygems_version: 3.0.
|
294
|
+
rubygems_version: 3.0.9
|
280
295
|
signing_key:
|
281
296
|
specification_version: 4
|
282
297
|
summary: Utilities for E.A.C.'s Ruby projects.
|