opening_hours_converter 1.13.10 → 1.13.15

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: d4bac3ea827b78a2d9b0435edcb108ba971f5805c4e812a8672a17ef0890d947
4
- data.tar.gz: b710b6cad6691f9d7e53f18fdf394d7d1b6f64e2abefd2cfad7b3b327c14cc07
3
+ metadata.gz: '0285111a830dec3522015740cb47bd369ae2b380e98d61cdf7b1cb5f28bc63ee'
4
+ data.tar.gz: c5a861db86278d886e244b48079eaf1e82cac515a96adffc1585c7b5df380c2a
5
5
  SHA512:
6
- metadata.gz: ee691bff32b678833ffe4e20b844a1a4b4beae8a4c05d6d81db5728cab926b75a72062d28c26d7d73d27c04c7b6144419fd0e5e013b048029eeb2d154a57446b
7
- data.tar.gz: 5a80b17aecae55f6da6f3a418f9a61d63c6aa8d3a062c3c93243d8239974d535074c2774b13b2456da90f022355eaa8eb40e251a71010a19db68a1f778338242
6
+ metadata.gz: 45727f1c510fd1411d3731a0dee6dc7e20cb352b35aeaafe4caea3293f23dbb29d7e3e83263f41e75f4d7621aaddc7e00179da6986379398b96f3730d64844c5
7
+ data.tar.gz: 70d2591cf15c348db93be5fb90fc6362c6ed4c6373918af3dbfd680cab23b8e8a301dbaaeb6caec8727c9fd256498fc0b8428822d00aa44747d96c27f411a6eb
@@ -68,8 +68,20 @@ module OpeningHoursConverter
68
68
  is_ph = false
69
69
  year = nil
70
70
  year_ph = nil
71
- date_ranges.each do |dr|
72
- is_ph = true if dr.is_holiday?
71
+ date_ranges.each do |date_range|
72
+ is_ph = true if date_range.is_holiday?
73
+ end
74
+
75
+ date_ranges = date_ranges.flat_map do |date_range|
76
+ if date_range.wide_interval.type == 'week' # Generate date range list from week syntax
77
+ date_range.wide_interval.to_day.map do |day|
78
+ day_range = date_range.dup
79
+ day_range.update_range(day)
80
+ day_range
81
+ end
82
+ else
83
+ date_range
84
+ end
73
85
  end
74
86
 
75
87
  date_ranges_array = get_iterator(date_ranges)
@@ -82,6 +94,7 @@ module OpeningHoursConverter
82
94
  year = day.year
83
95
  year_ph = PublicHoliday.ph_for_year(year)
84
96
  end
97
+
85
98
  date_ranges[index].typical.intervals.each do |i|
86
99
  next unless !i.nil? && !i.is_off
87
100
 
@@ -107,7 +107,7 @@ module OpeningHoursConverter
107
107
  elsif !(@regex_handler.month_day_regex =~ wide_range_selector).nil?
108
108
  months << get_month_day(wide_range_selector)
109
109
  elsif !(@regex_handler.month_regex =~ wide_range_selector).nil?
110
- months << get_month(wide_range_selector)
110
+ months += get_month(wide_range_selector)
111
111
  elsif !(@regex_handler.year_regex =~ wide_range_selector).nil?
112
112
  years << get_year(wide_range_selector)
113
113
  elsif !(@regex_handler.multi_month_regex =~ wide_range_selector).nil?
@@ -408,7 +408,23 @@ module OpeningHoursConverter
408
408
  else
409
409
  month_to = month_from
410
410
  end
411
- { from: month_from, to: month_to }
411
+
412
+ if month_from > month_to
413
+ [
414
+ {
415
+ from: month_from,
416
+ to: 12
417
+ },
418
+ {
419
+ from: 1,
420
+ to: month_to
421
+ }
422
+ ]
423
+ else
424
+ [
425
+ { from: month_from, to: month_to }
426
+ ]
427
+ end
412
428
  end
413
429
 
414
430
  def get_month_day(wrs)
@@ -429,6 +445,7 @@ module OpeningHoursConverter
429
445
  else
430
446
  month_to = nil
431
447
  end
448
+
432
449
  { from_day: month_from, to_day: month_to }
433
450
  end
434
451
 
@@ -534,25 +551,36 @@ module OpeningHoursConverter
534
551
  def get_multi_month(wrs)
535
552
  wrs.split(',').map do |wr|
536
553
  if wr.include?('-')
537
- start_month, end_month = wr.split('-')
554
+ start_month_day, end_month_day = wr.split('-')
555
+
556
+ start_month = start_month_day[0...3]
557
+ start_day = start_month_day[4...start_month_day.length]&.to_i
558
+
559
+ end_month = end_month_day[0...3]
560
+ end_day = end_month_day[4...end_month_day.length]&.to_i
561
+
538
562
  from = {
539
563
  month: OSM_MONTHS.find_index(start_month) + 1,
540
- day: 1
564
+ day: start_day || 1
541
565
  }
