ice_cube 0.16.0 → 0.16.1

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: 01f55d89af28400fc30bdfe60ccacd66e42212b0
4
- data.tar.gz: a7e85b8afe0d56f8b47c3e22139d080e035ee465
3
+ metadata.gz: d075ab984a12f078d212922e5119adb3280095f9
4
+ data.tar.gz: afed7767f9d95f17308f6dd3a40fcfc025c46d44
5
5
  SHA512:
6
- metadata.gz: a87067a8e0a099b1f9740bd4dab4ed408c72827c1498370b81ba3df3f6246fc7be12f8343f63832554dfa990f1754e5af365755831490d767df84b3462d49a41
7
- data.tar.gz: d41ba1b2a5dc98db1522a38320452d9404a92510872a0473ba6dc9b440a5258352ea484ce28dc663908bf6bc19d747f4099035549865745377e4be9f035aed28
6
+ metadata.gz: 2a24dc8dc9b8a745a6753bc60d9551366af050e3ce7d80d32b4d7c6b97006c0a9c65338a75fb4b184141bb38467dbb0e73eca98e35f2407f29d79df5bd069a3a
7
+ data.tar.gz: c309f41dd53711998b439544e5b9b386617d2a2b63b1792688cff76346b56765a11012b4d15e3cede673f8ed658a9997ac0e430c4af34bb7c8fa7aed35f3bc57
@@ -0,0 +1,178 @@
1
+ pt-BR:
2
+ ice_cube:
3
+ pieces_connector: ' / '
4
+ not: 'exceto %{target}'
5
+ not_on: 'exceto o dia %{target}'
6
+ date:
7
+ formats:
8
+ default: '%-d %B %Y'
9
+ month_names:
10
+ -
11
+ - Janeiro
12
+ - Fevereiro
13
+ - Março
14
+ - Abril
15
+ - Maio
16
+ - Junho
17
+ - Julho
18
+ - Agosto
19
+ - Setembro
20
+ - Outubro
21
+ - Novembro
22
+ - Dezembro
23
+ day_names:
24
+ - Domingo
25
+ - Segunda
26
+ - Terça
27
+ - Quarta
28
+ - Quinta
29
+ - Sexta
30
+ - Sábado
31
+ times:
32
+ other: '%{count} vezes'
33
+ one: '%{count} vez'
34
+ until: 'até %{date}'
35
+ days_of_week: '%{segments} %{day}'
36
+ days_of_month:
37
+ other: '%{segments} dias do mês'
38
+ one: '%{segments} dia'
39
+ days_of_year:
40
+ other: '%{segments} dias do ano'
41
+ one: '%{segments} dia'
42
+ at_hours_of_the_day:
43
+ other: às %{segments} horas
44
+ one: à %{segments} hora
45
+ on_minutes_of_hour:
46
+ other: aos %{segments} minutos
47
+ one: ao %{segments} minuto
48
+ at_seconds_of_minute:
49
+ other: aos %{segments} segundos
50
+ one: ao %{segments} segundo
51
+ on_seconds_of_minute:
52
+ other: aos %{segments} segundos
53
+ one: ao %{segments} segundo
54
+ each_second:
55
+ one: A cada segundo
56
+ other: A cada %{count} segundos
57
+ each_minute:
58
+ one: A cada minuto
59
+ other: A cada %{count} minutos
60
+ each_hour:
61
+ one: A cada hora
62
+ other: A cada %{count} horas
63
+ each_day:
64
+ one: Diariamente
65
+ other: A cada %{count} dias
66
+ each_week:
67
+ one: Semanalmente
68
+ other: A cada %{count} semanas
69
+ each_month:
70
+ one: Mensalmente
71
+ other: A cada %{count} meses
72
+ each_year:
73
+ one: Anualmente
74
+ other: A cada %{count} anos
75
+ 'on': no %{sentence}
76
+ in: 'em %{target}'
77
+ integer:
78
+ negative: '%{ordinal} depois que acabar'
79
+ literal_ordinals:
80
+ -1: último
81
+ -2: penúltimo
82
+ ordinal: '%{number}%{ordinal}'
83
+ ordinals:
84
+ default: º
85
+ 1: º
86
+ 2: º
87
+ 3: º
88
+ 11: º
89
+ 12: º
90
+ 13: º
91
+ on_weekends: nos finais de semana
92
+ on_weekdays: nos dias úteis
93
+ days_on:
94
+ - Domingos
95
+ - Segundas-feiras
96
+ - Terças-feiras
97
+ - Quartas-feiras
98
+ - Quintas-feiras
99
+ - Sextas-feiras
100
+ - Sábados
101
+ on_days: no dia %{days}
102
+ array:
103
+ last_word_connector: ' e '
104
+ two_words_connector: ' e '
105
+ words_connector: ', '
106
+ string:
107
+ format:
108
+ day: '%{rest} %{current}'
109
+ day_of_week: '%{rest} %{current}'
110
+ day_of_month: '%{rest} %{current}'
111
+ day_of_year: '%{rest} %{current}'
112
+ hour_of_day: '%{rest} %{current}'
113
+ minute_of_hour: '%{rest} %{current}'
114
+ until: '%{rest} %{current}'
115
+ count: '%{rest} %{current}'
116
+ default: '%{rest} %{current}'
117
+
118
+ date:
119
+ abbr_day_names:
120
+ - Dom
121
+ - Seg
122
+ - Ter
123
+ - Qua
124
+ - Qui
125
+ - Sex
126
+ - Sáb
127
+ abbr_month_names:
128
+ -
129
+ - Jan
130
+ - Fev
131
+ - Mar
132
+ - Abr
133
+ - Mai
134
+ - Jun
135
+ - Jul
136
+ - Ago
137
+ - Set
138
+ - Out
139
+ - Nov
140
+ - Dez
141
+ day_names:
142
+ - Domingo
143
+ - Segunda-feira
144
+ - Terça-feira
145
+ - Quarta-feira
146
+ - Quinta-feira
147
+ - Sexta-feira
148
+ - Sábado
149
+ formats:
150
+ default: "%d/%m/%Y"
151
+ long: "%d de %B de %Y"
152
+ short: "%d de %B"
153
+ month_names:
154
+ -
155
+ - Janeiro
156
+ - Fevereiro
157
+ - Março
158
+ - Abril
159
+ - Maio
160
+ - Junho
161
+ - Julho
162
+ - Agosto
163
+ - Setembro
164
+ - Outubro
165
+ - Novembro
166
+ - Dezembro
167
+ order:
168
+ - :day
169
+ - :month
170
+ - :year
171
+
172
+ time:
173
+ am: ''
174
+ formats:
175
+ default: "%a, %d de %B de %Y, %H:%M:%S %z"
176
+ long: "%d de %B de %Y, %H:%M"
177
+ short: "%d de %B, %H:%M"
178
+ pm: ''
data/lib/ice_cube/rule.rb CHANGED
@@ -27,8 +27,7 @@ module IceCube
27
27
  end
