et-orbi 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Makefile +1 -0
  4. data/lib/et-orbi.rb +24 -39
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92e8f11466211f94bfe4d872c6a1566af6c1cf9f
4
- data.tar.gz: '091a7dd8dd6981ff58bd661091f1ee6f07c67f40'
3
+ metadata.gz: db2e44b25fa9806ddea412a4c4ab67f404f8abf7
4
+ data.tar.gz: 28bff7ef341b1458b17a604638878f17c131ad76
5
5
  SHA512:
6
- metadata.gz: abe51c5879807fe9b57f1487091bdaeee5ddbec7219824893d1f0068f6bae454400c980924e1eff5e9f4f30a76bcd165916e8430e57e041feae8f06b1ed30556
7
- data.tar.gz: 406500144fbd7a87d61eb6cfe07e975fc05d5b9f50755b9a4a09326fae2a17997d99b15109c8d70d0d900492ed87518d2c0f0920f1d94573be5dbb97a100f265
6
+ metadata.gz: '0411908916cd638a834b73d73685c3615154c26b39d1ef264bb0e924808bbb845dab0ee7d89c12a2d0fc20757e748a0dc2b1785c12396a754123a65393cb7b5c'
7
+ data.tar.gz: bde96903887538a4f15885e74996882c68d662d6692e76f217fe471782ef9b8951df0aee97b0c6150ab0ffd5e6985579f9786f00b6e5c4b059b341eb4235b904
@@ -2,6 +2,11 @@
2
2
  # et-orbi CHANGELOG.md
3
3
 
4
4
 
5
+ ## et-orbi 1.1.1 released 2018-05-04
6
+
7
+ - Stop caching the local tzone, cache the tools used for determining it
8
+
9
+
5
10
  ## et-orbi 1.1.0 released 2018-03-25
6
11
 
7
12
  - Implement EoTime .utc and .local (based on Time .utc and .local)
data/Makefile CHANGED
@@ -8,6 +8,7 @@ VERSION = \
8
8
 
9
9
  count_lines:
10
10
  find lib -name "*.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
11
+ find spec -name "*_spec.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
11
12
  cl: count_lines
12
13
 
13
14
  gemspec_validate:
@@ -7,7 +7,7 @@ require 'tzinfo'
7
7
 
8
8
  module EtOrbi
9
9
 
10
- VERSION = '1.1.0'
10
+ VERSION = '1.1.1'
11
11
 
12
12
  #
13
13
  # module methods
@@ -47,7 +47,7 @@ module EtOrbi
47
47
  opts[:zone] ||
48
48
  str_zone ||
49
49
  find_olson_zone(str) ||
50
- local_tzone
50
+ determine_local_tzone
51
51
  #p [ :parse, :zone, zone ]
52
52
 
53
53
  str = str.sub(zone.name, '') unless zone.name.match(/\A[-+]/)
@@ -143,7 +143,7 @@ module EtOrbi
143
143
 
144
144
  return o if o.is_a?(::TZInfo::Timezone)
145
145
  return nil if o == nil
146
- return local_tzone if o == :local
146
+ return determine_local_tzone if o == :local
147
147
  return ::TZInfo::Timezone.get('Zulu') if o == 'Z'
148
148
  return o.tzinfo if o.respond_to?(:tzinfo)
149
149
 
@@ -156,24 +156,6 @@ module EtOrbi
156
156
  (::TZInfo::Timezone.get(o) rescue nil)
157
157
  end
158
158
 
159
- def local_tzone
160
-
161
- @local_tzone_tz ||= nil
162
- @local_tzone_loaded_at ||= nil
163
-
164
- @local_tzone = nil \
165
- if @local_tzone_loaded_at && (Time.now > @local_tzone_loaded_at + 1800)
166
- @local_tzone = nil \
167
- if @local_tzone_tz != ENV['TZ']
168
-
169
- @local_tzone ||=
170
- begin
171
- @local_tzone_tz = ENV['TZ']
172
- @local_tzone_loaded_at = Time.now
173
- determine_local_tzone
174
- end
175
- end
176
-
177
159
  def render_nozone_time(seconds)
178
160
 
179
161
  t =
@@ -181,10 +163,10 @@ module EtOrbi
181
163
  ts =
182
164
  t.strftime('%Y-%m-%d %H:%M:%S') +
183
165
  ".#{(seconds % 1).to_s.split('.').last}"
