eac_ruby_utils 0.80.0 → 0.82.1
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/lib/eac_ruby_utils/abstract_methods.rb +2 -1
- data/lib/eac_ruby_utils/patches/object/debug.rb +1 -1
- data/lib/eac_ruby_utils/patches/pathname/mkpath_s.rb +12 -0
- data/lib/eac_ruby_utils/simple_cache.rb +16 -6
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +11 -5
- data/lib/eac_ruby_utils/fs/logs.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aadd4c1c181c8e7ff64e358edb5e34c37c7a203e8937897739256728fb2c1df
|
4
|
+
data.tar.gz: b92a231502afe5c23930c88b74eef1b122c4dc4e1c5aa2d5fd82724ee4fdae5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82a52d0d7f8d663994497e7672f64f357a79767c4237dc5aaccc39c1e01c63dd75714f7cd9ccba8acb677ff3af8df1ee20849a30f8c3d7c8e5d000dbf0f5d782
|
7
|
+
data.tar.gz: 191e846d8f896b1cd4915a34678336cf2d6fc4579545e9380341dc573f9d587a9ba0527d2fbebc7b68e295a2c8ff6ab79c2423524fac9e59475a0b8fda285aca
|
@@ -60,7 +60,8 @@ module EacRubyUtils
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def raise_abstract_method(method_name)
|
63
|
-
raise ::NoMethodError, "Abstract method \"#{method_name}\" hit in \"#{self}\""
|
63
|
+
raise ::NoMethodError, "Abstract method \"#{method_name}\" hit in \"#{self}\"" \
|
64
|
+
" (Class: #{self.class})"
|
64
65
|
end
|
65
66
|
end
|
66
67
|
end
|
@@ -20,7 +20,7 @@ module EacRubyUtils
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def method_missing(method, *args, &block)
|
23
|
-
if respond_to?(
|
23
|
+
if respond_to?(uncached_method_name(method), true)
|
24
24
|
call_method_with_cache(method, args, &block)
|
25
25
|
else
|
26
26
|
super
|
@@ -37,27 +37,37 @@ module EacRubyUtils
|
|
37
37
|
|
38
38
|
def reset_cache(*keys)
|
39
39
|
if keys.any?
|
40
|
-
keys.each { |key| cache_keys.delete(key) }
|
40
|
+
keys.each { |key| cache_keys.delete(sanitize_cache_key(key)) }
|
41
41
|
else
|
42
42
|
@cache_keys = nil
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def sanitize_cache_key(key)
|
47
|
+
key.to_s.to_sym
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def uncached_method_name(original_method_name)
|
53
|
+
::EacRubyUtils::SimpleCache.uncached_method_name(original_method_name)
|
54
|
+
end
|
55
|
+
|
46
56
|
private
|
47
57
|
|
48
58
|
def call_method_with_cache(method, args, &block)
|
49
59
|
raise 'Não é possível realizar o cache de métodos com bloco' if block
|
50
60
|
|
51
61
|
key = ([method] + args).join('@@@')
|
52
|
-
unless cache_keys.key?(key)
|
62
|
+
unless cache_keys.key?(sanitize_cache_key(key))
|
53
63
|
uncached_value = call_uncached_method(method, args)
|
54
|
-
cache_keys[key] = uncached_value
|
64
|
+
cache_keys[sanitize_cache_key(key)] = uncached_value
|
55
65
|
end
|
56
|
-
cache_keys[key]
|
66
|
+
cache_keys[sanitize_cache_key(key)]
|
57
67
|
end
|
58
68
|
|
59
69
|
def call_uncached_method(method, args)
|
60
|
-
send(
|
70
|
+
send(uncached_method_name(method), *args)
|
61
71
|
end
|
62
72
|
|
63
73
|
def cache_keys
|
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.82.1
|
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-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4
|
19
|
+
version: '4'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '4
|
29
|
+
version: '4'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: addressable
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,7 +138,6 @@ files:
|
|
132
138
|
- lib/eac_ruby_utils/fs.rb
|
133
139
|
- lib/eac_ruby_utils/fs/clearable_directory.rb
|
134
140
|
- lib/eac_ruby_utils/fs/extname.rb
|
135
|
-
- lib/eac_ruby_utils/fs/logs.rb
|
136
141
|
- lib/eac_ruby_utils/fs/temp.rb
|
137
142
|
- lib/eac_ruby_utils/fs/temp/directory.rb
|
138
143
|
- lib/eac_ruby_utils/fs/temp/file.rb
|
@@ -199,6 +204,7 @@ files:
|
|
199
204
|
- lib/eac_ruby_utils/patches/object/to_pathname.rb
|
200
205
|
- lib/eac_ruby_utils/patches/pathname.rb
|
201
206
|
- lib/eac_ruby_utils/patches/pathname/basename_sub.rb
|
207
|
+
- lib/eac_ruby_utils/patches/pathname/mkpath_s.rb
|
202
208
|
- lib/eac_ruby_utils/patches/pathname/parent_n.rb
|
203
209
|
- lib/eac_ruby_utils/patches/regexp.rb
|
204
210
|
- lib/eac_ruby_utils/patches/regexp/if_match.rb
|
@@ -1,63 +0,0 @@
|
|
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
|