28
28
 
29
29
  def hash
30
- h = to_hash
31
- h.nil? ? super : h.hash
30
+ to_hash.hash
32
31
  end
33
32
 
34
33
  def to_ical
@@ -13,21 +13,33 @@ module IceCube
13
13
  reset
14
14
  end
15
15
 
16
- # Calculate the effective start time for when the given start time is later
17
- # in the week than one of the weekday validations, such that times could be
18
- # missed by a 7-day jump using the weekly interval, or when selecting from a
19
- # date that is misaligned from the schedule interval.
16
+ # Move the effective start time to correct for when the schedule has
17
+ # validations earlier in the week than the selected start time, e.g.
18
+ #
19
+ # Schedule.new(wednesday).weekly(2).day(:monday)
20
+ #
21
+ # The effective start time gets realigned to the second next Monday, jumping
22
+ # over the gap week for the interval (2). Without realignment, the correct
23
+ # Monday occurrence would be missed when the schedule performs a 7-day jump
24
+ # into the next interval week, arriving on the Wednesday. This corrects any
25
+ # selections from dates that are misaligned to the schedule interval.
20
26
  #
21
27
  def realign(step_time, start_time)
22
28
  time = TimeUtil::TimeWrapper.new(start_time)
23
29
  offset = wday_offset(step_time, start_time)
