opening_hours_converter 1.14.0 → 1.14.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
  SHA256:
3
- metadata.gz: 1840d4011474e210bb2248979afc8850829c4eab62b0cb2036a670a70ded1265
4
- data.tar.gz: 0710a806e7ac90d3b61d83bd9281acb1c56546aabb504d8b4961f5eeb05ca1b4
3
+ metadata.gz: 5a2ed9352795f7d666eb4869913debe946bf716477736bce0a692656de42adb4
4
+ data.tar.gz: ac9cc5e9c97d5a34752d4eb9a87b400de4fa79f345ed3feaf342d2eb79e4ba9d
5
5
  SHA512:
6
- metadata.gz: 5160c41e2242e1489b1daddecef9068c3218d9726b7f6c0871176d323796035df2b1d491018b13506e88bbf33212df6549063a5ed81559ad645ac5e59a579962
7
- data.tar.gz: 6e3c009bfb86cfda6a516ee4c86b49cc165211ee323981b20d74b778938249cb88a436601517659a4b17c8d4bc26119dec0e171ef94c6685094a9d8ee407ba6f
6
+ metadata.gz: e101cbe8cca800b452a573349b9058f5569a2a94c7bbbf46f9beb49223b6a5f9655bbe05510f0a2f3be5a87e1d84e948d67d6a433829879e89f3e05e9806fc46
7
+ data.tar.gz: 268214fc3bb1c51242ba19441ab5772c7bf8ae1f16f7d8855aa477acac568984aca9b097ca39da3326c8d90cdf95aa8416aeab76d6b7a05e5f4318bf16f6af18
@@ -67,7 +67,7 @@ module OpeningHoursConverter
67
67
  rule_index = 0
68
68
 
69
69
  while !oh_rule_added && rule_index < rules.length
70
- if rules[rule_index].same_time?(oh_rule) && !rules[rule_index].equals(oh_rule) && rules[rule_index].comment == oh_rule.comment
70
+ if rules[rule_index].mergeable?(oh_rule) && rules[rule_index].same_time?(oh_rule) && !rules[rule_index].equals(oh_rule) && rules[rule_index].comment == oh_rule.comment && rules[rule_index].comment != "off" && oh_rule.comment != "off"
71
71
  begin
72
72
  for date_id in 0...oh_rule.date.length
73
73
  rules[rule_index].add_date(oh_rule.date[date_id])
@@ -294,6 +294,17 @@ module OpeningHoursConverter
294
294
  end
295
295
  end
296
296
 
297
+ def mergeable?(o)
298
+ if o.nil? || o.date.length != @date.length
299
+ true
300
+ else
301
+ @date.each_with_index do |d, i|
302
+ return false if (d.wide_interval.start&.dig(:year) != o.date[i].wide_interval.start&.dig(:year)) && d.wide_interval.type != o.date[i].wide_interval.type
303
+ end
304
+ true
305
+ end
306
+ end
307
+
297
308
  def equals(o)
298
309
  return false unless o.instance_of?(OpeningHoursConverter::OpeningHoursRule)
299
310
  (same_time?(o) && same_date?(o))
@@ -519,7 +519,7 @@ module OpeningHoursConverter
519
519
  if self_to_day.is_a?(Array)
520
520
  if o_to_day.is_a?(Array)
521
521
  return false unless o_to_day.length == self_to_day.length
522
- return self_to_day.all? do |self_day|
522
+ return self.start == o.start && self_to_day.all? do |self_day|
523
523
  o_to_day.any? do |o_day|
524
524
  self_day.equals(o_day)
525
525
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opening_hours_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziserman Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-06 00:00:00.000000000 Z
11
+ date: 2022-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json