eac_ruby_utils 0.121.0 → 0.123.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f01b05501b3b07a9a61379167199fb3489be9b082a77ac5e1730ca271cbdc951
4
- data.tar.gz: ebc0eb54e6ee6d90d7fc3fffcf050b72ed10b1860d0db6c43213c7a241d2b27e
3
+ metadata.gz: 793aedb5e1113b889505fd8a8728397eeab8d26f46648bcab09592007d1e8d83
4
+ data.tar.gz: b37f3f944525140c07f494da7fde186a85f5be9c7053de6645ede66f1f493de2
5
5
  SHA512:
6
- metadata.gz: 814b5652fb79d527e9331111697f438082a6012db38d74cf432ee8c7f855ea7cfb61a0e073807dec5acc6143b8453885fdeba2c82e0f55d94ea0b19426f3723e
7
- data.tar.gz: dcb8f3c8b0ee24d278bfe723bbefb8646b1ff7bcc6d21544ba853aba8750386130d0f242a40e727c392d16fe972759b7f8da1e1d91ffd39787a24ed57ab8d06b
6
+ metadata.gz: 4f71e2816a735ef0de790d6b5c4ac661c1b7cbe7c1cab50a8ac3199a0470e2fd724d4e90d3be6b14bfd0d5741e3ae4eb4fe9d99dcb35be1fae184517377c19ed
7
+ data.tar.gz: eb05d158d821d867339bdaf52387672ada1a4d8a166dd6740714f59bee0bb4623ef16341a8f135f087f801018ff8493c8b9d3e94cd2e9201cd34b30ccc62b89e
@@ -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| object.send(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, object.send(attr)] }
29
+ attributes.to_h { |attr| [attr.to_sym, attribute_value(attr)] }
20
30
  end
21
31
  end
22
32
  end
@@ -7,7 +7,7 @@ module EacRubyUtils
7
7
  module Temp
8
8
  class Directory < ::EacRubyUtils::Fs::Temp::File
9
9
  def initialize(*tempfile_args)
10
- super(*tempfile_args)
10
+ super
11
11
  mkpath
12
12
  end
13
13
  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
- def compact_debug(*methods_names)
8
- methods_names.each do |method_name|
9
- send(method_name).print_debug(label: method_name)
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, :title, :success, :warn, to: :speaker_receiver
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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.121.0'
4
+ VERSION = '0.123.0'
5
5
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/time_with_zone'
3
4
  require 'date'
4
5
  require 'yaml'
5
6
 
@@ -7,7 +8,8 @@ module EacRubyUtils
7
8
  # A safe YAML loader/dumper with common types included.
8
9
  class Yaml
9
10
  class << self
10
- DEFAULT_PERMITTED_CLASSES = [::Array, ::Date, ::DateTime, ::FalseClass, ::Hash, ::NilClass,
11
+ DEFAULT_PERMITTED_CLASSES = [ActiveSupport::TimeWithZone, ActiveSupport::TimeZone,
12
+ ::Array, ::Date, ::DateTime, ::FalseClass, ::Hash, ::NilClass,
11
13
  ::Numeric, ::String, ::Symbol, ::Time, ::TrueClass].freeze
12
14
 
13
15
  def dump(object)
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.121.0
4
+ version: 0.123.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: 2024-02-10 00:00:00.000000000 Z
11
+ date: 2024-09-22 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.6
42
+ version: 2.8.7
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.6
52
+ version: 2.8.7
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: bundler
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +99,9 @@ dependencies:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0.5'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 0.5.1
102
105
  type: :development
103
106
  prerelease: false
104
107
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,20 +109,23 @@ dependencies:
106
109
  - - "~>"
107
110
  - !ruby/object:Gem::Version
108
111
  version: '0.5'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 0.5.1
109
115
  - !ruby/object:Gem::Dependency
110
116
  name: eac_ruby_gem_support
111
117
  requirement: !ruby/object:Gem::Requirement
112
118
  requirements:
113
119
  - - "~>"
114
120
  - !ruby/object:Gem::Version
115
- version: '0.9'
121
+ version: '0.10'
116
122
  type: :development
117
123
  prerelease: false
118
124
  version_requirements: !ruby/object:Gem::Requirement
119
125
  requirements:
120
126
  - - "~>"
121
127
  - !ruby/object:Gem::Version
122
- version: '0.9'
128
+ version: '0.10'
123
129
  description:
124
130
  email:
125
131
  executables: []