24
- time.add(:day, offset) if offset
30
+ time.add(:day, offset)
25
31
  time.to_time
26
32
  end
27
33
 
34
+ # Calculate how many days to the first wday validation in the correct
35
+ # interval week. This may move backwards within the week if starting in an
36
+ # interval week with earlier validations.
37
+ #
28
38
  def wday_offset(step_time, start_time)
39
+ return 0 if step_time == start_time
40
+
29
41
  wday_validations = other_interval_validations.select { |v| v.type == :wday }
30
- return if wday_validations.none?
42
+ return 0 if wday_validations.none?
31
43
 
32
44
  days = (step_time - start_time).to_i / ONE_DAY
33
45
  interval = base_interval_validation.validate(step_time, start_time).to_i
@@ -386,6 +386,19 @@ module IceCube
386
386
  recurrence_rules.empty? || recurrence_rules.all?(&:terminating?)
387
387
  end
388
388
 
389
+ def hash
390
+ [
391
+ TimeUtil.hash(start_time), duration,
392
+ *@all_recurrence_rules.map(&:hash).sort!,
393
+ *@all_exception_rules.map(&:hash).sort!
394
+ ].hash
395
+ end
396
+
397
+ def eql?(other)
398
+ self.hash == other.hash
399
+ end
400
+ alias == eql?
401
+
389
402
  def self.dump(schedule)
390
403
  return schedule if schedule.nil? || schedule == ""
391
404
  schedule.to_yaml
@@ -109,6 +109,14 @@ module IceCube
109
109
  end
110
110
  end
111
111
 
112
+ # Get a more precise equality for time objects
113
+ # Ruby provides a Time#hash method, but it fails to account for UTC
114
+ # offset (so the current date may be different) or DST rules (so the
115
+ # hour may be wrong for different schedule occurrences)
116
+ def self.hash(time)
117
+ [time, time.utc_offset, time.zone].hash
118
+ end
119
+
112
120
  # Check the deserialized time offset string against actual local time
113
121
  # offset to try and preserve the original offset for plain Ruby Time. If
114
122
  # the offset is the same as local we can assume the same original zone and
@@ -59,7 +59,10 @@ module IceCube
59
59
  # to the given start time
60
60
  def next_time(time, start_time, closing_time)
61
61
  @time = time
62
- @start_time ||= realign(time, start_time)
62
+ unless @start_time
63
+ @start_time = realign(time, start_time)
64
+ @time = @start_time if @time < @start_time
65
+ end
63
66
 
64
67
  return nil unless find_acceptable_time_before(closing_time)
65
68
 
@@ -134,7 +137,7 @@ module IceCube
134
137
 
135
138
  def normalized_interval(interval)
136
139
  int = interval.to_i
137
- raise ArgumentError, "'#{interval}' is not a valid input for interval. Please pass an integer." unless int > 0
140
+ raise ArgumentError, "'#{interval}' is not a valid input for interval. Please pass a postive integer." unless int > 0
138
141
  int
139
142
  end
140
143
 
@@ -1,5 +1,5 @@
1
1
  module IceCube
2
2
 
3
- VERSION = '0.16.0'
3
+ VERSION = '0.16.1'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ice_cube
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Crepezzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-13 00:00:00.000000000 Z
11
+ date: 2017-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -50,6 +50,7 @@ files:
50
50
  - config/locales/es.yml
51
51
  - config/locales/fr.yml
52
52
  - config/locales/ja.yml
53
+ - config/locales/pt-BR.yml
53
54
  - config/locales/ru.yml
54
55
  - config/locales/sv.yml
55
56
  - lib/ice_cube.rb