rhs-schedule 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rhs-schedule.rb +9 -9
- data/lib/rhs-schedule/period.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d78ca9524a73504524f2f92521fa48d1e90db7f9
|
4
|
+
data.tar.gz: 373349b5453a766fedff74cf46cfd97390c26231
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a0dcb14e0d91cff691032cc93b62600b26ced05271d9669db658a570949694fd6f1478c6349940bf9a195850adf6e8f1c1fdfd0bd2955ad22999ede2e8e511c
|
7
|
+
data.tar.gz: c927c5441c7e426bf98061aed9f9f276efc7a94b7ce7c8d747f498560e414e25d07cff162162237a983e1fa66239f8955d821515764fec7398ff5b4d5c297fae
|
data/lib/rhs-schedule.rb
CHANGED
@@ -6,7 +6,7 @@ require_relative 'rhs-schedule/period'
|
|
6
6
|
require_relative 'rhs-schedule/exports'
|
7
7
|
require_relative 'rhs-schedule/errors'
|
8
8
|
|
9
|
-
VERSION = '0.
|
9
|
+
VERSION = '0.5.0'.freeze
|
10
10
|
|
11
11
|
# 05/25/16 08:50 AM
|
12
12
|
DATE_FORMAT = '%m/%d/%y'.freeze
|
@@ -18,6 +18,7 @@ class ScheduleSystem
|
|
18
18
|
include Exports
|
19
19
|
|
20
20
|
attr_reader :schedule_days
|
21
|
+
attr_reader :class_days
|
21
22
|
|
22
23
|
# Creates a new ScheduleSystem by parsing the schedule text file passed to it.
|
23
24
|
# If it cannot read the file the program aborts.
|
@@ -28,7 +29,7 @@ class ScheduleSystem
|
|
28
29
|
abort "Cannot find schedule text file at '#{path}'. Please download it from http://intranet.regis.org/downloads/outlook_calendar_import/outlook_schedule_download.cfm." unless File.file? path
|
29
30
|
|
30
31
|
@path = path
|
31
|
-
@
|
32
|
+
@class_days = {}
|
32
33
|
@schedule_days = {}
|
33
34
|
parse
|
34
35
|
super(self) # Initialize the exports with the parsed schedule
|
@@ -50,8 +51,7 @@ class ScheduleSystem
|
|
50
51
|
# Displays formatted info on the current day, including it's schedule day and classes in order.
|
51
52
|
def today
|
52
53
|
#false_date = Date.strptime('05/20/16', DATE_FORMAT)
|
53
|
-
@
|
54
|
-
#@classdays.find { |cd| cd.schedule_day == @schedule_days[false_date] }
|
54
|
+
@class_days[@schedule_days[Date.parse(Time.now.to_s)]]
|
55
55
|
end
|
56
56
|
|
57
57
|
# Outputs a JSON object of all class days and their schedule days into the given file.
|
@@ -94,7 +94,6 @@ class ScheduleSystem
|
|
94
94
|
|
95
95
|
lines.each do |line|
|
96
96
|
next if line.include? 'Start Date' or line.strip.empty?
|
97
|
-
|
98
97
|
# Split the line and remove all the unnecessary values
|
99
98
|
values = line.split("\t")
|
100
99
|
|
@@ -109,6 +108,8 @@ class ScheduleSystem
|
|
109
108
|
ps << vital
|
110
109
|
end
|
111
110
|
end
|
111
|
+
|
112
|
+
puts ps.count { |values| values.any? { |v| v.include? 'Practicum' } }
|
112
113
|
end
|
113
114
|
|
114
115
|
puts "Found #{ps.length} periods for #{sds.length} class days"
|
@@ -117,8 +118,8 @@ class ScheduleSystem
|
|
117
118
|
handled = [] # Holds what schedules have been made
|
118
119
|
@schedule_days.each do |date, sd|
|
119
120
|
next if handled.include? sd
|
121
|
+
lines = ps.find_all { |values| values[0].gsub(/\n/, "") == date.strftime(DATE_FORMAT) }
|
120
122
|
|
121
|
-
lines = ps.find_all { |values| values[0] == date.strftime(DATE_FORMAT) }
|
122
123
|
next if lines.empty?
|
123
124
|
create_class_day sd, lines
|
124
125
|
handled << sd
|
@@ -132,6 +133,7 @@ class ScheduleSystem
|
|
132
133
|
end
|
133
134
|
|
134
135
|
def create_class_day sd, lines
|
136
|
+
|
135
137
|
periods = []
|
136
138
|
lines.each do |values|
|
137
139
|
# [date, start time, end time, class name, location]
|
@@ -145,7 +147,7 @@ class ScheduleSystem
|
|
145
147
|
|
146
148
|
day = ScheduleDay.new(sd, periods)
|
147
149
|
fill_periods day
|
148
|
-
@
|
150
|
+
@class_days[sd] = day
|
149
151
|
end
|
150
152
|
|
151
153
|
# Take a just created periods list and fill in the holes (lunch and frees)
|
@@ -172,6 +174,4 @@ class ScheduleSystem
|
|
172
174
|
filled << Period.new('Afternoon Advisement', DateTime.strptime('2:50 PM', TIME_FORMAT), DateTime.strptime('3:00 PM', TIME_FORMAT), 'Advisement')
|
173
175
|
day.periods = filled
|
174
176
|
end
|
175
|
-
|
176
|
-
|
177
177
|
end
|
data/lib/rhs-schedule/period.rb
CHANGED