eac_ruby_utils 0.120.0 → 0.122.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/arguments_consumer.rb +1 -1
- data/lib/eac_ruby_utils/compact.rb +12 -2
- data/lib/eac_ruby_utils/patches/hash/if_key.rb +12 -0
- data/lib/eac_ruby_utils/patches/kernel/ibr.rb +10 -0
- data/lib/eac_ruby_utils/patches/object/debug.rb +7 -3
- data/lib/eac_ruby_utils/speaker/sender.rb +14 -9
- data/lib/eac_ruby_utils/struct.rb +1 -1
- data/lib/eac_ruby_utils/version.rb +1 -1
- data/lib/eac_ruby_utils/yaml.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fea41f96c275a53fedaeae53d07b81e356757859be5c17207d2eaa6924c5bda
|
4
|
+
data.tar.gz: 79e2fe2a6432169b0222d2dd785a49f3bc459a0004cca89e1534f6e58716401c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf52648fabdb145fb750f0448aa758b122ae264a3947a50427ed3e08c28babc423b3cb2a091c0e3237d6edd6376203fa7abd071647c4269fbe286027116f323f
|
7
|
+
data.tar.gz: ee8f6519bc3074a512ed273c868e087da3ae79a50055d88118be6a109b6082737c911c12be4db91d10da333b1bb6cd2b7b33bb2cc01799d8bb9a634df6e10b18
|
@@ -73,7 +73,7 @@ module EacRubyUtils
|
|
73
73
|
def initialize(args_consumer, arg, message)
|
74
74
|
@args_consumer = args_consumer
|
75
75
|
@arg = arg
|
76
|
-
super
|
76
|
+
super("#{message} (Arg: #{arg}, Args Consumer: #{args_consumer})")
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module EacRubyUtils
|
4
4
|
class Compact
|
5
|
+
ATTRIBUTE_SEPARATOR = '.'
|
6
|
+
|
5
7
|
attr_reader :object, :attributes
|
6
8
|
|
7
9
|
def initialize(object, attributes)
|
@@ -9,14 +11,22 @@ module EacRubyUtils
|
|
9
11
|
@attributes = attributes
|
10
12
|
end
|
11
13
|
|
14
|
+
# @param attr_path [String, Symbol] A path separated by +ATTRIBUTE_SEPARATOR+.
|
15
|
+
# @return [Object]
|
16
|
+
def attribute_value(attr_path)
|
17
|
+
attr_path.to_s.split(ATTRIBUTE_SEPARATOR).inject(object) do |a, e|
|
18
|
+
a.send(e)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
12
22
|
# @return [Array]
|
13
23
|
def to_a
|
14
|
-
attributes.map { |attr|
|
24
|
+
attributes.map { |attr| attribute_value(attr) }
|
15
25
|
end
|
16
26
|
|
17
27
|
# @return [Hash]
|
18
28
|
def to_h
|
19
|
-
attributes.to_h { |attr| [attr.to_sym,
|
29
|
+
attributes.to_h { |attr| [attr.to_sym, attribute_value(attr)] }
|
20
30
|
end
|
21
31
|
end
|
22
32
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
|
5
|
+
class Hash
|
6
|
+
# @return +block.call(fetch(key))+ if +self+ has the key +key+, +default_value+ otherwise.
|
7
|
+
def if_key(key, default_value = nil)
|
8
|
+
return default_value unless key?(key)
|
9
|
+
|
10
|
+
block_given? ? yield(fetch(key)) : fetch(key)
|
11
|
+
end
|
12
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/compact'
|
3
4
|
require 'eac_ruby_utils/patches/object/if_present'
|
4
5
|
require 'pp'
|
5
6
|
|
6
7
|
class Object
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
# @param attributes [Enumerable<Symbol>] Attributes for +EacRubyUtils::Compact.new+.
|
9
|
+
# @return [void]
|
10
|
+
def compact_debug(*attributes)
|
11
|
+
::EacRubyUtils::Compact.new(self, attributes).to_h.each do |name, value|
|
12
|
+
value.print_debug(label: name)
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
@@ -35,6 +38,7 @@ class Object
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def print_debug_title(title)
|
41
|
+
title = title.to_s
|
38
42
|
char = '='
|
39
43
|
$stderr.write("#{char * (4 + title.length)}\n")
|
40
44
|
$stderr.write("#{char} #{title} #{char}\n")
|
@@ -1,17 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/compact'
|
4
|
+
|
3
5
|
module EacRubyUtils
|
4
6
|
module Speaker
|
5
7
|
module Sender
|
6
|
-
delegate :error, :fatal_error, :info, :infom, :
|
7
|
-
|
8
|
-
def infov(*args)
|
9
|
-
speaker_receiver.infov(*args)
|
10
|
-
end
|
11
|
-
|
12
|
-
delegate :out, to: :speaker_receiver
|
13
|
-
|
14
|
-
delegate :puts, to: :speaker_receiver
|
8
|
+
delegate :error, :fatal_error, :info, :infom, :infov, :out, :puts, :title, :success, :warn,
|
9
|
+
to: :speaker_receiver
|
15
10
|
|
16
11
|
# Shortcut to [EacRubyUtils::Speaker.current_receiver].
|
17
12
|
#
|
@@ -20,6 +15,16 @@ module EacRubyUtils
|
|
20
15
|
::EacRubyUtils::Speaker.current_receiver
|
21
16
|
end
|
22
17
|
|
18
|
+
# @param attributes [Enumerable<Symbol>] Attributes for +EacRubyUtils::Compact.new+.
|
19
|
+
# @return [self]
|
20
|
+
def compact_infov(*attributes)
|
21
|
+
::EacRubyUtils::Compact.new(self, attributes).to_h.each do |k, v|
|
22
|
+
infov k, v
|
23
|
+
end
|
24
|
+
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
23
28
|
# Options:
|
24
29
|
# +bool+ ([Boolean], default: +false+): requires a answer "yes" or "no".
|
25
30
|
# +list+ ([Hash] or [Array], default: +nil+): requires a answer from a list.
|
data/lib/eac_ruby_utils/yaml.rb
CHANGED
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.122.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: 2024-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '2.8'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 2.8.
|
42
|
+
version: 2.8.6
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '2.8'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 2.8.
|
52
|
+
version: 2.8.6
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,10 +235,12 @@ files:
|
|
235
235
|
- lib/eac_ruby_utils/patches/enumerator/current.rb
|
236
236
|
- lib/eac_ruby_utils/patches/enumerator/stopped.rb
|
237
237
|
- lib/eac_ruby_utils/patches/hash.rb
|
238
|
+
- lib/eac_ruby_utils/patches/hash/if_key.rb
|
238
239
|
- lib/eac_ruby_utils/patches/hash/options_consumer.rb
|
239
240
|
- lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
|
240
241
|
- lib/eac_ruby_utils/patches/hash/to_struct.rb
|
241
242
|
- lib/eac_ruby_utils/patches/kernel.rb
|
243
|
+
- lib/eac_ruby_utils/patches/kernel/ibr.rb
|
242
244
|
- lib/eac_ruby_utils/patches/kernel/nyi.rb
|
243
245
|
- lib/eac_ruby_utils/patches/module.rb
|
244
246
|
- lib/eac_ruby_utils/patches/module/abstract_methods.rb
|