eac_ruby_utils 0.57.0 → 0.59.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/fs/traverser.rb +0 -2
 - data/lib/eac_ruby_utils/inflector.rb +4 -1
 - data/lib/eac_ruby_utils/local_time_zone.rb +48 -0
 - data/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
 - data/lib/eac_ruby_utils/patches/kernel.rb +4 -0
 - data/lib/eac_ruby_utils/patches/kernel/nyi.rb +8 -0
 - data/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
 - data/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
 - data/lib/eac_ruby_utils/version.rb +1 -1
 - metadata +8 -4
 - data/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +0 -5
 - data/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 548ad31ed6381e0a51802ea856dfa885fdaef16080305285698872baa9dc9b24
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ee4ddee8e898704ef248d82296d7cb63093a3ff8a72e929b6815c854e8e66e70
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2dcbd2e28932d4a287e94798511973b1ec0803838294f2eba2d5fb7ea5e7399ee5092d2bde598e5f403195c3832bdc57a4de2a9ba7514ac4f3c9ff5f23523243
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8a3259581c69448604dcc452f7ede39ef6ba1eaf9081d609c837e16377aa11bdd0bba9100256226334b7863149a5d93ad43d4410b4d7b660ce61f6498850612c
         
     | 
| 
         @@ -1,12 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            require 'active_support/inflector'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       3 
5 
     | 
    
         
             
            module EacRubyUtils
         
     | 
| 
       4 
6 
     | 
    
         
             
              class Inflector
         
     | 
| 
       5 
7 
     | 
    
         
             
                class << self
         
     | 
| 
       6 
8 
     | 
    
         
             
                  VARIABLE_NAME_PATTERN = /[_a-z][_a-z0-9]*/i.freeze
         
     | 
| 
       7 
9 
     | 
    
         | 
| 
       8 
10 
     | 
    
         
             
                  def variableize(string)
         
     | 
| 
       9 
     | 
    
         
            -
                    r = string.gsub(/[^_a-z0-9]/i, '_') 
     | 
| 
      
 11 
     | 
    
         
            +
                    r = ::ActiveSupport::Inflector.transliterate(string).gsub(/[^_a-z0-9]/i, '_')
         
     | 
| 
      
 12 
     | 
    
         
            +
                                                  .gsub(/_+/, '_').gsub(/_\z/, '').gsub(/\A_/, '').downcase
         
     | 
| 
       10 
13 
     | 
    
         
             
                    m = VARIABLE_NAME_PATTERN.match(r)
         
     | 
| 
       11 
14 
     | 
    
         
             
                    return r if m
         
     | 
| 
       12 
15 
     | 
    
         | 
| 
         @@ -0,0 +1,48 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'active_support/core_ext/object/blank'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'active_support/values/time_zone'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module EacRubyUtils
         
     | 
| 
      
 7 
     | 
    
         
            +
              module LocalTimeZone
         
     | 
| 
      
 8 
     | 
    
         
            +
                DEBIAN_CONFIG_PATH = '/etc/timezone'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 11 
     | 
    
         
            +
                  TIMEDATECTL_TIMEZONE_LINE_PATTERN = %r{\s*Time zone:\s*(\S+/\S+)\s}.freeze
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  # @return [ActiveSupport::TimeZone]
         
     | 
| 
      
 14 
     | 
    
         
            +
                  def auto
         
     | 
| 
      
 15 
     | 
    
         
            +
                    %w[tz_env debian_config offset].lazy.map { |s| send("by_#{s}") }.find(&:present?)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  def auto_set
         
     | 
| 
      
 19 
     | 
    
         
            +
                    ::Time.zone = auto
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  # @return [ActiveSupport::TimeZone]
         
     | 
| 
      
 23 
     | 
    
         
            +
                  def by_debian_config
         
     | 
| 
      
 24 
     | 
    
         
            +
                    path = ::Pathname.new(DEBIAN_CONFIG_PATH)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    path.exist? ? path.read.strip.if_present { |v| ::ActiveSupport::TimeZone[v] } : nil
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  # @return [ActiveSupport::TimeZone]
         
     | 
| 
      
 29 
     | 
    
         
            +
                  def by_offset
         
     | 
| 
      
 30 
     | 
    
         
            +
                    ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset]
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  # @return [ActiveSupport::TimeZone]
         
     | 
| 
      
 34 
     | 
    
         
            +
                  def by_timedatectl
         
     | 
| 
      
 35 
     | 
    
         
            +
                    executable = ::EacRubyUtils::Envs.local.executable('timedatectl', '--version')
         
     | 
| 
      
 36 
     | 
    
         
            +
                    return nil unless executable.exist?
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                    TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] }
         
     | 
| 
      
 39 
     | 
    
         
            +
                                                     .if_present { |v| ::ActiveSupport::TimeZone[v] }
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  # @return [ActiveSupport::TimeZone]
         
     | 
| 
      
 43 
     | 
    
         
            +
                  def by_tz_env
         
     | 
| 
      
 44 
     | 
    
         
            +
                    ENV['TZ'].presence
         
     | 
| 
      
 45 
     | 
    
         
            +
                  end
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Object
         
     | 
| 
      
 4 
     | 
    
         
            +
              # @return +block.call(self)+ if +self+ is not nil, +default_value+ otherwise.
         
     | 
| 
      
 5 
     | 
    
         
            +
              def if_not_nil(default_value = nil)
         
     | 
