eac_ruby_utils 0.57.1 → 0.57.2

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: 6469a891b6aa484b994c98c3617fc63508607703f7eeb85106d543bdfb5a17e2
4
- data.tar.gz: 8724c432235e501b3e3a645caee3ac3eb42ba2d0430d870db8b06dcd5c5b2afc
3
+ metadata.gz: e9a5ba0cb4987def93f005feb8c7d109afe4f5e202939d9a5db9e64eb8d08194
4
+ data.tar.gz: 9c7632467e434195994afdf69ada8ea8820e5df639709e79cae7cb8543169129
5
5
  SHA512:
6
- metadata.gz: 7138140617aba1656eeaf68cce2a3a1895d9cc7f6bf9702c2d5630d71d4ca20022cb63c97bdefaae31815aaf7bfbb35d40ee2c139093c097c43f1f5819703bf8
7
- data.tar.gz: f509f49102ff7360aa6d368a2558876d808d5cd78f419886304acfcadb219a54ec9a4ecaad988fad7c38f992e77d087d6b8580cb80df9a8b59ad9fc55ca30314
6
+ metadata.gz: 92cfc25fcb83ec39aff6136acd20fc30a5a9eacb493765ba034f6fa9291e022c931b55d80350fefe605a126a7f9c61b75e6e2b78e6d24b0b627912fde7a4c0fc
7
+ data.tar.gz: bedc1cd2d75146ca942894d9105e4c6ce02283996c7b1192cd26f93024895feb3a3b02c5dcab0e2f50d0ef5c273c3cdd494d576f55078aa1d5c27712a1679a0a
@@ -0,0 +1,38 @@
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
+ def auto
14
+ %w[tz_env debian_config offset].lazy.map { |s| send("by_#{s}") }.find(&:present?)
15
+ end
16
+
17
+ def by_debian_config
18
+ path = ::Pathname.new(DEBIAN_CONFIG_PATH)
19
+ path.exist? ? path.read.strip.presence : nil
20
+ end
21
+
22
+ def by_offset
23
+ ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name
24
+ end
25
+
26
+ def by_timedatectl
27
+ executable = ::EacRubyUtils::Envs.local.executable('timedatectl', '--version')
28
+ return nil unless executable.exist?
29
+
30
+ TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] }
31
+ end
32
+
33
+ def by_tz_env
34
+ ENV['TZ'].presence
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/patches/time/local_time_zone'
3
+ require 'active_support/core_ext/time/zones'
4
+ require 'eac_ruby_utils/local_time_zone'
4
5
 
5
- ::Time.zone = ::Time.local_time_zone
6
+ ::Time.zone = ::EacRubyUtils::LocalTimeZone.auto
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.57.1'
4
+ VERSION = '0.57.2'
5
5
  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.57.1
4
+ version: 0.57.2
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-01-06 00:00:00.000000000 Z
11
+ date: 2021-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -186,6 +186,7 @@ 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
@@ -225,7 +226,6 @@ files:
225
226
  - lib/eac_ruby_utils/patches/string/inflector.rb
226
227
  - lib/eac_ruby_utils/patches/time.rb
227
228
  - lib/eac_ruby_utils/patches/time/default_time_zone_set.rb
228
- - lib/eac_ruby_utils/patches/time/local_time_zone.rb
229
229
  - lib/eac_ruby_utils/paths_hash.rb
230
230
  - lib/eac_ruby_utils/paths_hash/entry_key_error.rb
231
231
  - 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