rhs-schedule 0.5.0 → 0.6.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 +3 -1
- data/lib/rhs-schedule/errors.rb +5 -0
- data/lib/rhs-schedule/exports.rb +99 -0
- data/lib/rhs-schedule/period.rb +2 -1
- data/lib/rhs-schedule/scheduleday.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a959475b900db7b022ed04b8adc7c09d874447e1
|
4
|
+
data.tar.gz: a0c4ed47196e541f1762972e85e37947503b36ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07ce4d16728bed927fd79e0987bd2c71ea85bb62e8e37cf5f54494a39c6372447ad80685f6a6e64e5e1deb6bf4324871b0fedffdccf3b2dbe0154b888832d17b
|
7
|
+
data.tar.gz: 8e0ee15009598ccca9ec472a28f5875154d9d1ef758281d3f3e486c8478de62cfb1d823cec03749a64ed9f0cce2d0f6d51e8c1c6a9caf88d88373275f0f823d6
|
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.6.0'.freeze
|
10
10
|
|
11
11
|
# 05/25/16 08:50 AM
|
12
12
|
DATE_FORMAT = '%m/%d/%y'.freeze
|
@@ -49,6 +49,8 @@ class ScheduleSystem
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# Displays formatted info on the current day, including it's schedule day and classes in order.
|
52
|
+
#
|
53
|
+
# @return [ScheduleDay] The ScheduleDay object.
|
52
54
|
def today
|
53
55
|
#false_date = Date.strptime('05/20/16', DATE_FORMAT)
|
54
56
|
@class_days[@schedule_days[Date.parse(Time.now.to_s)]]
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Exports
|
2
|
+
def initialize(schedule)
|
3
|
+
@schedule = schedule
|
4
|
+
puts 'Loaded exports'
|
5
|
+
end
|
6
|
+
|
7
|
+
# Outputs the current schedule in JSON format to the path specified.
|
8
|
+
def to_json(path, include_advisements=false, include_frees=false)
|
9
|
+
puts "Not yet implemented."
|
10
|
+
end
|
11
|
+
|
12
|
+
# Exports the current schedule in CSV format (according to Google Calendar) to the path specified.
|
13
|
+
# https://support.google.com/calendar/answer/37118?hl=en
|
14
|
+
#
|
15
|
+
# @param path [String] the path to export to (not directory!)
|
16
|
+
# @param include_advisements [Boolean] whether or not to include AM/PM advisements in the export
|
17
|
+
# @param include_frees [Boolean] whether or not to include free periods in the export
|
18
|
+
def to_csv(path, include_advisements=false, include_frees=false)
|
19
|
+
# https://support.google.com/calendar/answer/37118?hl=en
|
20
|
+
# The format of the file is as follows:
|
21
|
+
# Headers
|
22
|
+
# 1 line per period in the school year
|
23
|
+
# 1 line per schedule day in the school year
|
24
|
+
|
25
|
+
headers = ['Subject', 'Start Date', 'Start Time', 'End Date', 'End Time', 'Location', 'All Day Event']
|
26
|
+
|
27
|
+
csv_file = File.open(path, 'w')
|
28
|
+
csv_file.puts(headers.join(","))
|
29
|
+
|
30
|
+
# 1 line per period in year
|
31
|
+
@schedule.schedule_days.each do |date, sd|
|
32
|
+
date_str = date.strftime(DATE_FORMAT)
|
33
|
+
periods = @schedule.class_days[sd].periods
|
34
|
+
periods = periods.select { |p| p.course_title != 'Unstructured Time' } unless include_frees
|
35
|
+
periods = periods.select { |p| p.course_title != 'Morning Advisement' and p.course_title != 'Afternoon Advisement' } unless include_advisements
|
36
|
+
|
37
|
+
periods.each do |p|
|
38
|
+
values = [p.course_title, date_str, p.start_time.strftime(TIME_FORMAT), date_str, p.end_time.strftime(TIME_FORMAT), p.location, 'False']
|
39
|
+
csv_file.puts(values.join(","))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
@schedule.schedule_days.each do |date, sd|
|
44
|
+
# 05/26/17 05/26/17 A Day 1 0 3 SIS Scheduled
|
45
|
+
date_str = date.strftime(DATE_FORMAT)
|
46
|
+
values = ["#{sd} Day", date_str, '', date_str, '', '', 'True']
|
47
|
+
csv_file.puts(values.join(","))
|
48
|
+
end
|
49
|
+
|
50
|
+
csv_file.close
|
51
|
+
|
52
|
+
puts "CSV schedule file exported to '#{path}'"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Exports the current schedule in CSV format (according to MS Outlook) to the path specified.
|
56
|
+
# The format is the exact same as the initally downloaded schedule file.
|
57
|
+
#
|
58
|
+
# @param path [String] the path to export to (not directory!)
|
59
|
+
# @param include_advisements [Boolean] whether or not to include AM/PM advisements in the export
|
60
|
+
# @param include_frees [Boolean] whether or not to include free periods in the export
|
61
|
+
def to_tsv(path, include_advisements=false, include_frees=false)
|
62
|
+
# The format of the file is as follows:
|
63
|
+
# Headers
|
64
|
+
# 1 line per period in the school year
|
65
|
+
# 1 line per schedule day in the school year
|
66
|
+
|
67
|
+
headers = ['Start Date', 'Start Time', 'End Date', 'End Time', 'Subject', 'Location', 'All day event', 'Reminder on/off', 'Show time as', 'Categories']
|
68
|
+
|
69
|
+
tsv_file = File.open(path, 'w')
|
70
|
+
tsv_file.puts(headers.join("\t"))
|
71
|
+
|
72
|
+
# 1 line per period in year
|
73
|
+
@schedule.schedule_days.each do |date, sd|
|
74
|
+
date_str = date.strftime(DATE_FORMAT)
|
75
|
+
periods = @schedule.class_days[sd].periods
|
76
|
+
periods = periods.select { |p| p.course_title != 'Unstructured Time' } unless include_frees
|
77
|
+
periods = periods.select { |p| p.course_title != 'Morning Advisement' and p.course_title != 'Afternoon Advisement' } unless include_advisements
|
78
|
+
|
79
|
+
periods.each do |p|
|
80
|
+
# Example line format:
|
81
|
+
# 09/12/16 09:50 AM 09/12/16 10:50 AM Fine Arts 11 Art Practicum (1A) Prezioso 416 0 0 2 SIS Scheduled
|
82
|
+
|
83
|
+
values = [date_str, p.start_time.strftime(TIME_FORMAT), date_str, p.end_time.strftime(TIME_FORMAT), p.course_title, p.location, 0, 0, 2, 'SIS Scheduled']
|
84
|
+
tsv_file.puts(values.join("\t"))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
@schedule.schedule_days.each do |date, sd|
|
89
|
+
# 05/26/17 05/26/17 A Day 1 0 3 SIS Scheduled
|
90
|
+
date_str = date.strftime(DATE_FORMAT)
|
91
|
+
values = [date_str, '', date_str, '', "#{sd} Day", '', 1, 0, 3, 'SIS Scheduled']
|
92
|
+
tsv_file.puts(values.join("\t"))
|
93
|
+
end
|
94
|
+
|
95
|
+
tsv_file.close
|
96
|
+
|
97
|
+
puts "TSV schedule file exported to '#{path}'"
|
98
|
+
end
|
99
|
+
end
|
data/lib/rhs-schedule/period.rb
CHANGED
@@ -11,8 +11,9 @@ class Period
|
|
11
11
|
@location = location
|
12
12
|
end
|
13
13
|
|
14
|
+
# Returns a short summary of the period including subject, location, and duration with times
|
14
15
|
def to_s
|
15
|
-
"#{@course_title} in #{@location} for #{duration} minutes"
|
16
|
+
"#{@course_title} in #{@location} for #{duration} minutes (#{start_time} to #{end_time})"
|
16
17
|
end
|
17
18
|
|
18
19
|
# Returns the duration of the period in minutes
|
@@ -9,6 +9,7 @@ class ScheduleDay
|
|
9
9
|
@periods = periods
|
10
10
|
end
|
11
11
|
|
12
|
+
# Returns short summary of schedule day, including letter, number of periods, and then a list of the periods.
|
12
13
|
def to_s
|
13
14
|
to_return = ["#{@schedule_day}-Day: #{@periods.length} periods"]
|
14
15
|
@periods.each do |p|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhs-schedule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Matranga
|
@@ -17,6 +17,8 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/rhs-schedule.rb
|
20
|
+
- lib/rhs-schedule/errors.rb
|
21
|
+
- lib/rhs-schedule/exports.rb
|
20
22
|
- lib/rhs-schedule/period.rb
|
21
23
|
- lib/rhs-schedule/scheduleday.rb
|
22
24
|
homepage:
|