osu-cc-scraper 3.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/osu-cc-scraper/course.rb +14 -3
- data/lib/osu-cc-scraper/department.rb +12 -3
- data/lib/osu-cc-scraper/section.rb +3 -7
- data/lib/osu-cc-scraper/university.rb +2 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a7c8e0f916fd670730f4f80e45f2742512420df
|
4
|
+
data.tar.gz: e7d63ba37d98faf404e5c72ac14c100908b7b060
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f3e0c2432c9adb001fea9c19733fd0b07b29aad6c75baf858f05170a6449c6b7f627352bc23844df1029a13173693ec951f3f2c72c7eb0a2f6a18baf6cc1e16
|
7
|
+
data.tar.gz: 2d27785cd4bf5e2f9893f44cf00dd1c77747bf2992f348990b8de6de592539f664ec3f4222445176897c87c6691dde944c7b3cdd1a95842cad9232ec9ec105ac
|
@@ -1,22 +1,31 @@
|
|
1
1
|
require "open-uri"
|
2
2
|
require "oga"
|
3
3
|
require "osu-cc-scraper/section"
|
4
|
+
require "json"
|
4
5
|
|
5
6
|
module OsuCcScraper
|
6
|
-
class Course < Struct.new(:
|
7
|
+
class Course < Struct.new(:subject_code, :course_number, :name)
|
7
8
|
|
8
9
|
def sections
|
9
10
|
html = fetch_sections
|
10
11
|
parse_sections(html)
|
11
12
|
end
|
12
13
|
|
14
|
+
def to_json
|
15
|
+
self.to_h.to_json
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.from_json(json)
|
19
|
+
Course.new(*JSON.parse(json).values)
|
20
|
+
end
|
21
|
+
|
13
22
|
private
|
14
23
|
|
15
24
|
SECTIONS_XPATH = "//table[@id='ctl00_ContentPlaceHolder1_SOCListUC1_gvOfferings']//tr[position() > 1]"
|
16
25
|
TITLE_XPATH = "//form/h3"
|
17
26
|
|
18
27
|
def fetch_sections
|
19
|
-
open("#{ENDPOINT}/CourseDetail.aspx?subjectcode=#{
|
28
|
+
open("#{ENDPOINT}/CourseDetail.aspx?subjectcode=#{subject_code}&coursenumber=#{course_number}").read
|
20
29
|
end
|
21
30
|
|
22
31
|
def parse_sections(html)
|
@@ -24,7 +33,9 @@ module OsuCcScraper
|
|
24
33
|
|
25
34
|
document.xpath(SECTIONS_XPATH).map { |row|
|
26
35
|
Section.new(
|
27
|
-
|
36
|
+
subject_code,
|
37
|
+
course_number,
|
38
|
+
name,
|
28
39
|
parse_term(row),
|
29
40
|
parse_section(row),
|
30
41
|
parse_instructor(row),
|
@@ -1,26 +1,35 @@
|
|
1
1
|
require "open-uri"
|
2
2
|
require "oga"
|
3
3
|
require "osu-cc-scraper/course"
|
4
|
+
require "json"
|
4
5
|
|
5
6
|
module OsuCcScraper
|
6
|
-
class Department < Struct.new(:
|
7
|
+
class Department < Struct.new(:name, :subject_code)
|
7
8
|
|
8
9
|
def courses
|
9
10
|
html = fetch_courses
|
10
11
|
parse_courses(html)
|
11
12
|
end
|
12
13
|
|
14
|
+
def to_json
|
15
|
+
self.to_h.to_json
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.from_json(json)
|
19
|
+
Department.new(*JSON.parse(json).values)
|
20
|
+
end
|
21
|
+
|
13
22
|
private
|
14
23
|
|
15
24
|
def fetch_courses
|
16
|
-
open("#{ENDPOINT}/CourseList.aspx?subjectcode=#{subject_code}
|
25
|
+
open("#{ENDPOINT}/CourseList.aspx?subjectcode=#{subject_code}").read
|
17
26
|
end
|
18
27
|
|
19
28
|
def parse_courses(html)
|
20
29
|
document = Oga.parse_html(html)
|
21
30
|
document.xpath("//tr//td//strong/a[last()]").map { |row|
|
22
31
|
Course.new(
|
23
|
-
|
32
|
+
subject_code,
|
24
33
|
parse_course_course_number(row),
|
25
34
|
parse_course_name(row)
|
26
35
|
)
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module OsuCcScraper
|
2
|
-
class Section < Struct.new(:
|
3
|
-
:
|
4
|
-
|
5
|
-
[ course.department.subject_code, course.course_number, course.name,
|
6
|
-
term, section, instructor, campus, type, status, capacity, current ]
|
7
|
-
end
|
8
|
-
|
2
|
+
class Section < Struct.new(:subject_code, :course_number, :name, :term,
|
3
|
+
:section, :instructor, :campus, :type, :status,
|
4
|
+
:capacity, :current)
|
9
5
|
end
|
10
6
|
end
|
@@ -3,7 +3,7 @@ require "oga"
|
|
3
3
|
require "osu-cc-scraper/department"
|
4
4
|
|
5
5
|
module OsuCcScraper
|
6
|
-
class University
|
6
|
+
class University
|
7
7
|
|
8
8
|
def departments
|
9
9
|
html = fetch_departments
|
@@ -13,14 +13,13 @@ module OsuCcScraper
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def fetch_departments
|
16
|
-
open("#{ENDPOINT}/CourseDescription.aspx
|
16
|
+
open("#{ENDPOINT}/CourseDescription.aspx").read
|
17
17
|
end
|
18
18
|
|
19
19
|
def parse_departments(html)
|
20
20
|
ng = Oga.parse_html(html)
|
21
21
|
ng.xpath("//tr/td/font/a").map { |row|
|
22
22
|
Department.new(
|
23
|
-
self,
|
24
23
|
parse_department_name(row),
|
25
24
|
parse_department_subject_code(row),
|
26
25
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osu-cc-scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonah George
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oga
|