166
+ tz =
167
+ EtOrbi.determine_local_tzone
184
168
  z =
185
- EtOrbi.local_tzone ?
186
- EtOrbi.local_tzone.period_for_local(t).abbreviation.to_s :
187
- nil
169
+ tz ? tz.period_for_local(t).abbreviation.to_s : nil
188
170
 
189
171
  "(secs:#{seconds},utc~:#{ts.inspect},ltz~:#{z.inspect})"
190
172
  end
@@ -200,9 +182,12 @@ module EtOrbi
200
182
  'tzid' => defined?(TZInfo::Data),
201
183
  'rv' => RUBY_VERSION,
202
184
  'rp' => RUBY_PLATFORM,
203
- 'eov' => EtOrbi::VERSION,
204
185
  'rorv' => (Rails::VERSION::STRING rescue nil),
205
186
  'astz' => ([ Time.zone.class, Time.zone.tzinfo.name ] rescue nil),
187
+ 'eov' => EtOrbi::VERSION,
188
+ 'eotnz' => EtOrbi::EoTime.now.zone,
189
+ 'eotnfz' => EtOrbi::EoTime.now.strftime('%z'),
190
+ 'eotlzn' => EtOrbi::EoTime.local_tzone.name,
206
191
  }.collect(&etos).join(',') + ',' +
207
192
  gather_tzs.collect(&etos).join(',') +
208
193
  ')'
@@ -237,7 +222,7 @@ module EtOrbi
237
222
 
238
223
  l = Time.local(t.year, t.month, t.day, t.hour, t.min, t.sec, t.usec)
239
224
 
240
- t.zone == l.zone ? local_tzone : nil
225
+ (t.zone == l.zone) ? determine_local_tzone : nil
241
226
  end
242
227
 
243
228
  def get_as_tzone(t)
@@ -279,7 +264,7 @@ module EtOrbi
279
264
 
280
265
  def local_tzone
281
266
 
282
- EtOrbi.local_tzone
267
+ EtOrbi.determine_local_tzone
283
268
  end
284
269
 
285
270
  def platform_info
@@ -299,7 +284,7 @@ module EtOrbi
299
284
 
300
285
  def local(*a)
301
286
 
302
- EtOrbi.make_from_array(a, EtOrbi.local_tzone)
287
+ EtOrbi.make_from_array(a, local_tzone)
303
288
  end
304
289
  end
305
290
 
@@ -648,7 +633,7 @@ module EtOrbi
648
633
 
649
634
  def os_tz
650
635
 
651
- debian_tz || centos_tz || osx_tz
636
+ @os_tz ||= (debian_tz || centos_tz || osx_tz)
652
637
  end
653
638
 
654
639
  #
@@ -704,7 +689,6 @@ module EtOrbi
704
689
  tzi.offset(id, utc_off, 0, id)
705
690
  tzi.create_timezone
706
691
  end
707
-
708
692
  end
709
693
 
710
694
  def determine_local_tzones
@@ -713,6 +697,7 @@ module EtOrbi
713
697
  .collect { |i| (Time.now + i * 30 * 24 * 3600).zone }
714
698
  .uniq
715
699
  .sort
700
+ .join('|')
716
701
 
717
702
  t = Time.now
718
703
  #tu = t.dup.utc # /!\ dup is necessary, #utc modifies its target
@@ -720,16 +705,16 @@ module EtOrbi
720
705
  twin = Time.utc(t.year, 1, 1) # winter
721
706
  tsum = Time.utc(t.year, 7, 1) # summer
722
707
 
723
- ::TZInfo::Timezone.all.select do |tz|
724
-
725
- pabbs =
726
- [
727
- tz.period_for_utc(twin).abbreviation.to_s,
728
- tz.period_for_utc(tsum).abbreviation.to_s
729
- ].uniq.sort
708
+ @tz_all ||= ::TZInfo::Timezone.all
709
+ @tz_winter_summer ||= {}
730
710
 
731
- pabbs == tabbs
732
- end
711
+ @tz_winter_summer[tabbs] ||= @tz_all
712
+ .select { |tz|
713
+ tabbs ==
714
+ [
715
+ tz.period_for_utc(twin).abbreviation.to_s,
716
+ tz.period_for_utc(tsum).abbreviation.to_s
717
+ ].uniq.sort.join('|') }
733
718
  end
734
719
 
735
720
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: et-orbi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-25 00:00:00.000000000 Z
11
+ date: 2018-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo