eac_ruby_utils 0.121.0 → 0.123.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/compact.rb +12 -2
 - data/lib/eac_ruby_utils/fs/temp/directory.rb +1 -1
 - 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/version.rb +1 -1
 - data/lib/eac_ruby_utils/yaml.rb +3 -1
 - metadata +12 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 793aedb5e1113b889505fd8a8728397eeab8d26f46648bcab09592007d1e8d83
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b37f3f944525140c07f494da7fde186a85f5be9c7053de6645ede66f1f493de2
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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|  
     | 
| 
      
 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
         
     | 
| 
         @@ -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
    
    | 
         @@ -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 = [:: 
     | 
| 
      
 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. 
     | 
| 
      
 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- 
     | 
| 
      
 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. 
     | 
| 
      
 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. 
     | 
| 
      
 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. 
     | 
| 
      
 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. 
     | 
| 
      
 128 
     | 
    
         
            +
                    version: '0.10'
         
     | 
| 
       123 
129 
     | 
    
         
             
            description: 
         
     | 
| 
       124 
130 
     | 
    
         
             
            email: 
         
     | 
| 
       125 
131 
     | 
    
         
             
            executables: []
         
     |