fugit 0.9.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fugit might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a69dbc44f95d36f6c14796afffeacf393a7c4b7
4
- data.tar.gz: 5d6c7c0c45791960264ea38ce96344414c669a94
3
+ metadata.gz: b3e0133c5181167fb43ca7228ce7b76d154f402a
4
+ data.tar.gz: 3ff631d838f4ea26b0af2c11701356f71e9518f4
5
5
  SHA512:
6
- metadata.gz: b3f31b0534b395e42d5586e0e69c3caa83d439f4dca53b3757534dd29785a2c465ad2bf870dfb376c334337af37e86557b7ee833f172dbbe5b637a8d830e1f10
7
- data.tar.gz: feefa45d7ac203a25e07f0de7ef878a5b20c7bd33602a69709ad2cda19bec02f280af8c25529191f9a3cf5b6cb69d67e19664b971464a7289add6a7ba18baf11
6
+ metadata.gz: cb8cfb83bb07a6289bc86b24a1c9c26510a807734a1f81b8f132f032c7015081320408515f606696a4fea03fa00bc6c7d2278d0ad6390fc3c8a277034e627683
7
+ data.tar.gz: b1ec3168fd15980353048e3261e848bf63c7e740f47388e20f0f3c8e3b2bd4a9c1cab324a7663d60b5a71aba7ecc473b9453f0d2ee9eab859a4aa5f017df3d87
@@ -2,6 +2,12 @@
2
2
  # fugit CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.0.0 released 2017-06-23
6
+
7
+ * introduce et-orbi dependency (1.0.5 or better)
8
+ * Wire #deflate into Duration.to_long_s / .to_iso_s / .to_plain_s
9
+
10
+
5
11
  ## fugit 0.9.6 released 2017-05-24
6
12
 
7
13
  * Provide Duration.to_long_s / .to_iso_s / .to_plain_s at class level
@@ -26,7 +26,8 @@ Time tools for flor and the floraison project. Cron parsing and occurence comput
26
26
  ]
27
27
 
28
28
  #s.add_runtime_dependency 'tzinfo'
29
- s.add_runtime_dependency 'raabro', '>= 1.1.3'
29
+ s.add_runtime_dependency 'raabro', '~> 1.1'
30
+ s.add_runtime_dependency 'et-orbi', '>= 1.0.5'
30
31
 
31
32
  s.add_development_dependency 'rspec', '~> 3.4'
32
33
 
@@ -1,13 +1,14 @@
1
1
 
2
2
  module Fugit
3
3
 
4
- VERSION = '0.9.6'
4
+ VERSION = '1.0.0'
5
5
  end
6
6
 
7
7
  require 'time'
8
8
  require 'stringio'
9
9
 
10
10
  require 'raabro'
11
+ require 'et-orbi'
11
12
 
12
13
  require 'fugit/misc'
13
14
  require 'fugit/cron'
@@ -58,22 +58,20 @@ module Fugit
58
58
  parse(s) || fail(ArgumentError.new("not a cron string #{s.inspect}"))
59
59
  end
60
60
 
61
- class TimeCursor # TODO at some point, use ZoTime
61
+ class TimeCursor
62
62
 
63
63
  def initialize(t)
64
- @t = t.is_a?(TimeCursor) ? t.time : t
64
+ @t = t.is_a?(TimeCursor) ? t.time : ::EtOrbi.make_time(t)
65
65
  end
66
66
 
67
67
  def time; @t; end
68
68
  def to_i; @t.to_i; end
69
69
 
70
- %w[ year month day wday hour min sec ]
70
+ %w[ year month day wday hour min sec wday_in_month ]
71
71
  .collect(&:to_sym).each { |k| define_method(k) { @t.send(k) } }
72
72
 
73
73
  def inc(i)
74
- u = @t.utc?
75
- @t = ::Time.at(@t.to_i + i)
76
- @t = @t.utc if u
74
+ @t = @t + i
77
75
  self
78
76
  end
79
77
  def dec(i); inc(-i); end
@@ -82,7 +80,7 @@ module Fugit
82
80
  y = @t.year
83
81
  m = @t.month + 1
84
82
  if m == 13; m = 1; y += 1; end
85
- @t = Time.send((@t.utc? ? :utc : :local), y, m)
83
+ @t = ::EtOrbi.make(y, m)
86
84
  self
87
85
  end
88
86
  def inc_day; inc((24 - @t.hour) * 3600 - @t.min * 60 - @t.sec); end
@@ -108,20 +106,6 @@ module Fugit
108
106
  target = seconds.reverse.find { |s| s < @t.sec } || seconds.last
109
107
  inc(target - @t.sec)
110
108
  end
111
-
112
- def count_weeks(inc)
113
- c = 0
114
- t = @t
115
- until t.month != @t.month
116
- c += 1
117
- t += inc * (7 * 24 * 3600)
118
- end
119
- c
120
- end
121
-
122
- def wday_in_month
123
- [ count_weeks(-1), - count_weeks(1) ]
124
- end
125
109
  end