| 
      
 6 
     | 
    
         
            +
                return default_value if nil?
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                block_given? ? yield(self) : self
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              # @return +yield+ if +self+ is nil, +self+ otherwise.
         
     | 
| 
      
 12 
     | 
    
         
            +
              def if_nil
         
     | 
| 
      
 13 
     | 
    
         
            +
                return yield if nil? && block_given?
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                self
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        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.59.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: 2021- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-02-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -186,12 +186,14 @@ files: 
     | 
|
| 
       186 
186 
     | 
    
         
             
            - lib/eac_ruby_utils/listable/string_list.rb
         
     | 
| 
       187 
187 
     | 
    
         
             
            - lib/eac_ruby_utils/listable/symbol_list.rb
         
     | 
| 
       188 
188 
     | 
    
         
             
            - lib/eac_ruby_utils/listable/value.rb
         
     | 
| 
      
 189 
     | 
    
         
            +
            - lib/eac_ruby_utils/local_time_zone.rb
         
     | 
| 
       189 
190 
     | 
    
         
             
            - lib/eac_ruby_utils/on_clean_ruby_environment.rb
         
     | 
| 
       190 
191 
     | 
    
         
             
            - lib/eac_ruby_utils/options_consumer.rb
         
     | 
| 
       191 
192 
     | 
    
         
             
            - lib/eac_ruby_utils/patch.rb
         
     | 
| 
       192 
193 
     | 
    
         
             
            - lib/eac_ruby_utils/patches.rb
         
     | 
| 
       193 
194 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/class.rb
         
     | 
| 
       194 
195 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/class/common_constructor.rb
         
     | 
| 
      
 196 
     | 
    
         
            +
            - lib/eac_ruby_utils/patches/class/settings_provider.rb
         
     | 
| 
       195 
197 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/enumerable.rb
         
     | 
| 
       196 
198 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb
         
     | 
| 
       197 
199 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/enumerator.rb
         
     | 
| 
         @@ -200,6 +202,8 @@ files: 
     | 
|
| 
       200 
202 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/hash.rb
         
     | 
| 
       201 
203 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/hash/options_consumer.rb
         
     | 
| 
       202 
204 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
         
     | 
| 
      
 205 
     | 
    
         
            +
            - lib/eac_ruby_utils/patches/kernel.rb
         
     | 
| 
      
 206 
     | 
    
         
            +
            - lib/eac_ruby_utils/patches/kernel/nyi.rb
         
     | 
| 
       203 
207 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/module.rb
         
     | 
| 
       204 
208 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/module/abstract_methods.rb
         
     | 
| 
       205 
209 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/module/common_concern.rb
         
     | 
| 
         @@ -213,6 +217,7 @@ files: 
     | 
|
| 
       213 
217 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/object.rb
         
     | 
| 
       214 
218 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/object/asserts.rb
         
     | 
| 
       215 
219 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/object/debug.rb
         
     | 
| 
      
 220 
     | 
    
         
            +
            - lib/eac_ruby_utils/patches/object/if_nil.rb
         
     | 
| 
       216 
221 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/object/if_present.rb
         
     | 
| 
       217 
222 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/object/if_respond.rb
         
     | 
| 
       218 
223 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/object/template.rb
         
     | 
| 
         @@ -224,8 +229,7 @@ files: 
     | 
|
| 
       224 
229 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/string.rb
         
     | 
| 
       225 
230 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/string/inflector.rb
         
     | 
| 
       226 
231 
     | 
    
         
             
            - lib/eac_ruby_utils/patches/time.rb
         
     | 
| 
       227 
     | 
    
         
            -
            - lib/eac_ruby_utils/patches/time/ 
     | 
| 
       228 
     | 
    
         
            -
            - lib/eac_ruby_utils/patches/time/local_time_zone.rb
         
     | 
| 
      
 232 
     | 
    
         
            +
            - lib/eac_ruby_utils/patches/time/required_zone.rb
         
     | 
| 
       229 
233 
     | 
    
         
             
            - lib/eac_ruby_utils/paths_hash.rb
         
     | 
| 
       230 
234 
     | 
    
         
             
            - lib/eac_ruby_utils/paths_hash/entry_key_error.rb
         
     | 
| 
       231 
235 
     | 
    
         
             
            - lib/eac_ruby_utils/paths_hash/node.rb
         
     | 
| 
         @@ -1,25 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'active_support/core_ext/time/zones'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'eac_ruby_utils/envs'
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            class Time
         
     | 
| 
       7 
     | 
    
         
            -
              class << self
         
     | 
| 
       8 
     | 
    
         
            -
                TIMEDATECTL_TIMEZONE_LINE_PATTERN = %r{\s*Time zone:\s*(\S+/\S+)\s}.freeze
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                def local_time_zone
         
     | 
| 
       11 
     | 
    
         
            -
                  local_time_zone_by_timedatectl || local_time_zone_by_offset
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                def local_time_zone_by_timedatectl
         
     | 
| 
       15 
     | 
    
         
            -
                  executable = ::EacRubyUtils::Envs.local.executable('timedatectl', '--version')
         
     | 
| 
       16 
     | 
    
         
            -
                  return nil unless executable.exist?
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                  TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] }
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                def local_time_zone_by_offset
         
     | 
| 
       22 
     | 
    
         
            -
                  ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name
         
     | 
| 
       23 
     | 
    
         
            -
                end
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
            end
         
     |