Skip to content

Commit 05f7745

Browse files
committed
Fix all remaining rubocop offenses
1 parent 1bfb333 commit 05f7745

File tree

6 files changed

+38
-60
lines changed

6 files changed

+38
-60
lines changed

export_date_range.rb

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
require 'date'
22

33
class ExportDateRange
4-
def self.for(year)
5-
[start_date(year), end_date(year)]
6-
end
4+
class << self
5+
def for(year)
6+
[start_date(year), end_date(year)]
7+
end
78

8-
private
9+
private
910

10-
def self.start_date(year)
11-
Date.new(year, 1, 1)
12-
end
11+
def start_date(year)
12+
Date.new(year, 1, 1)
13+
end
1314

14-
def self.end_date(year)
15-
if this_year?(year)
16-
Date.new(year, Date.today.month, Date.today.day - 1)
17-
else
18-
Date.new(year, 12, 31)
15+
def end_date(year)
16+
if this_year?(year)
17+
Date.new(year, Date.today.month, Date.today.day - 1)
18+
else
19+
Date.new(year, 12, 31)
20+
end
1921
end
20-
end
2122

22-
def self.this_year?(year)
23-
year == Date.today.year
23+
def this_year?(year)
24+
year == Date.today.year
25+
end
2426
end
2527
end

holiday_client.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def holiday_regions
2727

2828
def holidays_between
2929
Holidays.cache_between(
30-
startdate, startdate.next_year(1) - 1, *holiday_regions, :informal, :observed
30+
startdate, startdate.next_year(1) - 1,
31+
*holiday_regions, :informal, :observed
3132
).values.flatten
3233
end
3334
end

output_generator.rb

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@ def run
3737

3838
def output_csv_lines_for(date)
3939
if holiday_dates.include?(date)
40-
generate_output(date, rand(12_000..13_500), distribution.special_day, distribution.special_week)
40+
generate_output(
41+
date, rand(12_000..13_500),
42+
distribution.special_day, distribution.special_week
43+
)
4144
else
42-
generate_output(date, rand(13_500..14_500), distribution.normal_day, distribution.normal_week)
43-
end
45+
generate_output(date, rand(13_500..14_500),
46+
distribution.normal_day, distribution.normal_week)
47+
end
4448
end
4549

4650
def holiday_dates
47-
dates ||= HolidayClient.new(start_date, end_date, region).holidays.map { |h| h[1] }
51+
HolidayClient.new(
52+
start_date, end_date, region
53+
).holidays.map { |h| h[1] }
4854
end
4955

5056
private
@@ -61,16 +67,19 @@ def header
6167
'Queue;Date;Time;CallsOffered;CallsHandled;AHT'
6268
end
6369

64-
def generate_output(date, weekly_volume, daily_distribution, weekly_destribution)
70+
def generate_output(date, weekly_volume,
71+
daily_distribution, weekly_destribution)
6572
daily_volume = weekly_destribution[date.wday] * weekly_volume
6673
daily_distribution.each_with_index do |value, interval|
67-
random_value = IntervalValueRandomizer.new(daily_volume, value)
74+
random = IntervalValueRandomizer.new(daily_volume, value)
6875
time_string = build_time_string(interval)
69-
puts "#{queue_name};#{date.strftime('%d.%m.%Y')};#{time_string};#{random_value.calls};#{random_value.handled_calls};#{random_value.aht}"
76+
puts "#{queue_name};#{date.strftime('%d.%m.%Y')};#{time_string};" \
77+
"#{random.calls};#{random.handled_calls};#{random.aht}"
7078
end
7179
end
7280

7381
def distribution
74-
Distribution.new(open_time: @opening_hours.open, close_time: @opening_hours.close)
82+
Distribution.new(open_time: @opening_hours.open,
83+
close_time: @opening_hours.close)
7584
end
7685
end

random_csv.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class RandomCsv
88
class << self
99
def generate_output
1010
start_date, end_date = ExportDateRange.for(first_argument_or_default_year)
11-
output = OutputGenerator.new(
11+
OutputGenerator.new(
1212
region: second_argument_or_default,
1313
start_date: start_date,
1414
end_date: end_date,

spec/script_spec.rb

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,6 @@
33

44
RSpec.describe Script do
55
context 'data generation' do
6-
it 'generates an array with 48 elements' do
7-
expect(Script.new.base).to eq Array.new(48)
8-
end
9-
10-
it 'knows percentages per interval' do
11-
expect(Script.new.percentages).to eq [
12-
0.18,
13-
0.39,
14-
1.36,
15-
2.89,
16-
4.40,
17-
5.01,
18-
5.22,
19-
6.20,
20-
6.31,
21-
6.19,
22-
5.94,
23-
6.01,
24-
5.31,
25-
5.50,
26-
5.34,
27-
5.25,
28-
4.55,
29-
4.26,
30-
4.22,
31-
4.06,
32-
3.51,
33-
3.05,
34-
2.59,
35-
2.14,
36-
0.11
37-
]
38-
end
39-
406
it 'calculates a percentage from an input value' do
417
end
428
end

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
#
9393
# # Seed global randomization in this process using the `--seed` CLI option.
9494
# # Setting this allows you to use `--seed` to deterministically reproduce
95-
# # test failures related to randomization by passing the same `--seed` value
95+
# # test failures related to randomization by passing same `--seed` value
9696
# # as the one that triggered the failure.
9797
# Kernel.srand config.seed
9898
end

0 commit comments

Comments
 (0)