opening_hours_converter 1.13.9 → 1.13.14

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: 934c7bb88ac5fcf73e4a213c82f7f84fea36cb88c68534cb409d14ff2272df0b
4
- data.tar.gz: cdfa07abc240fb6399605108f5ab6cf3fefd75b19e08590c230fa2e1983c28df
3
+ metadata.gz: '00159189d902d1f186853f6ec21e6547f519a4aa287f1345207726c407544c73'
4
+ data.tar.gz: 811ea32145a84b1d223ed273eb24ce3780f93cbacd968444eaec97c7c8761792
5
5
  SHA512:
6
- metadata.gz: 8524fbb0d76e45c5e0173f7df2c0a31b17edbeddd501c9c476de7171a6e20463962ed049e04b3562cc9cd0f471dee65f2c679f97c96657750b77c8c9f4e1a155
7
- data.tar.gz: 5f09e6388c2b64b7b9e0ae0887b30226d98af045d4b9c43294ceb3dc34a5ecf4a092e16a644923aadba30ba52dc7e7f7e319804b7825c55ba75fde403f687363
6
+ metadata.gz: f551d277daa96358792f80c6535a170155d27c6e030466ba7e834882f4b7cb1c8e7397af72e64ee6e22c5dfe3dd92426041ce7c133234e3afd69d6826c21cfbc
7
+ data.tar.gz: 4eb66cd74374778dd58727d3e77d1c6293e878f6d1621d262636895f212bc92deee4e0b62e966df37c2b64f9cd37961e86d1cbef0cb917d0740f3c19609ab746
@@ -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
 
@@ -502,7 +519,7 @@ module OpeningHoursConverter
502
519
  year = wrs[0...4]
503
520
 
504
521
  wrs.split(',').map.with_index do |wr|
505
- if wr.start_with?(/#{@regex_handler.year}/)
522
+ if wr =~ /^#{@regex_handler.year}/
506
523
  year = wr[0...4]
507
524
  wr = wr[5...wr.length]
508
525
  end
@@ -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.9
4
+ version: 1.13.14
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-18 00:00:00.000000000 Z
11
+ date: 2020-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json