cron_format 0.3.5 → 0.4.0

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
  SHA1:
3
- metadata.gz: 770687981ae1603cae0ae5742d3361dc96b5a92e
4
- data.tar.gz: 159e4a8dc03bafb524c3daf488c8cf95e5c5ddca
3
+ metadata.gz: 16b339c6d41735353e8cf1268fd8faf1bef76e8c
4
+ data.tar.gz: bdf4d4506b8234269bc979096a8cb58545758255
5
5
  SHA512:
6
- metadata.gz: a6a96846405c3a0fb418f361d806fcb1535a7cee7682e58014937e83e36ee98523456178bd2386b16d0ec97619b7ec6a0273a04b02e33d2b076e282449bc1633
7
- data.tar.gz: 36115594470e04363446f08bdc91516a6f3bce814500f6442ce8879eabc44ca6de8b6ff63cc66ddb930ba1e742aead7bebb2efddea3bc0749a29e8adec6121aa
6
+ metadata.gz: 8fd195d79177cdf7295dd15c35179b458914e0f6785999ce554bfc169dfb98dce90b155b5acce4a669662f56a10b026fba31ba31c0af6fdbcbbce30ea7b77365
7
+ data.tar.gz: 51e59d602b155bafa33692277762010bf21f563591a9d6fec6dc0fa4b3ef7e286f24e1a3ee8e1ba63a138d63f5fd92845b36612d9b5a8c1db6b4a724b82bd186
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/cron_format.rb CHANGED
@@ -17,8 +17,8 @@ class CronFormat
17
17
 
18
18
  attr_reader :to_time, :to_expression
19
19
 
20
- def initialize(cron_string, now=Time.now)
21
- @cron_string, @to_time = cron_string, now
20
+ def initialize(cron_string, now=Time.now, debug: false)
21
+ @cron_string, @to_time, @debug = cron_string, now, debug
22
22
  parse()
23
23
  end
24
24
 
@@ -51,6 +51,7 @@ class CronFormat
51
51
  def nudge()
52
52
 
53
53
  t1 = @to_time
54
+ puts 't1: ' + t1.inspect if @debug
54
55
  a = @cron_string.split
55
56
 
56
57
  val = if @cron_string =~ %r{[/,-]} then
@@ -60,6 +61,8 @@ class CronFormat
60
61
  end
61
62
 
62
63
  index, n = 0, 1
64
+
65
+ puts 'val: ' + val.inspect if @debug
63
66
 
64
67
  if val then
65
68
  index = a.index(val)
@@ -80,7 +83,8 @@ class CronFormat
80
83
  end
81
84
  end
82
85
 
83
-
86
+ puts 'index: ' + index.inspect if @debug
87
+
84
88
  month_proc = lambda {|t1,n|
85
89
  a = t1.to_a
86
90
  a[4] = a[4] + n <= 12 ? a[4] + n : a[4] + n - 12
@@ -98,12 +102,26 @@ class CronFormat
98
102
  month_proc,
99
103
  day_proc
100
104
  ]
101
-
105
+
106
+ if @debug then
107
+ puts '@to_time: ' + @to_time.inspect
108
+ puts 'n: ' + n.inspect
109
+ end
110
+
102
111
  r = units[index].call @to_time, n
112
+
113
+ puts 'r: ' + r.inspect if @debug
114
+
115
+ @to_time = if n > 1 then
116
+
117
+ # given day light savings, ensure the time fragment is preserved
118
+ Time.new(r.year, r.month, r.day, t1.hour, t1.min)
119
+
120
+ else
121
+ r
122
+ end
103
123
  #r += MINUTE if r == t1
104
124
 
105
- @to_time = r
106
-
107
125
  end
108
126
 
109
127
  def parse()
data.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- %Z���%M ��i��>����:ѣ9gQ�}W\��[�,��Z�J���Gm"I�:�A�<|%��$����"�q�}܉�)$
1
+ ૄ��Q0->��߈����Lh!����(,���*�8���w�:���6k7O����%�ׂ}J��Wh�sXΖ$}�� ��h�q k�9Nj�%�o�)o��yg�'��u&����xϫ��Qu`��yY7d,��
2
+ 35����/�����_?��.���o�•�l�dk��W�c1ts!/�����1[S�P@�,& A��ny�C�FB�dn�;1_�T{^.�QN8[䓱�
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cron_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,26 +11,26 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDXjCC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x05w2txGJLZMvv
28
+ N/ETFF5O4SD1tsPaLS5/kjAk+epirsb/UR8gLq37tyosM79P10HeikBdOMqXmN7U
29
+ 8Wj31raYqIS2rUA0lp+u+e4gKg4r0EBcIqH3pHahMd5le9D3yIwfPLuURhHwBw6R
30
+ Jde8bC6zoA/f/DUUzBf2TtjXPuoAdtsV3CT3nIo880mXyihT9CL9ulTHMJCBR73I
31
+ fsk=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-03-13 00:00:00.000000000 Z
33
+ date: 2018-04-09 00:00:00.000000000 Z
34
34
  dependencies: []
35
35
  description:
36
36
  email: james@jamesrobertson.eu
@@ -62,5 +62,6 @@ rubyforge_project:
62
62
  rubygems_version: 2.6.13
63
63
  signing_key:
64
64
  specification_version: 4
65
- summary: cron_format
65
+ summary: Accepts a cron expression and outputs the relative time (e.g. 0 7 1 1 * *
66
+ => 2019-01-01 07:00:00 +0000
66
67
  test_files: []
metadata.gz.sig CHANGED
Binary file