126
110
 
127
111
  def month_match?(nt); ( ! @months) || @months.include?(nt.month); end
@@ -172,13 +156,12 @@ module Fugit
172
156
  def match?(t)
173
157
 
174
158
  t = Fugit.do_parse_at(t)
175
- t = TimeCursor.new(t)
176
159
 
177
160
  month_match?(t) && day_match?(t) &&
178
161
  hour_match?(t) && min_match?(t) && sec_match?(t)
179
162
  end
180
163
 
181
- def next_time(from=Time.now)
164
+ def next_time(from=::EtOrbi::EoTime.now)
182
165
 
183
166
  t = TimeCursor.new(from)
184
167
 
@@ -196,7 +179,7 @@ module Fugit
196
179
  t.time
197
180
  end
198
181
 
199
- def previous_time(from=Time.now)
182
+ def previous_time(from=::EtOrbi::EoTime.now)
200
183
 
201
184
  t = TimeCursor.new(from)
202
185
 
@@ -228,7 +211,7 @@ module Fugit
228
211
 
229
212
  deltas = []
230
213
 
231
- t = Time.parse("#{year}-01-01") - 1
214
+ t = EtOrbi.make_time("#{year}-01-01") - 1
232
215
  t0 = nil
233
216
  t1 = nil
234
217
  loop do
@@ -97,9 +97,9 @@ module Fugit
97
97
  end
98
98
 
99
99
  class << self
100
- def to_plain_s(o); do_parse(o).to_plain_s; end
101
- def to_iso_s(o); do_parse(o).to_iso_s; end
102
- def to_long_s(o, opts={}); do_parse(o).to_long_s(opts); end
100
+ def to_plain_s(o); do_parse(o).deflate.to_plain_s; end
101
+ def to_iso_s(o); do_parse(o).deflate.to_iso_s; end
102
+ def to_long_s(o, opts={}); do_parse(o).deflate.to_long_s(opts); end
103
103
  end
104
104
 
105
105
  # Warning: this is an "approximation", months are 30 days and years are
@@ -170,6 +170,8 @@ module Fugit
170
170
 
171
171
  def add_to_time(t)
172
172
 
173
+ t = ::EtOrbi.make_time(t)
174
+
173
175
  INFLA_KEYS.each do |k, a|
174
176
 
175
177
  v = @h[k]; next unless v
@@ -192,7 +194,7 @@ module Fugit
192
194
  at[0], at[1] = at[0] - n, m
193
195
  end
194
196
 
195
- t = Time.send(t.utc? ? :utc : :local, *at)
197
+ t = ::EtOrbi.make_time(at, t.zone)
196
198
  end
197
199
 
198
200
  t
@@ -201,12 +203,12 @@ module Fugit
201
203
  def add(a)
202
204
 
203
205
  case a
204
- when Numeric then add_numeric(a)
205
- when Fugit::Duration then add_duration(a)
206
- when String then add_duration(self.class.parse(a))
207
- when Time then add_to_time(a)
208
- else fail ArgumentError.new(
209
- "cannot add #{a.class} instance to a Fugit::Duration")
206
+ when Numeric then add_numeric(a)
207
+ when Fugit::Duration then add_duration(a)
208
+ when String then add_duration(self.class.parse(a))
209
+ when ::Time, EtOrbi::EoTime then add_to_time(a)
210
+ else fail ArgumentError.new(
211
+ "cannot add #{a.class} instance to a Fugit::Duration")
210
212
  end
211
213
  end
212
214
  alias + add
@@ -214,12 +216,12 @@ module Fugit
214
216
  def substract(a)
215
217
 
216
218
  case a
217
- when Numeric then add_numeric(-a)
218
- when Fugit::Duration then add_duration(-a)
219
- when String then add_duration(-self.class.parse(a))
220
- when Time then opposite.add_to_time(a)
221
- else fail ArgumentError.new(
222
- "cannot substract #{a.class} instance to a Fugit::Duration")
219
+ when Numeric then add_numeric(-a)
220
+ when Fugit::Duration then add_duration(-a)
221
+ when String then add_duration(-self.class.parse(a))
222
+ when ::Time, ::EtOrbi::EoTime then add_to_time(a)
223
+ else fail ArgumentError.new(
224
+ "cannot substract #{a.class} instance to a Fugit::Duration")
223
225
  end
224
226
  end
225
227
  alias - substract
@@ -235,7 +237,7 @@ module Fugit
235
237
  @h.hash
236
238
  end
237
239
 
238
- def next_time(from=Time.now)
240
+ def next_time(from=::EtOrbi::EoTime.now)
239
241
 
240
242
  add(from)
241
243
  end
@@ -19,9 +19,9 @@ module Fugit
19
19
  isostamp(true, true, false, t)
