eac_ruby_utils 0.80.1 → 0.83.0
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/context.rb +2 -0
- data/lib/eac_ruby_utils/patches/hash/to_struct.rb +10 -0
- 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 +12 -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: ead277954d30057deff2aadb9f960afabd477f983bacdd0dddd578ebfd5d1f69
|
4
|
+
data.tar.gz: c385ec742ac8e478d289f00891caadda9ac8447b2d2b781c99cb8203c33a4ea6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70ab1feb4ce84b8239e709992a90a27b854c03038a8aced9a3ea56b1a3954177ef3af5b0ec4ebec84d1ac9045f20926038581b0d4aeef130ffb551c0959d4f28
|
7
|
+
data.tar.gz: 31bb8905cbadfd73cf1514d9b1318e66bac201be7ae6e2537956bbebba5392c9f1ad61be8371fa7fbc08976d4491f7975d7ed899f10453d141582c5c19db36d4
|
@@ -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.83.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:
|
11
|
+
date: 2022-01-17 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
|
@@ -173,6 +178,7 @@ files:
|
|
173
178
|
- lib/eac_ruby_utils/patches/hash.rb
|
174
179
|
- lib/eac_ruby_utils/patches/hash/options_consumer.rb
|
175
180
|
- lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
|
181
|
+
- lib/eac_ruby_utils/patches/hash/to_struct.rb
|
176
182
|
- lib/eac_ruby_utils/patches/kernel.rb
|
177
183
|
- lib/eac_ruby_utils/patches/kernel/nyi.rb
|
178
184
|
- lib/eac_ruby_utils/patches/module.rb
|
@@ -199,6 +205,7 @@ files:
|
|
199
205
|
- lib/eac_ruby_utils/patches/object/to_pathname.rb
|
200
206
|
- lib/eac_ruby_utils/patches/pathname.rb
|
201
207
|
- lib/eac_ruby_utils/patches/pathname/basename_sub.rb
|
208
|
+
- lib/eac_ruby_utils/patches/pathname/mkpath_s.rb
|
202
209
|
- lib/eac_ruby_utils/patches/pathname/parent_n.rb
|
203
210
|
- lib/eac_ruby_utils/patches/regexp.rb
|
204
211
|
- 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
|