rhs-schedule 0.6.0 → 0.7.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/LICENSE +21 -0
- data/README.md +15 -0
- data/lib/rhs-schedule.rb +15 -5
- data/lib/rhs-schedule/exports.rb +1 -2
- data/lib/rhs-schedule/period.rb +15 -1
- data/lib/rhs-schedule/scheduleday.rb +3 -1
- 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: 172e5a7deee9a6fbcc7a87c64a5af9d14b2fa4f0
|
4
|
+
data.tar.gz: 0f33998edeed880f68b33d48d91f04f4bd38dc5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a0d21f8253a8608904f8fa215296d16360673e45cb7608cd6ad98b4b7c4e517e47a362f6fbf0e605a8f5bbc05c664b22c5f7f24bb95f4c135c4a5c4b0bb6b77
|
7
|
+
data.tar.gz: 55de0b13178b3b7df12acf93b038af95cb4f3ae8269317c2d36a6be9b07c62830da9e5337f5098650b6246a27933c758e6b6a67add0137e3cc619066910de9ba
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Frank Matranga
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# rhs-schedule
|
2
|
+
A RubyGem that can parse the Regis Intranet schedule download so that it can be used in programs (such as displaying it correctly).
|
3
|
+
|
4
|
+
## How to Use
|
5
|
+
```ruby
|
6
|
+
require 'rhs-schedule'
|
7
|
+
|
8
|
+
# Initialize the schedule system by passing a path to the schedule text download from the Intranet
|
9
|
+
# (found at http://intranet.regis.org/downloads/outlook_calendar_import/outlook_schedule_download.cfm)
|
10
|
+
schedule = ScheduleSystem.new 'path/to/schedule.txt'
|
11
|
+
|
12
|
+
# Check out the wiki to see how to use it!
|
13
|
+
puts schedule.today
|
14
|
+
```
|
15
|
+
**Documentation is available at [http://www.rubydoc.info/github/Apexal/rhs-schedule/master/](http://www.rubydoc.info/github/Apexal/rhs-schedule/master/)**
|
data/lib/rhs-schedule.rb
CHANGED
@@ -6,22 +6,33 @@ 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.7.0'.freeze
|
10
10
|
|
11
|
-
# 05/25/16
|
11
|
+
# e.g. 05/25/16
|
12
12
|
DATE_FORMAT = '%m/%d/%y'.freeze
|
13
|
+
|
14
|
+
# e.g. '08:50 AM'
|
13
15
|
TIME_FORMAT = '%I:%M %p'.freeze
|
16
|
+
|
17
|
+
# e.g. '05/25/16 08:50 AM'
|
14
18
|
DATETIME_FORMAT = "#{DATE_FORMAT} #{TIME_FORMAT}".freeze
|
19
|
+
|
20
|
+
# The list of values found in a valid schedule download that should be ignored
|
15
21
|
EXCEPTIONS = ['0', '1', '2', '3', 'WEBEIM Scheduled', 'SIS Scheduled'].freeze
|
16
22
|
|
17
23
|
class ScheduleSystem
|
18
24
|
include Exports
|
19
25
|
|
26
|
+
# Returns an hash mapping all school days' dates to their schedule day letter
|
27
|
+
# @return [Hash] the date to string hash
|
20
28
|
attr_reader :schedule_days
|
29
|
+
|
30
|
+
# Return a hash mapping schedule day letters to their corresponding ScheduleDay objects
|
31
|
+
# @return [Hash] the string to ScheduleDay hash
|
21
32
|
attr_reader :class_days
|
22
33
|
|
23
34
|
# Creates a new ScheduleSystem by parsing the schedule text file passed to it.
|
24
|
-
# If it cannot read the file the program aborts.
|
35
|
+
# If it cannot read the file or it detects that the format of the file is invalid the program aborts.
|
25
36
|
#
|
26
37
|
# @param path [String] the path to the text file (not the folder!)
|
27
38
|
def initialize(path)
|
@@ -81,7 +92,6 @@ class ScheduleSystem
|
|
81
92
|
lines.each { |l| actual += l.split("\t").length }
|
82
93
|
raise InvalidScheduleError, 'Not all lines are valid.' unless expected == actual
|
83
94
|
#raise InvalidScheduleError, 'Missing schedule day lines' unless lines
|
84
|
-
|
85
95
|
end
|
86
96
|
|
87
97
|
# Reads the schedule text file and parses each line to decide periods and schedule days.
|
@@ -120,7 +130,7 @@ class ScheduleSystem
|
|
120
130
|
handled = [] # Holds what schedules have been made
|
121
131
|
@schedule_days.each do |date, sd|
|
122
132
|
next if handled.include? sd
|
123
|
-
lines = ps.find_all { |values| values[0]
|
133
|
+
lines = ps.find_all { |values| values[0] == date.strftime(DATE_FORMAT) }
|
124
134
|
|
125
135
|
next if lines.empty?
|
126
136
|
create_class_day sd, lines
|
data/lib/rhs-schedule/exports.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
module Exports
|
2
2
|
def initialize(schedule)
|
3
3
|
@schedule = schedule
|
4
|
-
puts 'Loaded exports'
|
5
4
|
end
|
6
5
|
|
7
|
-
# Outputs the current schedule in JSON format to the path specified.
|
6
|
+
# Outputs the current schedule in JSON format to the path specified. (NOT YET IMPLEMENTED)
|
8
7
|
def to_json(path, include_advisements=false, include_frees=false)
|
9
8
|
puts "Not yet implemented."
|
10
9
|
end
|
data/lib/rhs-schedule/period.rb
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
class Period
|
2
|
+
# The time (only) of day that the period starts at.
|
3
|
+
# ex. '10:30 AM' or '02:40 PM'
|
4
|
+
# @return [String] the time
|
2
5
|
attr_reader :start_time
|
6
|
+
|
7
|
+
# The time (only) of day that the period ends at.
|
8
|
+
# ex. '10:30 AM' or '02:40 PM'
|
9
|
+
# @return [String] the time
|
3
10
|
attr_reader :end_time
|
11
|
+
|
12
|
+
# The title of the course or event of the period.
|
13
|
+
# @return [String] the title
|
4
14
|
attr_reader :course_title
|
15
|
+
|
16
|
+
# The location of the period without any preceding text.
|
17
|
+
# e.g. '312' not 'Room 312'
|
18
|
+
# @return [String] the location
|
5
19
|
attr_reader :location
|
6
20
|
|
7
21
|
def initialize(course, start_time, end_time, location)
|
@@ -16,7 +30,7 @@ class Period
|
|
16
30
|
"#{@course_title} in #{@location} for #{duration} minutes (#{start_time} to #{end_time})"
|
17
31
|
end
|
18
32
|
|
19
|
-
# Returns the duration of the period in minutes
|
33
|
+
# Returns the duration of the period in minutes of the period
|
20
34
|
# @return [Integer] duration in minutes
|
21
35
|
def duration
|
22
36
|
((@end_time - @start_time) * 24 * 60).to_i
|
@@ -1,4 +1,6 @@
|
|
1
1
|
class ScheduleDay
|
2
|
+
# Returns the letter of the schedule day for the ScheduleDay object.
|
3
|
+
# @return [String] the letter
|
2
4
|
attr_reader :schedule_day
|
3
5
|
|
4
6
|
attr_writer :periods
|
@@ -13,7 +15,7 @@ class ScheduleDay
|
|
13
15
|
def to_s
|
14
16
|
to_return = ["#{@schedule_day}-Day: #{@periods.length} periods"]
|
15
17
|
@periods.each do |p|
|
16
|
-
to_return << " -#{p.to_s}"
|
18
|
+
to_return << " -#{p.to_s}\n"
|
17
19
|
end
|
18
20
|
to_return << "\n"
|
19
21
|
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Matranga
|
@@ -16,6 +16,8 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
19
21
|
- lib/rhs-schedule.rb
|
20
22
|
- lib/rhs-schedule/errors.rb
|
21
23
|
- lib/rhs-schedule/exports.rb
|