20
20
  end
21
21
 
22
- def self.time_to_plain_s(t=Time.now)
22
+ def self.time_to_plain_s(t=Time.now, z=true)
23
23
 
24
- t.strftime('%Y-%m-%d %H:%M:%S') + (t.utc? ? ' Z' : '')
24
+ t.strftime('%Y-%m-%d %H:%M:%S') + (z && t.utc? ? ' Z' : '')
25
25
  end
26
26
 
27
27
  def self.time_to_zone_s(t=Time.now)
@@ -116,19 +116,19 @@ module Fugit
116
116
  v = tt.string.downcase
117
117
 
118
118
  case k
119
- when :numeral_hour
120
- [ k, NUMS.index(v) ]
121
- when :simple_hour
122
- [ k, v.to_i ]
123
- when :digital_hour
124
- v = v.gsub(/:/, '')
125
- [ k, [ v[0, 2], v[2, 2] ] ]
126
- when :name_hour
127
- [ :digital_hour, NHOURS[v] ]
128
- when :name_day
129
- [ k, WEEKDAYS.index(v[0, 3]) ]
130
- else
131
- [ k, v ]
119
+ when :numeral_hour
120
+ [ k, NUMS.index(v) ]
121
+ when :simple_hour
122
+ [ k, v.to_i ]
123
+ when :digital_hour
124
+ v = v.gsub(/:/, '')
125
+ [ k, [ v[0, 2], v[2, 2] ] ]
126
+ when :name_hour
127
+ [ :digital_hour, NHOURS[v] ]
128
+ when :name_day
129
+ [ k, WEEKDAYS.index(v[0, 3]) ]
130
+ else
131
+ [ k, v ]
132
132
  end
133
133
  }
134
134
  end
@@ -3,13 +3,12 @@ module Fugit
3
3
 
4
4
  def self.parse_at(s)
5
5
 
6
- Time.parse(s) rescue nil
6
+ ::EtOrbi.make_time(s) rescue nil
7
7
  end
8
8
 
9
9
  def self.do_parse_at(s)
10
10
 
11
- return s if s.is_a?(Time)
12
- Time.parse(s)
11
+ ::EtOrbi.make_time(s)
13
12
  end
14
13
 
15
14
  def self.parse_cron(s); ::Fugit::Cron.parse(s); end
@@ -42,10 +41,10 @@ module Fugit
42
41
  def self.determine_type(s)
43
42
 
44
43
  case self.parse(s)
45
- when ::Time then 'at'
46
- when ::Fugit::Cron then 'cron'
47
- when ::Fugit::Duration then 'in'
48
- else nil
44
+ when ::Fugit::Cron then 'cron'
45
+ when ::Fugit::Duration then 'in'
46
+ when ::Time, ::EtOrbi::EoTime then 'at'
47
+ else nil
49
48
  end
50
49
  end
51
50
  end
metadata CHANGED
@@ -1,41 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fugit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-24 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.3
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.3
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: et-orbi
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.5
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ~>
45
+ - - "~>"
32
46
  - !ruby/object:Gem::Version
33
47
  version: '3.4'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ~>
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '3.4'
41
55
  description: Time tools for flor and the floraison project. Cron parsing and occurence
@@ -46,18 +60,18 @@ executables: []
46
60
  extensions: []
47
61
  extra_rdoc_files: []
48
62
  files:
63
+ - CHANGELOG.md
64
+ - CREDITS.md
65
+ - LICENSE.txt
49
66
  - Makefile
67
+ - README.md
68
+ - fugit.gemspec
69
+ - lib/fugit.rb
50
70
  - lib/fugit/cron.rb
51
71
  - lib/fugit/duration.rb
52
72
  - lib/fugit/misc.rb
53
73
  - lib/fugit/nat.rb
54
74
  - lib/fugit/parse.rb
55
- - lib/fugit.rb
56
- - fugit.gemspec
57
- - LICENSE.txt
58
- - CHANGELOG.md
59
- - CREDITS.md
60
- - README.md
61
75
  homepage: http://github.com/floraison/fugit
62
76
  licenses:
63
77
  - MIT
@@ -68,17 +82,17 @@ require_paths:
68
82
  - lib
69
83
  required_ruby_version: !ruby/object:Gem::Requirement
70
84
  requirements:
71
- - - '>='
85
+ - - ">="
72
86
  - !ruby/object:Gem::Version
73
87
  version: '0'
74
88
  required_rubygems_version: !ruby/object:Gem::Requirement
75
89
  requirements:
76
- - - '>='
90
+ - - ">="
77
91
  - !ruby/object:Gem::Version
78
92
  version: '0'
79
93
  requirements: []
80
94
  rubyforge_project:
81
- rubygems_version: 2.0.14
95
+ rubygems_version: 2.5.2
82
96
  signing_key:
83
97
  specification_version: 4
84
98
  summary: time tools for flor