rhs-schedule 0.9.0 → 0.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 826ff7f66f9e86f1b983d7343e0eff0db2dc5341
4
- data.tar.gz: 9e21305d673aa17a0bcd1632a400a26eec715f67
3
+ metadata.gz: d5e5dc3ab261d9eda4a491a1cfa7c0ff7bfb40c8
4
+ data.tar.gz: aa10305acded326e8f4ad71d872394049cc46a55
5
5
  SHA512:
6
- metadata.gz: e9cff6a2c9a3ce62ab910e309395c4145d7fb616075762b3667050ff9d6fcff2957057bb68f120d47c9d9aa6093a8e176f49ba4e0a5ffd027a80d7e7c4d5d042
7
- data.tar.gz: 948799766f39e24342fcce95de19e263767a7e3639dc0dd125c9d5a68376efa8070b714c8ebaa4ba98b8722e940823981acffd59f9a330dd89d1fd48cc7e49ab
6
+ metadata.gz: 315c5a0917f8c609457bcdafe5ad4c2fdaf0caecf9ab0360bf11cc99c31ead5c920e14d9f7bc9d23dc39cbf4c52fd2c354392da1555ec6a51082d8f5e0e9da96
7
+ data.tar.gz: 418e9e4d5b7baf1decc7efa4ec9accc8d9d18fde184fa990b3794545739d4b2bad08cd5c9c88b01a19bd8a01b698cc51bc74882c838e142d4e1652ed88004546
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # rhs-schedule
2
+ ### v0.9.0
2
3
  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
 
4
5
  ## How to Use
@@ -10,6 +11,14 @@ require 'rhs-schedule'
10
11
  schedule = ScheduleSystem.new 'path/to/schedule.txt'
11
12
 
12
13
  # Check out the wiki to see how to use it!
14
+
15
+ # Examples:
13
16
  puts schedule.today
17
+
18
+ schedule.get_class_day('09/26/16').periods.each do |p|
19
+ puts p.duration
20
+ end
21
+
22
+ schedule.export_schedule_days('schedule_days.tsv')
14
23
  ```
15
24
  **Documentation is available at [http://www.rubydoc.info/github/Apexal/rhs-schedule/master/](http://www.rubydoc.info/github/Apexal/rhs-schedule/master/)**
@@ -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.0'.freeze
9
+ VERSION = '0.9.1'.freeze
10
10
 
11
11
  # e.g. 05/25/16
12
12
  DATE_FORMAT = '%m/%d/%y'.freeze
@@ -226,6 +226,6 @@ class ScheduleSystem
226
226
 
227
227
  # PM Advisement isn't in schedule text file
228
228
  filled << Period.new('Afternoon Advisement', DateTime.strptime('2:50 PM', TIME_FORMAT), DateTime.strptime('3:00 PM', TIME_FORMAT), 'Advisement')
229
- day.periods = filled
229
+ day.set_periods(filled)
230
230
  end
231
231
  end
@@ -0,0 +1,9 @@
1
+ module Commands
2
+ def initialize(schedule)
3
+ @schedule = schedule
4
+ end
5
+
6
+ def command_help(args)
7
+ puts "Help!"
8
+ end
9
+ end
@@ -2,4 +2,10 @@ class InvalidScheduleError < StandardError
2
2
  def initialize(msg='Invalid schedule text file!')
3
3
  super
4
4
  end
5
+ end
6
+
7
+ class InvalidPeriodList < StandardError
8
+ def initialize(msg='Invalid period list!')
9
+ super
10
+ end
5
11
  end
@@ -3,7 +3,6 @@ class ScheduleDay
3
3
  # @return [String] the letter
4
4
  attr_reader :schedule_day
5
5
 
6
- attr_writer :periods
7
6
  # Gets all of the periods in this schedule day.
8
7
  attr_reader :periods
9
8
 
@@ -11,7 +10,30 @@ class ScheduleDay
11
10
  @schedule_day = sd
12
11
  @periods = periods
13
12
  end
14
-
13
+
14
+ # Sets the period list as given, after checking to make sure there are no holes in the schedule. If there are it returns false and does not
15
+ # set the schedule.
16
+ #
17
+ # @param new_periods [Array<Period>] the new period list
18
+ # @return [nil]
19
+ def set_periods(new_periods)
20
+ # Check start and end
21
+ raise InvalidPeriodList, 'First and/or last periods are missing!' unless new_periods.first.start_time.strftime(TIME_FORMAT) == '08:40 AM' and new_periods.last.end_time.strftime(TIME_FORMAT) == '03:00 PM'
22
+
23
+ # Check for gaps
24
+ prev_time = '08:40 AM'
25
+ new_periods.each do |p|
26
+ if p.start_time.strftime(TIME_FORMAT) == prev_time
27
+ prev_time = p.end_time.strftime(TIME_FORMAT)
28
+ next
29
+ end
30
+ raise InvalidPeriodList, "There is a gap in the period list at #{p.start_time.strftime(TIME_FORMAT)}"
31
+ end
32
+
33
+ # No gaps, go ahead
34
+ @periods = new_periods
35
+ end
36
+
15
37
  # Returns short summary of schedule day, including letter, number of periods, and then a list of the periods.
16
38
  def to_s
17
39
  to_return = ["#{@schedule_day}-Day: #{@periods.length} periods"]
@@ -22,7 +44,7 @@ class ScheduleDay
22
44
 
23
45
  to_return.join("\n")
24
46
  end
25
-
47
+
26
48
  private
27
49
  def add_period(period)
28
50
  @periods << period
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhs-schedule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Matranga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-03 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A RubyGem that parses Regis High School's Intranet schedule download.
14
14
  email: thefrankmatranga@gmail.com
@@ -19,6 +19,7 @@ files:
19
19
  - LICENSE
20
20
  - README.md
21
21
  - lib/rhs-schedule.rb
22
+ - lib/rhs-schedule/commands.rb
22
23
  - lib/rhs-schedule/errors.rb
23
24
  - lib/rhs-schedule/exports.rb
24
25
  - lib/rhs-schedule/period.rb