coursegen 0.8.3 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/pr.yml +19 -0
- data/.gitignore +3 -0
- data/Gemfile.lock +60 -35
- data/README.md +285 -69
- data/Rakefile +10 -1
- data/coursegen.gemspec +26 -26
- data/lib/coursegen.rb +5 -2
- data/lib/coursegen/cli.rb +49 -14
- data/lib/coursegen/course/data/citem.rb +10 -1
- data/lib/coursegen/course/data/data_adaptor.rb +16 -6
- data/lib/coursegen/course/data/section.rb +1 -1
- data/lib/coursegen/course/helpers/bootstrap_markup.rb +15 -15
- data/lib/coursegen/course/helpers/content_helpers.rb +86 -71
- data/lib/coursegen/course/helpers/formatting_helpers.rb +6 -10
- data/lib/coursegen/course/helpers/ical_feed_helpers.rb +2 -1
- data/lib/coursegen/course/helpers/lecture_helpers.rb +3 -2
- data/lib/coursegen/course/helpers/list_of.rb +40 -20
- data/lib/coursegen/course/helpers/list_of_helpers.rb +20 -14
- data/lib/coursegen/course/helpers/logging_helpers.rb +13 -12
- data/lib/coursegen/course/helpers/navigation_helpers.rb +62 -23
- data/lib/coursegen/course/helpers/sidebar_helpers.rb +19 -18
- data/lib/coursegen/course/helpers/table_helpers.rb +5 -4
- data/lib/coursegen/course/schedule/scheduler.rb +52 -19
- data/lib/coursegen/templates.rb +30 -23
- data/lib/coursegen/version.rb +3 -1
- data/spec/lectures_spec.rb +60 -50
- data/spec/play_spec.rb +24 -12
- data/spec/scheduler_spec.rb +87 -27
- data/tech_debt.md +5 -0
- data/templates/Rules +14 -19
- data/templates/cg_config.rb +105 -21
- data/templates/content/bootstrap/css/custom.css +87 -151
- data/templates/content/bootstrap/css/full-width-pics.css +8 -64
- data/templates/content/bootstrap/css/postit.css +7 -0
- data/templates/content/bootstrap/css/toasty.css +3 -0
- data/templates/content/content/index.md.erb +1 -1
- data/templates/content/content/intro/course_toc.md.erb +0 -1
- data/templates/content/content/intro/welcome.md.erb +1 -3
- data/templates/content/content/lectures/part1/02_here_we_go.md.erb +22 -1
- data/templates/content/content/lectures/part2/01_start_part2.md.erb +2 -1
- data/templates/content/content/lectures/part2/02_continue_part2.md.erb +3 -2
- data/templates/layouts/banner.html.erb +4 -4
- data/templates/layouts/body_footer.html +3 -4
- data/templates/layouts/body_header.html.erb +25 -7
- data/templates/layouts/bottom_includes.html.erb +21 -10
- data/templates/layouts/course.html.erb +7 -21
- data/templates/layouts/helpful_box.html +1 -1
- data/templates/layouts/nav-menus.html.erb +16 -36
- data/templates/layouts/sidebar.html.erb +9 -8
- data/templates/layouts/slides.html.erb +69 -0
- data/templates/layouts/top_includes.html.erb +24 -23
- metadata +32 -24
- data/.DS_Store +0 -0
- data/.vscode/settings.json +0 -2
- data/templates/.DS_Store +0 -0
- data/templates/Guardfile +0 -9
- data/templates/content/bootstrap/css/tipuesearch.css +0 -163
- data/templates/content/bootstrap/js/tipuesearch.js +0 -379
- data/templates/content/bootstrap/js/tipuesearch.min.js +0 -12
- data/templates/content/bootstrap/js/tipuesearch_content.js +0 -13
- data/templates/content/bootstrap/js/tipuesearch_set.js +0 -23
- data/templates/layouts/main_navbar.html.erb +0 -21
@@ -1,5 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'date'
|
2
|
+
require 'active_support'
|
3
|
+
require 'active_support/core_ext/numeric/time'
|
4
|
+
|
5
|
+
WEEKDAYS = { sunday: 0, monday: 1, tuesday: 2,
|
6
|
+
wednesday: 3, thursday: 4, friday: 5, saturday: 6 }.freeze
|
3
7
|
|
4
8
|
# Calculate days on which each event occurs, based on the configuration info
|
5
9
|
class Scheduler
|
@@ -26,8 +30,17 @@ class Scheduler
|
|
26
30
|
@start = nil
|
27
31
|
return
|
28
32
|
end
|
29
|
-
|
30
|
-
|
33
|
+
|
34
|
+
setup_from_args(
|
35
|
+
start: sdef.first_day,
|
36
|
+
weekdays: sdef.weekdays,
|
37
|
+
number: sdef.number,
|
38
|
+
skips: sdef.skips,
|
39
|
+
start_time: sdef.start_time,
|
40
|
+
end_time: sdef.end_time,
|
41
|
+
start_times: sdef.start_times,
|
42
|
+
end_times: sdef.end_times
|
43
|
+
)
|
31
44
|
end
|
32
45
|
|
33
46
|
def event_date_by_index(ind)
|
@@ -41,14 +54,15 @@ class Scheduler
|
|
41
54
|
private
|
42
55
|
|
43
56
|
def recalc_event_map
|
44
|
-
return if
|
57
|
+
return if null?
|
58
|
+
|
45
59
|
@event_dates = []
|
46
60
|
@event_start_times = []
|
47
61
|
@event_end_times = []
|
48
62
|
wkdy_of_start = @start_date.cwday
|
49
63
|
wkday_index = @weekdays.find_index(wkdy_of_start)
|
50
64
|
curr_event_date = @start_date
|
51
|
-
@number.times do |
|
65
|
+
@number.times do |_i|
|
52
66
|
unless @skips.include? curr_event_date
|
53
67
|
@event_dates << curr_event_date
|
54
68
|
@event_start_times << @start_times[wkday_index]
|
@@ -70,31 +84,50 @@ class Scheduler
|
|
70
84
|
start_time, end_time, start_times, end_times)
|
71
85
|
@number = number + skips.length
|
72
86
|
@start_date = string_to_date(start)
|
73
|
-
@skips =
|
74
|
-
|
75
|
-
|
87
|
+
@skips = begin
|
88
|
+
skips.map { |d| string_to_date(d) }
|
89
|
+
rescue StandardError
|
90
|
+
raise(ArgumentError, 'Scheduler: Invalid skip date')
|
91
|
+
end
|
92
|
+
|
93
|
+
unless weekdays.all? { |wd| WEEKDAYS.include? wd }
|
94
|
+
raise ArgumentError, 'Scheduler: invalid weekdays'
|
95
|
+
end
|
76
96
|
|
77
|
-
@weekdays = weekdays.map { |wd| WEEKDAYS[wd]}
|
78
|
-
|
79
|
-
|
97
|
+
@weekdays = weekdays.map { |wd| WEEKDAYS[wd] }
|
98
|
+
unless @weekdays.include? @start_date.cwday
|
99
|
+
raise ArgumentError, 'Scheduler: Start date is not on one of the weekdays'
|
100
|
+
end
|
101
|
+
unless @skips.reduce(true) { |accum, skip| accum && @weekdays.include?(skip.cwday) }
|
102
|
+
raise ArgumentError, 'Scheduler: Skip date is not on a valid weekday'
|
103
|
+
end
|
80
104
|
|
81
|
-
@start_time =
|
82
|
-
|
83
|
-
|
84
|
-
|
105
|
+
@start_time = begin
|
106
|
+
time_span_to_seconds(start_time)
|
107
|
+
rescue StandardError
|
108
|
+
raise(ArgumentError, "error converting start time. Use hh:mm: #{start_time} ")
|
109
|
+
end
|
110
|
+
@end_time = begin
|
111
|
+
time_span_to_seconds(end_time)
|
112
|
+
rescue StandardError
|
113
|
+
raise(ArgumentError, "error converting end time. Use hh:mm: #{end_time}")
|
114
|
+
end
|
115
|
+
@start_times = start_times.map { |x| time_span_to_seconds(x) }
|
116
|
+
@end_times = end_times.map { |x| time_span_to_seconds(x) }
|
85
117
|
end
|
86
118
|
|
87
119
|
def string_to_date(string_date)
|
88
|
-
Date.strptime(string_date,
|
120
|
+
Date.strptime(string_date, '%b-%d-%Y')
|
121
|
+
rescue StandardError
|
122
|
+
raise "string to date in scheduler.rb #{string_date}"
|
89
123
|
end
|
90
124
|
|
91
125
|
def strings_to_date_time(string_date, string_time)
|
92
|
-
DateTime.strptime(string_date +
|
126
|
+
DateTime.strptime(string_date + ' ' + string_time, '%b-%d-%Y %H:%M')
|
93
127
|
end
|
94
128
|
|
95
129
|
def time_span_to_seconds(string_time)
|
96
130
|
result = string_time.match(/(\d\d):(\d\d)/)
|
97
131
|
result[1].to_i.hours + result[2].to_i.minutes
|
98
132
|
end
|
99
|
-
|
100
133
|
end
|
data/lib/coursegen/templates.rb
CHANGED
@@ -1,32 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pry'
|
2
4
|
|
3
5
|
module CourseGen
|
6
|
+
# Class Templates represent a Coursegen template.
|
4
7
|
class Templates < Thor::Group
|
5
8
|
include Thor::Actions
|
6
9
|
|
10
|
+
# Generate_all generates a Coursegen site using the default template.
|
7
11
|
def generate_all
|
8
|
-
copy_template_dir(
|
9
|
-
copy_template_dir(
|
10
|
-
copy_template_dir(
|
11
|
-
delete_target_file(
|
12
|
-
copy_template_dir(
|
13
|
-
delete_target_file(
|
14
|
-
copy_template_file(
|
15
|
-
copy_template_file(
|
16
|
-
copy_template_file(
|
17
|
-
copy_template_file(
|
18
|
-
|
19
|
-
delete_target_file(
|
20
|
-
delete_target_file(
|
21
|
-
|
22
|
-
create_empty_dir("content/images")
|
12
|
+
copy_template_dir('layouts', 'layouts')
|
13
|
+
copy_template_dir('content/bootstrap', 'content/bootstrap')
|
14
|
+
copy_template_dir('content/content', 'content/content')
|
15
|
+
delete_target_file('lib/default.rb')
|
16
|
+
copy_template_dir('lib', 'lib')
|
17
|
+
delete_target_file('Rules')
|
18
|
+
copy_template_file('Rules', 'Rules')
|
19
|
+
copy_template_file('.gitignore', '.gitignore')
|
20
|
+
copy_template_file('cg_config.rb', 'cg_config.rb')
|
21
|
+
copy_template_file('cg_config.rb_sample', 'cg_config.rb_sample')
|
22
|
+
delete_target_file('content/stylesheet.css')
|
23
|
+
delete_target_file('content/index.html')
|
24
|
+
delete_target_file('layouts/default.html')
|
25
|
+
create_empty_dir('content/images')
|
23
26
|
end
|
24
27
|
|
28
|
+
# Valid_cg_directory? checks if the underlying directory is a valid
|
29
|
+
# nanoc site.
|
30
|
+
#
|
31
|
+
# This method is used by Coursegen::CLI.
|
25
32
|
def valid_cg_directory?
|
26
33
|
valid = true
|
27
|
-
list = [
|
34
|
+
list = ['Rules', 'nanoc.yaml', 'content', 'lib']
|
28
35
|
list.each do |filename|
|
29
|
-
|
36
|
+
unless File.exist?(filename)
|
30
37
|
valid = false
|
31
38
|
say("Required file not found: #{filename}")
|
32
39
|
end
|
@@ -38,22 +45,22 @@ module CourseGen
|
|
38
45
|
Pathname.new(File.dirname(__FILE__)).parent.parent.to_s
|
39
46
|
end
|
40
47
|
|
41
|
-
# invoke methods from Thor::Actions
|
48
|
+
# invoke methods from Thor::Actions
|
42
49
|
def initialize
|
43
50
|
super
|
44
51
|
destination_root = Dir.getwd
|
45
52
|
end
|
46
53
|
|
47
|
-
def create_empty_dir
|
54
|
+
def create_empty_dir(to)
|
48
55
|
empty_directory(to)
|
49
56
|
end
|
50
57
|
|
51
|
-
def copy_template_dir
|
52
|
-
directory("templates/#{from}",
|
58
|
+
def copy_template_dir(from, to)
|
59
|
+
directory("templates/#{from}", to.to_s)
|
53
60
|
end
|
54
61
|
|
55
|
-
def copy_template_file
|
56
|
-
template("templates/#{from}",
|
62
|
+
def copy_template_file(from, to)
|
63
|
+
template("templates/#{from}", to.to_s)
|
57
64
|
end
|
58
65
|
|
59
66
|
def delete_target_file(to)
|
data/lib/coursegen/version.rb
CHANGED
data/spec/lectures_spec.rb
CHANGED
@@ -1,52 +1,62 @@
|
|
1
|
-
require_relative
|
2
|
-
describe Lectures do
|
3
|
-
before do
|
4
|
-
mocks1_templates =
|
5
|
-
[["/lectures/intro/wonders/index.html", "subsection", 0],
|
6
|
-
["/lectures/intro/wonders/page2.md.erb", "page", 1],
|
7
|
-
["/lectures/intro/wonders/page3.md.erb", "page", 2],
|
8
|
-
["/lectures/intro/wonder2/index.html", "subsection", 1],
|
9
|
-
["/lectures/intro/wonder2/page22.md.erb", "page", 1],
|
10
|
-
["/lectures/intro/wonder2/page32.md.erb/", "page",2 ]
|
11
|
-
]
|
12
|
-
@citems1 = mocks1_templates.map { |i, t, o| CItem.new(nil, i, t, o) }
|
13
|
-
@sect = Lectures.new "intro", @citems1
|
14
|
-
end
|
15
|
-
|
16
|
-
it "correctly counts subsections" do
|
17
|
-
expect(@sect.subsections.length).to eq 2
|
18
|
-
end
|
19
|
-
|
20
|
-
it "correctly handles next from page to page " do
|
21
|
-
expect(@sect.next_for(@citems1[1])).to eq @citems1[2]
|
22
|
-
end
|
23
|
-
|
24
|
-
it "correctly handles prev from page to page " do
|
25
|
-
expect(@sect.previous_for(@citems1[2])).to eq @citems1[1]
|
26
|
-
end
|
27
|
-
|
28
|
-
it "correctly handles prev from first page in section " do
|
29
|
-
expect(@sect.previous_for(@citems1[1])).to eq @citems1[1]
|
30
|
-
end
|
31
|
-
|
32
|
-
it "correctly handles next from last page in section " do
|
33
|
-
expect(@sect.next_for(@citems1[5])).to eq @citems1[5]
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
it "correctly handles next from subsection to subseciton" do
|
38
|
-
expect(@sect.next_for(@citems1[0])).to eq @citems1[3]
|
39
|
-
end
|
40
|
-
|
41
|
-
it "correctly handles next from last subsection" do
|
42
|
-
expect(@sect.next_for(@citems1[3])).to eq @citems1[3]
|
43
|
-
end
|
44
|
-
|
45
|
-
it { expect(@citems1[0].lecture_number).to eq 1 }
|
46
|
-
it { expect(@citems1[1].lecture_number).to eq 1 }
|
47
|
-
it { expect(@citems1[2].lecture_number).to eq 2 }
|
48
|
-
it { expect(@citems1[3].lecture_number).to eq 3 }
|
49
|
-
it { expect(@citems1[4].lecture_number).to eq 3 }
|
50
|
-
it { expect(@citems1[5].lecture_number).to eq 4 }
|
1
|
+
require_relative './spec_helper.rb'
|
51
2
|
|
3
|
+
describe Lectures do
|
4
|
+
before do
|
5
|
+
mocks1_templates =
|
6
|
+
[['/lectures/intro/wonders/index.html', 'subsection', 0],
|
7
|
+
['/lectures/intro/wonders/page2.md.erb', 'page', 1],
|
8
|
+
['/lectures/intro/wonders/page3.md.erb', 'page', 2],
|
9
|
+
['/lectures/intro/wonder2/index.html', 'subsection', 1],
|
10
|
+
['/lectures/intro/wonder2/page22.md.erb', 'page', 1],
|
11
|
+
['/lectures/intro/wonder2/page32.md.erb/', 'page', 2]]
|
12
|
+
@citems1 = mocks1_templates.map { |i, t, o| CItem.new(nil, i, t, o) }
|
13
|
+
@schd = Scheduler.new
|
14
|
+
@schd.setup_from_args(
|
15
|
+
start: 'jan-17-2017',
|
16
|
+
weekdays: %i[tuesday wednesday thursday],
|
17
|
+
start_times: %w[15:30 14:00 15:30],
|
18
|
+
end_times: %w[16:50 16:00 16:50],
|
19
|
+
number: 39,
|
20
|
+
start_time: '15:30',
|
21
|
+
end_time: '16:50',
|
22
|
+
skips: %w[feb-9-2017 feb-21-2017 feb-22-2017 feb-23-2017 apr-11-2017
|
23
|
+
apr-12-2017 apr-13-2017 apr-18-2017 apr-19-2017]
|
24
|
+
)
|
25
|
+
@sect = Lectures.new('intro', @citems1, @schd)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'correctly counts subsections' do
|
29
|
+
expect(@sect.subsections.length).to eq 2
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'correctly handles next from page to page' do
|
33
|
+
expect(@sect.next_for(@citems1[1])).to eq @citems1[2]
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'correctly handles prev from page to page' do
|
37
|
+
expect(@sect.previous_for(@citems1[2])).to eq @citems1[1]
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'correctly handles prev from first page in section' do
|
41
|
+
expect(@sect.previous_for(@citems1[1])).to eq @citems1[1]
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'correctly handles next from last page in section' do
|
45
|
+
expect(@sect.next_for(@citems1[5])).to eq @citems1[5]
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'correctly handles next from subsection to subsecton' do
|
49
|
+
expect(@sect.next_for(@citems1[0])).to eq @citems1[3]
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'correctly handles next from last subsection' do
|
53
|
+
expect(@sect.next_for(@citems1[3])).to eq @citems1[3]
|
54
|
+
end
|
55
|
+
|
56
|
+
it { expect(@citems1[0].lecture_number).to eq 1 }
|
57
|
+
it { expect(@citems1[1].lecture_number).to eq 1 }
|
58
|
+
it { expect(@citems1[2].lecture_number).to eq 2 }
|
59
|
+
it { expect(@citems1[3].lecture_number).to eq 3 }
|
60
|
+
it { expect(@citems1[4].lecture_number).to eq 3 }
|
61
|
+
it { expect(@citems1[5].lecture_number).to eq 4 }
|
52
62
|
end
|
data/spec/play_spec.rb
CHANGED
@@ -1,19 +1,31 @@
|
|
1
|
-
require_relative
|
2
|
-
|
1
|
+
require_relative './spec_helper.rb'
|
2
|
+
|
3
|
+
describe 'Does it work?' do
|
3
4
|
before do
|
4
|
-
@abc = 1
|
5
5
|
mocks1_templates =
|
6
|
-
[[
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
[['/lectures/intro/wonders/index.html', 'subsection', 0],
|
7
|
+
['/lectures/intro/wonders/page2.md.erb', 'page', 1],
|
8
|
+
['/lectures/intro/wonders/page3.md.erb', 'page', 2],
|
9
|
+
['/lectures/intro/wonder2/index.html', 'subsection', 1],
|
10
|
+
['/lectures/intro/wonder2/page22.md.erb', 'page', 1],
|
11
|
+
['/lectures/intro/wonder2/page32.md.erb', 'page', 2]]
|
12
12
|
@citems1 = mocks1_templates.map { |i, t, o| CItem.new(nil, i, t, o) }
|
13
|
-
@
|
13
|
+
@schd = Scheduler.new
|
14
|
+
@schd.setup_from_args(
|
15
|
+
start: 'jan-17-2017',
|
16
|
+
weekdays: %i[tuesday wednesday thursday],
|
17
|
+
start_times: %w[15:30 14:00 15:30],
|
18
|
+
end_times: %w[16:50 16:00 16:50],
|
19
|
+
number: 39,
|
20
|
+
start_time: '15:30',
|
21
|
+
end_time: '16:50',
|
22
|
+
skips: %w[feb-9-2017 feb-21-2017 feb-22-2017 feb-23-2017 apr-11-2017
|
23
|
+
apr-12-2017 apr-13-2017 apr-18-2017 apr-19-2017]
|
24
|
+
)
|
25
|
+
@sect = Lectures.new('intro', @citems1, @schd)
|
14
26
|
end
|
15
27
|
|
16
|
-
it
|
17
|
-
expect
|
28
|
+
it 'correctly counts subsections' do
|
29
|
+
expect(@sect).to be_truthy
|
18
30
|
end
|
19
31
|
end
|
data/spec/scheduler_spec.rb
CHANGED
@@ -1,75 +1,135 @@
|
|
1
1
|
require 'active_support/core_ext/date/conversions'
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative './spec_helper.rb'
|
4
4
|
|
5
5
|
def s2d(string_date)
|
6
|
-
Date.strptime(string_date,
|
6
|
+
Date.strptime(string_date, '%b-%d-%Y')
|
7
7
|
end
|
8
8
|
|
9
9
|
describe Scheduler do
|
10
|
-
let(:sched) {Scheduler.new}
|
11
|
-
let(:target_date) {
|
10
|
+
let(:sched) { Scheduler.new }
|
11
|
+
let(:target_date) { 'nov-25-2013' }
|
12
12
|
let(:target_date_bin) { s2d(target_date) }
|
13
13
|
|
14
|
-
describe
|
15
|
-
it
|
16
|
-
sched.setup_from_args(
|
14
|
+
describe 'Single day scheduler' do
|
15
|
+
it 'knows date for first event' do
|
16
|
+
sched.setup_from_args(
|
17
|
+
start: target_date,
|
18
|
+
weekdays: [:monday],
|
19
|
+
number: 1,
|
20
|
+
start_time: '10:00',
|
21
|
+
end_time: '11:00'
|
22
|
+
)
|
17
23
|
a_date = sched.event_date_by_index 0
|
18
24
|
expect(a_date).to eq target_date_bin
|
19
25
|
end
|
20
26
|
|
21
|
-
it
|
22
|
-
sched.setup_from_args(
|
27
|
+
it 'knows date for second event' do
|
28
|
+
sched.setup_from_args(
|
29
|
+
start: target_date,
|
30
|
+
weekdays: [:monday],
|
31
|
+
number: 2,
|
32
|
+
start_time: '10:00',
|
33
|
+
end_time: '11:00'
|
34
|
+
)
|
23
35
|
a_date = sched.event_date_by_index 1
|
24
36
|
expect(a_date).to eq target_date_bin + 7
|
25
37
|
end
|
26
38
|
end
|
27
39
|
|
28
|
-
describe
|
29
|
-
it
|
30
|
-
sched.setup_from_args(
|
40
|
+
describe 'Double day scheduler' do
|
41
|
+
it 'knows date for first event' do
|
42
|
+
sched.setup_from_args(
|
43
|
+
start: target_date,
|
44
|
+
weekdays: %i[monday tuesday],
|
45
|
+
number: 1,
|
46
|
+
start_time: '10:00',
|
47
|
+
end_time: '11:00'
|
48
|
+
)
|
31
49
|
a_date = sched.event_date_by_index 0
|
32
50
|
expect(a_date).to eq target_date_bin
|
33
51
|
end
|
34
52
|
|
35
|
-
it
|
36
|
-
sched.setup_from_args(
|
53
|
+
it 'knows date for second event' do
|
54
|
+
sched.setup_from_args(
|
55
|
+
start: target_date,
|
56
|
+
weekdays: %i[monday tuesday],
|
57
|
+
number: 2,
|
58
|
+
start_time: '10:00',
|
59
|
+
end_time: '11:00'
|
60
|
+
)
|
37
61
|
a_date = sched.event_date_by_index 1
|
38
62
|
expect(a_date).to eq target_date_bin + 1
|
39
63
|
end
|
40
64
|
|
41
|
-
it
|
42
|
-
sched.setup_from_args(
|
65
|
+
it 'knows date for third event' do
|
66
|
+
sched.setup_from_args(
|
67
|
+
start: target_date,
|
68
|
+
weekdays: %i[monday tuesday],
|
69
|
+
number: 3,
|
70
|
+
start_time: '10:00',
|
71
|
+
end_time: '11:00'
|
72
|
+
)
|
43
73
|
a_date = sched.event_date_by_index 2
|
44
74
|
expect(a_date).to eq target_date_bin + 7
|
45
75
|
end
|
46
76
|
|
47
|
-
it
|
48
|
-
sched.setup_from_args(
|
77
|
+
it 'knows date for fourth event' do
|
78
|
+
sched.setup_from_args(
|
79
|
+
start: target_date,
|
80
|
+
weekdays: %i[monday tuesday],
|
81
|
+
number: 4,
|
82
|
+
start_time: '10:00',
|
83
|
+
end_time: '11:00'
|
84
|
+
)
|
49
85
|
a_date = sched.event_date_by_index 3
|
50
86
|
expect(a_date).to eq target_date_bin + 7 + 1
|
51
87
|
end
|
52
88
|
end
|
53
89
|
|
54
|
-
describe
|
55
|
-
it
|
56
|
-
sched.setup_from_args(
|
90
|
+
describe 'Triple day scheduler' do
|
91
|
+
it 'knows date for first event' do
|
92
|
+
sched.setup_from_args(
|
93
|
+
start: target_date,
|
94
|
+
weekdays: %i[monday wednesday friday],
|
95
|
+
number: 1,
|
96
|
+
start_time: '10:00',
|
97
|
+
end_time: '11:00'
|
98
|
+
)
|
57
99
|
a_date = sched.event_date_by_index 0
|
58
100
|
expect(a_date).to eq target_date_bin
|
59
101
|
end
|
60
|
-
it
|
61
|
-
sched.setup_from_args(
|
102
|
+
it 'knows date for second event' do
|
103
|
+
sched.setup_from_args(
|
104
|
+
start: target_date,
|
105
|
+
weekdays: %i[monday wednesday friday],
|
106
|
+
number: 2,
|
107
|
+
start_time: '10:00',
|
108
|
+
end_time: '11:00'
|
109
|
+
)
|
62
110
|
a_date = sched.event_date_by_index 1
|
63
111
|
expect(a_date).to eq target_date_bin + 2
|
64
112
|
end
|
65
113
|
|
66
|
-
it
|
67
|
-
sched.setup_from_args(
|
114
|
+
it 'knows date for third event' do
|
115
|
+
sched.setup_from_args(
|
116
|
+
start: target_date,
|
117
|
+
weekdays: %i[monday wednesday friday],
|
118
|
+
number: 3,
|
119
|
+
start_time: '10:00',
|
120
|
+
end_time: '11:00'
|
121
|
+
)
|
68
122
|
a_date = sched.event_date_by_index 2
|
69
123
|
expect(a_date).to eq target_date_bin + 4
|
70
124
|
end
|
71
|
-
it
|
72
|
-
sched.setup_from_args(
|
125
|
+
it 'knows date for fourth event' do
|
126
|
+
sched.setup_from_args(
|
127
|
+
start: target_date,
|
128
|
+
weekdays: %i[monday wednesday friday],
|
129
|
+
number: 4,
|
130
|
+
start_time: '10:00',
|
131
|
+
end_time: '11:00'
|
132
|
+
)
|
73
133
|
a_date = sched.event_date_by_index 3
|
74
134
|
expect(a_date).to eq target_date_bin + 7
|
75
135
|
end
|