542
566
  to = {
543
567
  month: OSM_MONTHS.find_index(end_month) + 1,
544
- day: MONTH_END_DAY[OSM_MONTHS.find_index(end_month)]
568
+ day: end_day || MONTH_END_DAY[OSM_MONTHS.find_index(end_month)]
545
569
  }
546
570
  else
571
+ month = wr[0...3]
572
+ day = wr[4...wr.length]&.to_i
573
+
547
574
  from = {
548
- month: OSM_MONTHS.find_index(wr[0...3]) + 1,
549
- day: 1
575
+ month: OSM_MONTHS.find_index(month) + 1,
576
+ day: day || 1
550
577
  }
551
578
  to = {
552
- month: OSM_MONTHS.find_index(wr[0...3]) + 1,
553
- day: MONTH_END_DAY[OSM_MONTHS.find_index(wr[0...3])]
579
+ month: OSM_MONTHS.find_index(month) + 1,
580
+ day: day || MONTH_END_DAY[OSM_MONTHS.find_index(month)]
554
581
  }
555
582
  end
583
+
556
584
  { from_day: from, to_day: to }
557
585
  end
558
586
  end
@@ -178,7 +178,20 @@ module OpeningHoursConverter
178
178
  end
179
179
 
180
180
  def multi_month_regex
181
- compile(line(potential_list(potential_range(month))))
181
+ compile(
182
+ line(
183
+ potential_list(
184
+ potential_range(
185
+ month +
186
+ potential(
187
+ group(
188
+ space, potential_range(month_day)
189
+ )
190
+ )
191
+ )
192
+ )
193
+ )
194
+ )
182
195
  end
183
196
 
184
197
  def week_value_regex
@@ -286,7 +286,7 @@ module OpeningHoursConverter
286
286
  break
287
287
  end
288
288
 
289
- if current_token.hyphen? || current_token.weekday_modifier?
289
+ if current_token.hyphen? || current_token.comma? || current_token.weekday_modifier?
290
290
  value, made_from, type = add_current_token_to(value, type, made_from)
291
291
  next
292
292
  end
@@ -53,25 +53,25 @@ module OpeningHoursConverter
53
53
  when 'day'
54
54
  if !@end.nil?
55
55
  if @start[:year] && !@end[:year] || @start[:year] && @start[:year] == @end[:year]
56
- result = "du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
56
+ result = "Du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
57
57
  elsif @start[:year] && @end[:year] && @start[:year] != @end[:year]
58
- result = "du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]} #{@end[:year]}"
58
+ result = "Du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]} #{@end[:year]}"
59
59
  elsif @start[:month] != @end[:month]
60
- result = "du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]}"
60
+ result = "Du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]}"
61
61
  else
62
- result = "le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]}"
62
+ result = "Le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]}"
63
63
  end
64
64
  else
65
- result = "le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year] || ''}"
65
+ result = "Le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year] || ''}"
66
66
  end
67
67
  when 'month'
68
68
  if !@end.nil?
69
69
  if @start[:year] && !@end[:year] || @start[:year] && @start[:year] == @end[:year]
70
- result = "de #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} à #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
70
+ result = "De #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} à #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
71
71
  elsif @start[:year] && @end[:year] && @start[:year] != @end[:year]
72
- result = "de #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} à #{IRL_MONTHS[@end[:month] - 1]} #{@end[:year]}"
72
+ result = "De #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} à #{IRL_MONTHS[@end[:month] - 1]} #{@end[:year]}"
73
73
  else
74
- result = "de #{IRL_MONTHS[@start[:month] - 1]} à #{IRL_MONTHS[@end[:month] - 1]}"
74
+ result = "De #{IRL_MONTHS[@start[:month] - 1]} à #{IRL_MONTHS[@end[:month] - 1]}"
75
75
  end
76
76
  else
77
77
  result = "#{IRL_MONTHS[@start[:month] - 1]}#{@start[:year] ? " #{@start[:year]}" : ''}"
@@ -85,17 +85,17 @@ module OpeningHoursConverter
85
85
  when 'holiday'
86
86
  result = if !@end.nil?
87
87
  if !@start[:year]
88
- 'jours fériés'
88
+ 'Jours fériés'
89
89
  else
90
- "les jours fériés de #{@start[:year]} à #{@end[:year]}"
90
+ "Les jours fériés de #{@start[:year]} à #{@end[:year]}"
91
91
  end
92
92
  elsif !@start[:year]
93
- 'jours fériés'
93
+ 'Jours fériés'
94
94
  else
95
- "les jours fériés de #{@start[:year]}"
95
+ "Les jours fériés de #{@start[:year]}"
96
96
  end
97
97
  when 'always'
98
- result = 'tout le temps'
98
+ result = 'Toute l\'année'
99
99
  end
100
100
  result
101
101
  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.13.10
4
+ version: 1.13.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziserman Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json